summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtest/run-tests.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/test/run-tests.py b/test/run-tests.py
index 2d4c1da1..766d0578 100755
--- a/test/run-tests.py
+++ b/test/run-tests.py
@@ -707,6 +707,16 @@ def GetAllTestInfo(test_names, status):
return infos
+def CanonicalizePath(path):
+ """In order to get identical test results we canonicalize path
+ names that we pass into test code. We use posix path separators
+ because they work sufficiently well on all platforms (including
+ windows)."""
+ # For some reason this doesn't work on winows:
+ # return str(pathlib.PurePosixPath(path))
+ return path.replace(os.path.sep, '/')
+
+
def RunTest(info, options, variables, verbose_level=0):
timeout = options.timeout
if info.slow:
@@ -719,9 +729,8 @@ def RunTest(info, options, variables, verbose_level=0):
env = dict(os.environ)
env.update(info.env)
gen_input_path = info.CreateInputFile()
- rel_gen_input_path = (
- os.path.relpath(gen_input_path, cwd).replace(os.path.sep, '/'))
- variables['in_file'] = rel_gen_input_path
+ rel_gen_input_path = os.path.relpath(gen_input_path, cwd)
+ variables['in_file'] = CanonicalizePath(rel_gen_input_path)
# Each test runs with a unique output directory which is removed before
# we run the test.
@@ -729,13 +738,13 @@ def RunTest(info, options, variables, verbose_level=0):
if os.path.isdir(out_dir):
shutil.rmtree(out_dir)
os.makedirs(out_dir)
- variables['out_dir'] = out_dir
+ variables['out_dir'] = CanonicalizePath(out_dir)
# Temporary files typically are placed in `out_dir` and use the same test's
# basename. This name does include an extension.
input_basename = os.path.basename(rel_gen_input_path)
- variables['temp_file'] = os.path.join(out_dir,
- os.path.splitext(input_basename)[0])
+ temp_file = os.path.join(out_dir, os.path.splitext(input_basename)[0])
+ variables['temp_file'] = CanonicalizePath(temp_file)
test_result = TestResult()