Skip to content

Commit 5bd28d6

Browse files
Extract out some variables
1 parent 505ecae commit 5bd28d6

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

check.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,21 @@ def run_spec_tests():
210210
print('\n[ checking wasm-shell spec testcases... ]\n')
211211

212212
def run_one(wast: Path, stdout=None, stderr=None):
213-
base = wast.name
214-
print('..', base, file=stdout)
213+
test_name = wast.name
214+
base_name = "-".join(wast.parts[-3:])
215+
216+
print('..', test_name, file=stdout)
215217
# windows has some failures that need to be investigated
216-
if base == 'names.wast' and shared.skip_if_on_windows('spec: ' + base):
218+
if test_name == 'names.wast' and shared.skip_if_on_windows('spec: ' + test_name):
217219
return
218220

219-
expected = os.path.join(shared.get_test_dir('spec'), 'expected-output', base + '.log')
221+
expected = os.path.join(shared.get_test_dir('spec'), 'expected-output', test_name + '.log')
220222

221223
# some spec tests should fail (actual process failure, not just assert_invalid)
222224
try:
223225
actual = run_spec_test(str(wast), stdout=stdout, stderr=stderr)
224226
except Exception as e:
225-
if ('wasm-validator error' in str(e) or 'error: ' in str(e)) and '.fail.' in base:
227+
if ('wasm-validator error' in str(e) or 'error: ' in str(e)) and '.fail.' in test_name:
226228
print('<< test failed as expected >>', file=stdout)
227229
return # don't try all the binary format stuff TODO
228230
else:
@@ -233,25 +235,25 @@ def run_one(wast: Path, stdout=None, stderr=None):
233235
# check binary format. here we can verify execution of the final
234236
# result, no need for an output verification
235237
actual = ''
236-
with open("-".join(wast.parts[-3:]) + ".transformed", 'w') as transformed_spec_file:
238+
with open(base_name + ".transformed", 'w') as transformed_spec_file:
237239
for i, (module, asserts) in enumerate(support.split_wast(str(wast))):
238240
if not module:
239241
# Skip any initial assertions that don't have a module
240242
return
241243
print(f' testing split module {i}', file=stdout)
242-
split_name = "-".join(wast.parts[-3:]) + f'_split{i}.wast'
244+
split_name = base_name + f'_split{i}.wast'
243245
support.write_wast(split_name, module)
244246
run_opt_test(split_name, stdout=stdout, stderr=stderr) # also that our optimizer doesn't break on it
245247

246-
result_wast_file = shared.binary_format_check(split_name, verify_final_result=False, base_name="-".join(wast.parts[-3:]), stdout=stdout, stderr=stderr)
248+
result_wast_file = shared.binary_format_check(split_name, verify_final_result=False, base_name=base_name, stdout=stdout, stderr=stderr)
247249
with open(result_wast_file) as f:
248250
result_wast = f.read()
249251
# add the asserts, and verify that the test still passes
250252
transformed_spec_file.write(result_wast + '\n' + '\n'.join(asserts))
251253

252254
# compare all the outputs to the expected output
253-
actual = run_spec_test("-".join(wast.parts[-3:]) + ".transformed", stdout=stdout, stderr=stderr)
254-
check_expected(actual, os.path.join(shared.get_test_dir('spec'), 'expected-output', base + '.log'), stdout=stdout)
255+
actual = run_spec_test(base_name + ".transformed", stdout=stdout, stderr=stderr)
256+
check_expected(actual, os.path.join(shared.get_test_dir('spec'), 'expected-output', test_name + '.log'), stdout=stdout)
255257

256258
output_queue = queue.Queue()
257259

0 commit comments

Comments
 (0)