Skip to content

Commit 16dee77

Browse files
committed
Bug fixes for filtering recursively in maps.
1 parent a253bd1 commit 16dee77

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

docker/android/scripts/build-system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def remove_soong_tests(path, args, *_):
6565
else:
6666
map = node.expr
6767
for key, value, *_ in map.recurse():
68-
if value.is_list():
68+
if value.value.is_list():
6969
value.filter(lambda x: x.str_op(lambda y: 'libgtest' not in y.lower()))
7070

7171
with open(path, 'w') as file:

docker/android/tests/Android.bp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,12 @@ cc_test_host {
6969
"-fstrict-aliasing",
7070
],
7171
}
72+
cc_defaults {
73+
name: "custom",
74+
shared_libs: ["libcustom"],
75+
whole_static_libs: [
76+
"libz",
77+
"libgtest_main",
78+
],
79+
host_ldlibs: ["-lgtest"],
80+
}

docker/android/tests/test_soong.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test():
2222

2323
parser = soong.Parser()
2424
result = parser.parse(iter(tokens))
25-
assert len(result) == 6
25+
assert len(result) == 7
2626

2727
assert result[0].is_assignment()
2828
assert result[0].to_str() == '''sample_array = [
@@ -55,8 +55,8 @@ def test():
5555
filtered = copy.deepcopy(ast)
5656
filtered.filter(lambda x: not (x.is_scope() and x.is_dev()))
5757
assert type(filtered) is soong.Ast
58-
assert len(filtered) == 4
59-
assert filtered == ast[:4]
58+
assert len(filtered) == 5
59+
assert filtered == ast[:4] + [ast[6]]
6060

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

69+
custom = filtered[4].map
70+
assert 'whole_static_libs' in custom
71+
custom['whole_static_libs'].filter(lambda x: x.str_op(lambda y: 'gtest' not in y.lower()))
72+
assert custom['whole_static_libs'] == ['libz']
73+
74+
assert 'host_ldlibs' in custom
75+
custom['host_ldlibs'].filter(lambda x: x.str_op(lambda y: 'gtest' not in y.lower()))
76+
assert custom['host_ldlibs'] == []
77+
6978

7079
def test_addition():
7180
path = os.path.join(TEST_DIR, 'Addition.bp')

0 commit comments

Comments
 (0)