aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2023-08-24 13:29:58 +0200
committerstijn <stijn@ignitron.net>2024-01-10 11:34:09 +0100
commitbd21820b4cc7d3c6c293b2fd104cb8214df686cd (patch)
tree5368d8af9fe9a4e0ed1813babd1e164d8ae55d38
parent88d21f186bc8ca9ef9728a36f5ca27731f2d86bc (diff)
tests/run-tests.py: Fix path-based special test detection.
Compare the full absolute path instead of relying on the path form passed by the user. For instance, this will make python3 run-tests.py -d basics python3 run-tests.py -d ./basics python3 run-tests.py -d ../tests/basics python3 run-tests.py -d /full/path/to/basics all behave the same by correctly treating the bytes_compare3 and builtin_help tests as special, whereas previously only the first invocation would do that and hence result in these tests to fail when called with a different path form. Signed-off-by: stijn <stijn@ignitron.net>
-rwxr-xr-xtests/run-tests.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/tests/run-tests.py b/tests/run-tests.py
index 8fe97be6c..4d4c2543b 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -176,20 +176,25 @@ def run_script_on_remote_target(pyb, args, test_file, is_special):
return had_crash, output_mupy
-def run_micropython(pyb, args, test_file, is_special=False):
- special_tests = (
+special_tests = [
+ base_path(file)
+ for file in (
"micropython/meminfo.py",
"basics/bytes_compare3.py",
"basics/builtin_help.py",
"thread/thread_exc2.py",
"esp32/partition_ota.py",
)
+]
+
+
+def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False):
had_crash = False
if pyb is None:
# run on PC
if (
- test_file.startswith(("cmdline/", base_path("feature_check/")))
- or test_file in special_tests
+ test_file_abspath.startswith((base_path("cmdline/"), base_path("feature_check/")))
+ or test_file_abspath in special_tests
):
# special handling for tests of the unix cmdline program
is_special = True
@@ -283,7 +288,7 @@ def run_micropython(pyb, args, test_file, is_special=False):
mpy_modname = os.path.splitext(os.path.basename(mpy_filename))[0]
cmdlist.extend(["-m", mpy_modname])
else:
- cmdlist.append(os.path.abspath(test_file))
+ cmdlist.append(test_file_abspath)
# run the actual test
try:
@@ -316,7 +321,7 @@ def run_micropython(pyb, args, test_file, is_special=False):
if is_special and not had_crash and b"\nSKIP\n" in output_mupy:
return b"SKIP\n"
- if is_special or test_file in special_tests:
+ if is_special or test_file_abspath in special_tests:
# convert parts of the output that are not stable across runs
with open(test_file + ".exp", "rb") as f:
lines_exp = []
@@ -364,7 +369,8 @@ def run_feature_check(pyb, args, test_file):
if pyb is not None and test_file.startswith("repl_"):
# REPL feature tests will not run via pyboard because they require prompt interactivity
return b""
- return run_micropython(pyb, args, base_path("feature_check", test_file), is_special=True)
+ test_file_path = base_path("feature_check", test_file)
+ return run_micropython(pyb, args, test_file_path, test_file_path, is_special=True)
class ThreadSafeCounter:
@@ -673,6 +679,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
def run_one_test(test_file):
test_file = test_file.replace("\\", "/")
+ test_file_abspath = os.path.abspath(test_file).replace("\\", "/")
if args.filters:
# Default verdict is the opposit of the first action
@@ -733,7 +740,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
# run CPython to work out expected output
try:
output_expected = subprocess.check_output(
- CPYTHON3_CMD + [os.path.abspath(test_file)],
+ CPYTHON3_CMD + [test_file_abspath],
cwd=os.path.dirname(test_file),
stderr=subprocess.STDOUT,
)
@@ -750,7 +757,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
return
# run MicroPython
- output_mupy = run_micropython(pyb, args, test_file)
+ output_mupy = run_micropython(pyb, args, test_file, test_file_abspath)
if output_mupy == b"SKIP\n":
print("skip ", test_file)