Skip to content

Commit b7186bb

Browse files
committed
Test spec paths are now relative to tool execution directory
This commit also normalizes the paths produced by the the test spec to Unix style paths to increase portability of the file.
1 parent 07958da commit b7186bb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tools/test_api.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,15 @@ def print_tests(tests, format="list", sort=True):
20082008
print "Unknown format '%s'" % format
20092009
sys.exit(1)
20102010

2011+
def norm_relative_path(path, start):
2012+
"""This function will create a normalized, relative path. It mimics the
2013+
python os.path.relpath function, but also normalizes a Windows-syle path
2014+
that use backslashes to a Unix style path that uses forward slashes."""
2015+
path = os.path.normpath(path)
2016+
path = os.path.relpath(path, start)
2017+
path = path.replace("\\", "/")
2018+
return path
2019+
20112020
def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20122021
options=None, clean=False, notify=None, verbose=False, jobs=1,
20132022
macros=None, silent=False, report=None, properties=None,
@@ -2018,10 +2027,14 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20182027
Returns a tuple of the build result (True or False) followed by the test
20192028
build data structure"""
20202029

2030+
execution_directory = "."
2031+
2032+
base_path = norm_relative_path(build_path, execution_directory)
2033+
20212034
test_build = {
20222035
"platform": target.name,
20232036
"toolchain": toolchain_name,
2024-
"base_path": build_path,
2037+
"base_path": base_path,
20252038
"baud_rate": 9600,
20262039
"binary_type": "bootable",
20272040
"tests": {}
@@ -2060,7 +2073,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20602073

20612074
# Normalize the path
20622075
if bin_file:
2063-
bin_file = os.path.normpath(bin_file)
2076+
bin_file = norm_relative_path(bin_file, execution_directory)
20642077

20652078
test_build['tests'][test_name] = {
20662079
"binaries": [

0 commit comments

Comments
 (0)