Skip to content

Commit c5a721c

Browse files
author
Jimmy Brisson
committed
Test that libraries' source is excluded
1 parent 7a360ef commit c5a721c

File tree

9 files changed

+35
-5
lines changed

9 files changed

+35
-5
lines changed

tools/build_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def get_config(src_paths, target, toolchain_name=None, app_config=None):
147147

148148
cfg, macros = config.get_config_data()
149149
features = config.get_features()
150-
return cfg, macros, features
150+
return cfg, macros, features, res
151151

152152
def is_official_target(target_name, version):
153153
""" Returns True, None if a target is part of the official release for the

tools/test/config/config_test.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
from tools.build_api import get_config
2727
from tools.targets import set_targets_json_location, Target, TARGET_NAMES
2828
from tools.config import ConfigException, Config, ConfigParameter, ConfigMacro
29+
from tools.resources import Resources
30+
31+
NOT_CONFIG = [
32+
"expected_macros",
33+
"expected_features",
34+
"included_source",
35+
"excluded_source",
36+
]
2937

3038
def compare_config(cfg, expected):
3139
"""Compare the output of config against a dictionary of known good results
@@ -40,7 +48,7 @@ def compare_config(cfg, expected):
4048
except KeyError:
4149
return "Unexpected key '%s' in configuration data" % k
4250
for k in expected:
43-
if k not in ["expected_macros", "expected_features"] + list(cfg.keys()):
51+
if k not in NOT_CONFIG + list(cfg.keys()):
4452
return "Expected key '%s' was not found in configuration data" % k
4553
return ""
4654

@@ -73,7 +81,7 @@ def test_config(name):
7381
set_targets_json_location(targets_json if isfile(targets_json) else None)
7482
for target, expected in test_data.items():
7583
try:
76-
cfg, macros, features = get_config(test_dir, target, "GCC_ARM")
84+
cfg, macros, features, resources = get_config(test_dir, target, "GCC_ARM")
7785
res = compare_config(cfg, expected)
7886
assert not(res), res
7987
expected_macros = expected.get("expected_macros", None)
@@ -84,6 +92,25 @@ def test_config(name):
8492
assert sorted(expected_macros) == sorted(macros)
8593
if expected_features is not None:
8694
assert sorted(expected_features) == sorted(features)
95+
96+
included_source = [
97+
join(test_dir, src) for src in
98+
expected.get("included_source", [])
99+
]
100+
excluded_source = [
101+
join(test_dir, src) for src in
102+
expected.get("excluded_source", [])
103+
]
104+
for typ in Resources.ALL_FILE_TYPES:
105+
for _, path in resources.get_file_refs(typ):
106+
print(path)
107+
if included_source and path in included_source:
108+
included_source.remove(path)
109+
if excluded_source:
110+
assert(path not in excluded_source)
111+
assert(not included_source)
112+
if included_source:
113+
assert(False)
87114
except ConfigException as e:
88115
err_msg = str(e)
89116
if "exception_msg" not in expected:

tools/test/config/requires_from_lib/lib3/lib3.cpp

Whitespace-only changes.

tools/test/config/requires_from_lib/test_data.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"test_target": {
33
"lib3.test": "GOOD",
44
"lib2.test": "GOOD",
5-
"lib1.test": "GOOD"
5+
"lib1.test": "GOOD",
6+
"included_source": ["lib3/lib3.cpp"]
67
}
78
}

tools/test/config/requires_omit_lib/lib1/lib1.cpp

Whitespace-only changes.

tools/test/config/requires_omit_lib/lib2/lib2.c

Whitespace-only changes.

tools/test/config/requires_omit_lib/test_data.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"exception_msg": "Attempt to override undefined parameter 'lib2.test' in 'application[should_fail]'"
44
},
55
"should_pass": {
6-
"lib1.test": "GOOD"
6+
"lib1.test": "GOOD",
7+
"excluded_source": ["lib2/lib2.c"],
8+
"included_source": ["lib1/lib1.cpp"]
79
}
810
}

0 commit comments

Comments
 (0)