Skip to content

Commit

Permalink
Bug fixes for filtering recursively in maps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh committed Oct 17, 2022
1 parent a253bd1 commit 16dee77
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docker/android/scripts/build-system.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def remove_soong_tests(path, args, *_):
else:
map = node.expr
for key, value, *_ in map.recurse():
if value.is_list():
if value.value.is_list():
value.filter(lambda x: x.str_op(lambda y: 'libgtest' not in y.lower()))

with open(path, 'w') as file:
Expand Down
9 changes: 9 additions & 0 deletions docker/android/tests/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@ cc_test_host {
"-fstrict-aliasing",
],
}
cc_defaults {
name: "custom",
shared_libs: ["libcustom"],
whole_static_libs: [
"libz",
"libgtest_main",
],
host_ldlibs: ["-lgtest"],
}
15 changes: 12 additions & 3 deletions docker/android/tests/test_soong.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test():

parser = soong.Parser()
result = parser.parse(iter(tokens))
assert len(result) == 6
assert len(result) == 7

assert result[0].is_assignment()
assert result[0].to_str() == '''sample_array = [
Expand Down Expand Up @@ -55,8 +55,8 @@ def test():
filtered = copy.deepcopy(ast)
filtered.filter(lambda x: not (x.is_scope() and x.is_dev()))
assert type(filtered) is soong.Ast
assert len(filtered) == 4
assert filtered == ast[:4]
assert len(filtered) == 5
assert filtered == ast[:4] + [ast[6]]

map = filtered[1].map
assert 'cflags' in map
Expand All @@ -66,6 +66,15 @@ def test():
map['array'].filter(lambda x: x != '-short')
assert len(map['array']) == 1

custom = filtered[4].map
assert 'whole_static_libs' in custom
custom['whole_static_libs'].filter(lambda x: x.str_op(lambda y: 'gtest' not in y.lower()))
assert custom['whole_static_libs'] == ['libz']

assert 'host_ldlibs' in custom
custom['host_ldlibs'].filter(lambda x: x.str_op(lambda y: 'gtest' not in y.lower()))
assert custom['host_ldlibs'] == []


def test_addition():
path = os.path.join(TEST_DIR, 'Addition.bp')
Expand Down

0 comments on commit 16dee77

Please sign in to comment.