mirror of
https://github.com/micropython/micropython.git
synced 2026-03-11 03:10:17 +01:00
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>
This commit is contained in:
@@ -838,6 +838,8 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
|
||||
# Works but CPython uses '\' path separator
|
||||
skip_tests.add("import/import_file.py")
|
||||
|
||||
skip_tests = [os.path.realpath(base_path(skip_test)) for skip_test in skip_tests]
|
||||
|
||||
def run_one_test(test_file):
|
||||
test_file = test_file.replace("\\", "/")
|
||||
test_file_abspath = os.path.abspath(test_file).replace("\\", "/")
|
||||
@@ -869,7 +871,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
|
||||
is_fstring = test_name.startswith("string_fstring")
|
||||
is_inlineasm = test_name.startswith("asm")
|
||||
|
||||
skip_it = test_file in skip_tests
|
||||
skip_it = os.path.realpath(test_file) in skip_tests
|
||||
skip_it |= skip_native and is_native
|
||||
skip_it |= skip_endian and is_endian
|
||||
skip_it |= skip_int_big and is_int_big
|
||||
|
||||
Reference in New Issue
Block a user