mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #6793 from theotherjimmy/fix-test-config-passing
tools: Pass app-config to get_configpull/6522/merge
commit
c52a8d6044
|
@ -120,7 +120,7 @@ def add_result_to_report(report, result):
|
||||||
result_wrap = {0: result}
|
result_wrap = {0: result}
|
||||||
report[target][toolchain][id_name].append(result_wrap)
|
report[target][toolchain][id_name].append(result_wrap)
|
||||||
|
|
||||||
def get_config(src_paths, target, toolchain_name):
|
def get_config(src_paths, target, toolchain_name, app_config=None):
|
||||||
"""Get the configuration object for a target-toolchain combination
|
"""Get the configuration object for a target-toolchain combination
|
||||||
|
|
||||||
Positional arguments:
|
Positional arguments:
|
||||||
|
@ -133,7 +133,8 @@ def get_config(src_paths, target, toolchain_name):
|
||||||
src_paths = [src_paths]
|
src_paths = [src_paths]
|
||||||
|
|
||||||
# Pass all params to the unified prepare_resources()
|
# Pass all params to the unified prepare_resources()
|
||||||
toolchain = prepare_toolchain(src_paths, None, target, toolchain_name)
|
toolchain = prepare_toolchain(src_paths, None, target, toolchain_name,
|
||||||
|
app_config=app_config)
|
||||||
|
|
||||||
# Scan src_path for config files
|
# Scan src_path for config files
|
||||||
resources = toolchain.scan_resources(src_paths[0])
|
resources = toolchain.scan_resources(src_paths[0])
|
||||||
|
|
|
@ -33,7 +33,8 @@ from tools.utils import argparse_filestring_type
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Parse Options
|
# Parse Options
|
||||||
parser = get_default_options_parser(add_clean=False, add_options=False)
|
parser = get_default_options_parser(add_clean=False, add_options=False,
|
||||||
|
add_app_config=True)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--source", dest="source_dir", type=argparse_filestring_type,
|
"--source", dest="source_dir", type=argparse_filestring_type,
|
||||||
required=True, default=[], help="The source (input) directory",
|
required=True, default=[], help="The source (input) directory",
|
||||||
|
@ -61,7 +62,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
try:
|
try:
|
||||||
params, macros, features = get_config(
|
params, macros, features = get_config(
|
||||||
options.source_dir, target, toolchain)
|
options.source_dir, target, toolchain, app_config=options.app_config)
|
||||||
if not params and not macros:
|
if not params and not macros:
|
||||||
print("No configuration data available.")
|
print("No configuration data available.")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -78,9 +78,11 @@ def test_find_tests_app_config(build_path, target, toolchain_name, app_config):
|
||||||
src_paths = ['.']
|
src_paths = ['.']
|
||||||
set_targets_json_location()
|
set_targets_json_location()
|
||||||
with patch('tools.test_api.scan_resources') as mock_scan_resources,\
|
with patch('tools.test_api.scan_resources') as mock_scan_resources,\
|
||||||
patch('tools.test_api.build_project') as mock_build_project:
|
patch('tools.test_api.build_project') as mock_build_project,\
|
||||||
|
patch('tools.test_api.get_config') as mock_get_config:
|
||||||
mock_build_project.return_value = "build_project"
|
mock_build_project.return_value = "build_project"
|
||||||
mock_scan_resources().inc_dirs.return_value = []
|
mock_scan_resources().inc_dirs.return_value = []
|
||||||
|
mock_get_config.return_value = ({}, "", "")
|
||||||
|
|
||||||
build_tests(tests, src_paths, build_path, target, toolchain_name,
|
build_tests(tests, src_paths, build_path, target, toolchain_name,
|
||||||
app_config=app_config)
|
app_config=app_config)
|
||||||
|
@ -91,3 +93,5 @@ def test_find_tests_app_config(build_path, target, toolchain_name, app_config):
|
||||||
"build_tests was not called with app_config"
|
"build_tests was not called with app_config"
|
||||||
assert args[1]['app_config'] == app_config,\
|
assert args[1]['app_config'] == app_config,\
|
||||||
"build_tests was called with an incorrect app_config"
|
"build_tests was called with an incorrect app_config"
|
||||||
|
mock_get_config.called_with(src_paths, target,
|
||||||
|
toolchain_name, app_conifg=app_config)
|
||||||
|
|
|
@ -2220,7 +2220,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
|
||||||
base_path = norm_relative_path(build_path, execution_directory)
|
base_path = norm_relative_path(build_path, execution_directory)
|
||||||
|
|
||||||
target_name = target.name if isinstance(target, Target) else target
|
target_name = target.name if isinstance(target, Target) else target
|
||||||
cfg, _, _ = get_config(base_source_paths, target_name, toolchain_name)
|
cfg, _, _ = get_config(base_source_paths, target_name, toolchain_name, app_config=app_config)
|
||||||
|
|
||||||
baud_rate = 9600
|
baud_rate = 9600
|
||||||
if 'platform.stdio-baud-rate' in cfg:
|
if 'platform.stdio-baud-rate' in cfg:
|
||||||
|
|
Loading…
Reference in New Issue