Skip to content

Commit b8c64cd

Browse files
authored
Merge pull request #2102 from mbedmicro/fix_tests_with_config
Fix tests with config
2 parents 7c00a75 + fbb26a4 commit b8c64cd

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

tools/build_api.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,16 @@ def build_library(src_paths, build_path, target, toolchain_name,
282282
# We will use default project name based on project folder name
283283
name = project_name
284284

285+
# If the configuration object was not yet created, create it now
286+
config = Config(target, src_paths)
287+
288+
# If the 'target' argument is a string, convert it to a target instance
289+
if isinstance(target, str):
290+
try:
291+
target = TARGET_MAP[target]
292+
except KeyError:
293+
raise KeyError("Target '%s' not found" % target)
294+
285295
if report != None:
286296
start = time()
287297

@@ -355,9 +365,6 @@ def build_library(src_paths, build_path, target, toolchain_name,
355365
else:
356366
tmp_path = build_path
357367

358-
# Handle configuration
359-
config = Config(target)
360-
361368
# Load resources into the config system which might expand/modify resources based on config data
362369
resources = config.load_resources(resources)
363370

tools/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
base_source_paths = ['.']
133133

134134

135-
target = TARGET_MAP[options.mcu]
135+
target = options.mcu
136136

137137
build_report = {}
138138
build_properties = {}

tools/test_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,9 +2030,11 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20302030
execution_directory = "."
20312031

20322032
base_path = norm_relative_path(build_path, execution_directory)
2033+
2034+
target_name = target if isinstance(target, str) else target.name
20332035

20342036
test_build = {
2035-
"platform": target.name,
2037+
"platform": target_name,
20362038
"toolchain": toolchain_name,
20372039
"base_path": base_path,
20382040
"baud_rate": 9600,
@@ -2086,7 +2088,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20862088
print 'Image: %s'% bin_file
20872089

20882090
test_builds = {}
2089-
test_builds["%s-%s" % (target.name, toolchain_name)] = test_build
2091+
test_builds["%s-%s" % (target_name, toolchain_name)] = test_build
20902092

20912093

20922094
return result, test_builds

0 commit comments

Comments
 (0)