kopia lustrzana https://github.com/micropython/micropython
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>pull/12296/head
rodzic
88d21f186b
commit
bd21820b4c
|
@ -176,20 +176,25 @@ def run_script_on_remote_target(pyb, args, test_file, is_special):
|
||||||
return had_crash, output_mupy
|
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",
|
"micropython/meminfo.py",
|
||||||
"basics/bytes_compare3.py",
|
"basics/bytes_compare3.py",
|
||||||
"basics/builtin_help.py",
|
"basics/builtin_help.py",
|
||||||
"thread/thread_exc2.py",
|
"thread/thread_exc2.py",
|
||||||
"esp32/partition_ota.py",
|
"esp32/partition_ota.py",
|
||||||
)
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False):
|
||||||
had_crash = False
|
had_crash = False
|
||||||
if pyb is None:
|
if pyb is None:
|
||||||
# run on PC
|
# run on PC
|
||||||
if (
|
if (
|
||||||
test_file.startswith(("cmdline/", base_path("feature_check/")))
|
test_file_abspath.startswith((base_path("cmdline/"), base_path("feature_check/")))
|
||||||
or test_file in special_tests
|
or test_file_abspath in special_tests
|
||||||
):
|
):
|
||||||
# special handling for tests of the unix cmdline program
|
# special handling for tests of the unix cmdline program
|
||||||
is_special = True
|
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]
|
mpy_modname = os.path.splitext(os.path.basename(mpy_filename))[0]
|
||||||
cmdlist.extend(["-m", mpy_modname])
|
cmdlist.extend(["-m", mpy_modname])
|
||||||
else:
|
else:
|
||||||
cmdlist.append(os.path.abspath(test_file))
|
cmdlist.append(test_file_abspath)
|
||||||
|
|
||||||
# run the actual test
|
# run the actual test
|
||||||
try:
|
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:
|
if is_special and not had_crash and b"\nSKIP\n" in output_mupy:
|
||||||
return b"SKIP\n"
|
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
|
# convert parts of the output that are not stable across runs
|
||||||
with open(test_file + ".exp", "rb") as f:
|
with open(test_file + ".exp", "rb") as f:
|
||||||
lines_exp = []
|
lines_exp = []
|
||||||
|
@ -364,7 +369,8 @@ def run_feature_check(pyb, args, test_file):
|
||||||
if pyb is not None and test_file.startswith("repl_"):
|
if pyb is not None and test_file.startswith("repl_"):
|
||||||
# REPL feature tests will not run via pyboard because they require prompt interactivity
|
# REPL feature tests will not run via pyboard because they require prompt interactivity
|
||||||
return b""
|
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:
|
class ThreadSafeCounter:
|
||||||
|
@ -673,6 +679,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
|
||||||
|
|
||||||
def run_one_test(test_file):
|
def run_one_test(test_file):
|
||||||
test_file = test_file.replace("\\", "/")
|
test_file = test_file.replace("\\", "/")
|
||||||
|
test_file_abspath = os.path.abspath(test_file).replace("\\", "/")
|
||||||
|
|
||||||
if args.filters:
|
if args.filters:
|
||||||
# Default verdict is the opposit of the first action
|
# 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
|
# run CPython to work out expected output
|
||||||
try:
|
try:
|
||||||
output_expected = subprocess.check_output(
|
output_expected = subprocess.check_output(
|
||||||
CPYTHON3_CMD + [os.path.abspath(test_file)],
|
CPYTHON3_CMD + [test_file_abspath],
|
||||||
cwd=os.path.dirname(test_file),
|
cwd=os.path.dirname(test_file),
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
)
|
)
|
||||||
|
@ -750,7 +757,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
|
||||||
return
|
return
|
||||||
|
|
||||||
# run MicroPython
|
# 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":
|
if output_mupy == b"SKIP\n":
|
||||||
print("skip ", test_file)
|
print("skip ", test_file)
|
||||||
|
|
Ładowanie…
Reference in New Issue