Skip to content

Commit

Permalink
Fixed some spelling errors and test that failed on Bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
kkress committed Feb 11, 2022
1 parent c949462 commit 2830756
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
18 changes: 9 additions & 9 deletions lib/subpackages.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

"""Skylib module containing common functions for working with native.subpackages()
"""
_SUBACKAGES_SUPPORTED = "subpackages" in dir(native)
_SUBPACKAGES_SUPPORTED = hasattr(native, "subpackages")

def _supported():
return _SUBACKAGES_SUPPORTED
return _SUBPACKAGES_SUPPORTED

def _check_supported():
if not _SUBACKAGES_SUPPORTED:
if not _SUBPACKAGES_SUPPORTED:
fail("native.subpackages not supported.")

def _all(exclude = [], allow_empty = False, fully_qualified = True):
Expand All @@ -31,13 +31,13 @@ def _all(exclude = [], allow_empty = False, fully_qualified = True):
Example:
Assuming the following BUILD files exist:
BUILD
foo/BUILD
foo/sub/BUILD
bar/BUILD
baz/deep/dir/BUILD
BUILD
foo/BUILD
foo/sub/BUILD
bar/BUILD
baz/deep/dir/BUILD
If the current package is 'BUILD' all() will return ['//foo', '//bar',
If the current package is '//' all() will return ['//foo', '//bar',
'//baz/deep/dir']. //foo/sub is not included because it is a direct
subpackage of '//foo' not '//'
Expand Down
11 changes: 7 additions & 4 deletions tests/subpackages_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ def _all_test(env):
"write_file",
]

# subpackages is always in sorted order:
all_pkgs = sorted(all_pkgs)

# test defaults
loadingtest.asserts(
loadingtest.equals(
env,
"all",
all_pkgs,
subpackages.all(fully_qualified = False),
)

# test exclusion
loadingtest.asserts(
loadingtest.equals(
env,
"all_w_exclude",
filtered_pkgs,
Expand All @@ -59,8 +62,8 @@ def _all_test(env):

def _exists_test(env):
"""Unit tests for subpackages.exists."""
loadingtest.asserts(env, "exists_yes", True, subpackages.exists("copy_file"))
loadingtest.asserts(env, "exists_no", False, subpackages.exists("never_existed"))
loadingtest.equals(env, "exists_yes", True, subpackages.exists("copy_file"))
loadingtest.equals(env, "exists_no", False, subpackages.exists("never_existed"))

def subpackages_test_suite():
"""Creates the test targets and test suite for subpackages.bzl tests."""
Expand Down

0 comments on commit 2830756

Please sign in to comment.