Skip to content

Commit c52a8d6

Browse files
author
Cruz Monrreal
authored
Merge pull request #6793 from theotherjimmy/fix-test-config-passing
tools: Pass app-config to get_config
2 parents 39fd120 + 0579c7e commit c52a8d6

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

tools/build_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def add_result_to_report(report, result):
120120
result_wrap = {0: result}
121121
report[target][toolchain][id_name].append(result_wrap)
122122

123-
def get_config(src_paths, target, toolchain_name):
123+
def get_config(src_paths, target, toolchain_name, app_config=None):
124124
"""Get the configuration object for a target-toolchain combination
125125
126126
Positional arguments:
@@ -133,7 +133,8 @@ def get_config(src_paths, target, toolchain_name):
133133
src_paths = [src_paths]
134134

135135
# Pass all params to the unified prepare_resources()
136-
toolchain = prepare_toolchain(src_paths, None, target, toolchain_name)
136+
toolchain = prepare_toolchain(src_paths, None, target, toolchain_name,
137+
app_config=app_config)
137138

138139
# Scan src_path for config files
139140
resources = toolchain.scan_resources(src_paths[0])

tools/get_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
if __name__ == '__main__':
3535
# Parse Options
36-
parser = get_default_options_parser(add_clean=False, add_options=False)
36+
parser = get_default_options_parser(add_clean=False, add_options=False,
37+
add_app_config=True)
3738
parser.add_argument(
3839
"--source", dest="source_dir", type=argparse_filestring_type,
3940
required=True, default=[], help="The source (input) directory",
@@ -61,7 +62,7 @@
6162

6263
try:
6364
params, macros, features = get_config(
64-
options.source_dir, target, toolchain)
65+
options.source_dir, target, toolchain, app_config=options.app_config)
6566
if not params and not macros:
6667
print("No configuration data available.")
6768
sys.exit(0)

tools/test/test_api/test_api_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ def test_find_tests_app_config(build_path, target, toolchain_name, app_config):
7878
src_paths = ['.']
7979
set_targets_json_location()
8080
with patch('tools.test_api.scan_resources') as mock_scan_resources,\
81-
patch('tools.test_api.build_project') as mock_build_project:
81+
patch('tools.test_api.build_project') as mock_build_project,\
82+
patch('tools.test_api.get_config') as mock_get_config:
8283
mock_build_project.return_value = "build_project"
8384
mock_scan_resources().inc_dirs.return_value = []
85+
mock_get_config.return_value = ({}, "", "")
8486

8587
build_tests(tests, src_paths, build_path, target, toolchain_name,
8688
app_config=app_config)
@@ -91,3 +93,5 @@ def test_find_tests_app_config(build_path, target, toolchain_name, app_config):
9193
"build_tests was not called with app_config"
9294
assert args[1]['app_config'] == app_config,\
9395
"build_tests was called with an incorrect app_config"
96+
mock_get_config.called_with(src_paths, target,
97+
toolchain_name, app_conifg=app_config)

tools/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2220,7 +2220,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
22202220
base_path = norm_relative_path(build_path, execution_directory)
22212221

22222222
target_name = target.name if isinstance(target, Target) else target
2223-
cfg, _, _ = get_config(base_source_paths, target_name, toolchain_name)
2223+
cfg, _, _ = get_config(base_source_paths, target_name, toolchain_name, app_config=app_config)
22242224

22252225
baud_rate = 9600
22262226
if 'platform.stdio-baud-rate' in cfg:

0 commit comments

Comments
 (0)