mirror of https://github.com/ARMmbed/mbed-os.git
Test that libraries' source is excluded
parent
7a360efe8a
commit
c5a721c104
|
@ -147,7 +147,7 @@ def get_config(src_paths, target, toolchain_name=None, app_config=None):
|
|||
|
||||
cfg, macros = config.get_config_data()
|
||||
features = config.get_features()
|
||||
return cfg, macros, features
|
||||
return cfg, macros, features, res
|
||||
|
||||
def is_official_target(target_name, version):
|
||||
""" Returns True, None if a target is part of the official release for the
|
||||
|
|
|
@ -26,6 +26,14 @@ from os.path import join, isfile, dirname, abspath
|
|||
from tools.build_api import get_config
|
||||
from tools.targets import set_targets_json_location, Target, TARGET_NAMES
|
||||
from tools.config import ConfigException, Config, ConfigParameter, ConfigMacro
|
||||
from tools.resources import Resources
|
||||
|
||||
NOT_CONFIG = [
|
||||
"expected_macros",
|
||||
"expected_features",
|
||||
"included_source",
|
||||
"excluded_source",
|
||||
]
|
||||
|
||||
def compare_config(cfg, expected):
|
||||
"""Compare the output of config against a dictionary of known good results
|
||||
|
@ -40,7 +48,7 @@ def compare_config(cfg, expected):
|
|||
except KeyError:
|
||||
return "Unexpected key '%s' in configuration data" % k
|
||||
for k in expected:
|
||||
if k not in ["expected_macros", "expected_features"] + list(cfg.keys()):
|
||||
if k not in NOT_CONFIG + list(cfg.keys()):
|
||||
return "Expected key '%s' was not found in configuration data" % k
|
||||
return ""
|
||||
|
||||
|
@ -73,7 +81,7 @@ def test_config(name):
|
|||
set_targets_json_location(targets_json if isfile(targets_json) else None)
|
||||
for target, expected in test_data.items():
|
||||
try:
|
||||
cfg, macros, features = get_config(test_dir, target, "GCC_ARM")
|
||||
cfg, macros, features, resources = get_config(test_dir, target, "GCC_ARM")
|
||||
res = compare_config(cfg, expected)
|
||||
assert not(res), res
|
||||
expected_macros = expected.get("expected_macros", None)
|
||||
|
@ -84,6 +92,25 @@ def test_config(name):
|
|||
assert sorted(expected_macros) == sorted(macros)
|
||||
if expected_features is not None:
|
||||
assert sorted(expected_features) == sorted(features)
|
||||
|
||||
included_source = [
|
||||
join(test_dir, src) for src in
|
||||
expected.get("included_source", [])
|
||||
]
|
||||
excluded_source = [
|
||||
join(test_dir, src) for src in
|
||||
expected.get("excluded_source", [])
|
||||
]
|
||||
for typ in Resources.ALL_FILE_TYPES:
|
||||
for _, path in resources.get_file_refs(typ):
|
||||
print(path)
|
||||
if included_source and path in included_source:
|
||||
included_source.remove(path)
|
||||
if excluded_source:
|
||||
assert(path not in excluded_source)
|
||||
assert(not included_source)
|
||||
if included_source:
|
||||
assert(False)
|
||||
except ConfigException as e:
|
||||
err_msg = str(e)
|
||||
if "exception_msg" not in expected:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"test_target": {
|
||||
"lib3.test": "GOOD",
|
||||
"lib2.test": "GOOD",
|
||||
"lib1.test": "GOOD"
|
||||
"lib1.test": "GOOD",
|
||||
"included_source": ["lib3/lib3.cpp"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
"exception_msg": "Attempt to override undefined parameter 'lib2.test' in 'application[should_fail]'"
|
||||
},
|
||||
"should_pass": {
|
||||
"lib1.test": "GOOD"
|
||||
"lib1.test": "GOOD",
|
||||
"excluded_source": ["lib2/lib2.c"],
|
||||
"included_source": ["lib1/lib1.cpp"]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue