Skip to content

Commit e0d2e96

Browse files
aheejinradekdoulik
authored andcommitted
[test] Make get_tests return only files (WebAssembly#6164)
Currently `get_tests` returns files and directories, especially when the extension is not given. This makes `get_tests` return a directory like `test/wasm2js/` as a test. `wasm2js.py`'s `check_for_stale_files` errors out when there are files within `test/wasm2js/` whose basenames don't match any files within any of `test/`, `test/spec/`, `test/wasm2js/`. https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L33-L46 `wasm2js.wast.asserts` is apparently a special case for asserts test: https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L28 and this doesn't seem to have the matching `wast` tests in the three test directories. But it just happened to not error out because `get_tests` returns directory names too and one of them was `wasm2js` (`test/wasm2js/` directory). This makes `get_tests` return only files, and make files in `assert_tests` not error out additionally.
1 parent 49a16af commit e0d2e96

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

scripts/test/shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def get_tests(test_dir, extensions=[], recursive=False):
386386
tests += glob.glob(os.path.join(test_dir, star + ext), recursive=True)
387387
if options.test_name_filter:
388388
tests = fnmatch.filter(tests, options.test_name_filter)
389+
tests = [item for item in tests if os.path.isfile(item)]
389390
return sorted(tests)
390391

391392

scripts/test/wasm2js.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def check_for_stale_files():
4141

4242
all_files = os.listdir(shared.get_test_dir('wasm2js'))
4343
for f in all_files:
44+
if f in assert_tests:
45+
continue
4446
prefix = f.split('.')[0]
4547
if prefix not in all_tests:
4648
shared.fail_with_error('orphan test output: %s' % f)

0 commit comments

Comments
 (0)