Skip to content

Commit 2f79888

Browse files
Use relative paths for spec tests to skip to avoid ambiguity when two tests have the same basename (#8060)
* Update SPEC_TESTS_TO_SKIP and SPEC_TESTSUITE_TESTS_TO_SKIP to use relative paths, which allows us to distinguish between tests with the same base name. This is useful since some future changes will fix test/spec/testsuite/memory.wast but not test/spec/testsuite/proposals/threads/memory.wast * Check that the user-specified `--spec-test` paths exist. This is also done to avoid skipping rather than erroring when the user specifies a path relative to `test/` instead of relative to the repo root (since we drop the test/ prefix we can't tell the difference).
1 parent 6ec7b5f commit 2f79888

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

scripts/test/shared.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import fnmatch
2020
import glob
2121
import os
22+
from pathlib import Path
2223
import shutil
2324
import subprocess
2425
import sys
@@ -385,6 +386,9 @@ def get_tests(test_dir, extensions=[], recursive=False):
385386

386387

387388
if options.spec_tests:
389+
non_existent_tests = [test_name for test_name in options.spec_tests if not os.path.isfile(test_name)]
390+
if non_existent_tests:
391+
raise ValueError(f"Supplied test files do not exist: {non_existent_tests}")
388392
options.spec_tests = [os.path.abspath(t) for t in options.spec_tests]
389393
else:
390394
options.spec_tests = get_tests(get_test_dir('spec'), ['.wast'], recursive=True)
@@ -399,6 +403,7 @@ def get_tests(test_dir, extensions=[], recursive=False):
399403
# corresponding 'old_[FILENAME].wast' file. When you fix the new file and
400404
# delete the old file, make sure you rename the corresponding .wast.log file in
401405
# expected-output/ if any.
406+
# Paths are relative to the test/spec directory
402407
SPEC_TESTS_TO_SKIP = [
403408
# Requires us to write our own floating point parser
404409
'const.wast',
@@ -416,6 +421,8 @@ def get_tests(test_dir, extensions=[], recursive=False):
416421
'custom-page-sizes',
417422
'wide-arithmetic',
418423
]
424+
425+
# Paths are relative to the test/spec/testsuite directory
419426
SPEC_TESTSUITE_TESTS_TO_SKIP = [
420427
'address.wast', # 64-bit offset allowed by memory64
421428
'array_new_elem.wast', # Failure to parse element segment item abbreviation
@@ -434,8 +441,10 @@ def get_tests(test_dir, extensions=[], recursive=False):
434441
'global.wast', # Fail to parse table
435442
'if.wast', # Requires more precise unreachable validation
436443
'imports.wast', # Missing validation of missing function on instantiation
444+
'proposals/threads/imports.wast', # Missing memory type validation on instantiation
437445
'linking.wast', # Missing function type validation on instantiation
438446
'memory.wast', # Requires wast `module definition` support
447+
'proposals/threads/memory.wast', # Missing memory type validation on instantiation
439448
'memory64-imports.wast', # Missing validation on instantiation
440449
'annotations.wast', # String annotations IDs should be allowed
441450
'id.wast', # Empty IDs should be disallowed
@@ -493,12 +502,14 @@ def get_tests(test_dir, extensions=[], recursive=False):
493502

494503

495504
def _can_run_spec_test(test):
496-
if 'testsuite' in test:
497-
for proposal in SPEC_TESTSUITE_PROPOSALS_TO_SKIP:
498-
if proposal in test:
499-
return False
500-
return os.path.basename(test) not in SPEC_TESTSUITE_TESTS_TO_SKIP
501-
return os.path.basename(test) not in SPEC_TESTS_TO_SKIP
505+
test = Path(test)
506+
if 'testsuite' not in test.parts:
507+
return not any(test.match(f"test/spec/{test_to_skip}") for test_to_skip in SPEC_TESTS_TO_SKIP)
508+
509+
if any(proposal in test.parts for proposal in SPEC_TESTSUITE_PROPOSALS_TO_SKIP):
510+
return False
511+
512+
return not any(Path(test).match(f"test/spec/testsuite/{test_to_skip}") for test_to_skip in SPEC_TESTSUITE_TESTS_TO_SKIP)
502513

503514

504515
options.spec_tests = [t for t in options.spec_tests if _can_run_spec_test(t)]

0 commit comments

Comments
 (0)