Skip to content

Commit 634f605

Browse files
committed
tests/run-tests.py: Make skip logic work irregardless of test path.
Test file paths which get passed to the run_tests function can be absolute or relative and with or without leading slash in the latter case, depending on the arguments to run-tests.py, but the skip_tests list with tests to skip only contains relative paths so using simple string equality comparison easily leads to false negatives. Compare the full absolute path instead such that it doesn't matter anymore in which form the tests are passed. Note: - use realpath to resolve symlinks plus make the comparison case insensitive on windows - the test_file passed to run_one_test is not altered by this commit, such that when the user inputs relative paths the tests are also still displayed with relative paths - likewise the test_file_abspath is not modified because functions like run_micropython rely on it having forward slashes In practice this means that it used to be so that the only forms of running tests for which the skip_tests lists actually worked were: >python ./run-tests.py >python ./run-tests.py -d extmod whereas it now works consistently so also for these invocations, which in the end all point to the exact same path: >python ./run-tests.py -d ./extmod >python ./run-tests.py -d ../tests/extmod >python ./run-tests.py -d /full/path/to/tests/extmod These examples used to not skip any of the tests in the extmod/ directory thereby leading to test failures. Signed-off-by: stijn <stijn@ignitron.net>
1 parent d13b5c2 commit 634f605

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/run-tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,10 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
838838
# Works but CPython uses '\' path separator
839839
skip_tests.add("import/import_file.py")
840840

841+
skip_tests = [os.path.realpath(base_path(skip_test)) for skip_test in skip_tests]
842+
841843
def run_one_test(test_file):
844+
test_file_realpath = os.path.realpath(test_file)
842845
test_file = test_file.replace("\\", "/")
843846
test_file_abspath = os.path.abspath(test_file).replace("\\", "/")
844847

@@ -869,7 +872,7 @@ def run_one_test(test_file):
869872
is_fstring = test_name.startswith("string_fstring")
870873
is_inlineasm = test_name.startswith("asm")
871874

872-
skip_it = test_file in skip_tests
875+
skip_it = test_file_realpath in skip_tests
873876
skip_it |= skip_native and is_native
874877
skip_it |= skip_endian and is_endian
875878
skip_it |= skip_int_big and is_int_big

0 commit comments

Comments
 (0)