From 70e855b30114853b86f0947f49cb5a77ddad6aa9 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 20 Aug 2020 14:00:18 -0700 Subject: Harmonize auto updater with test runner: wasm-opt should update .fromBinary outputs (#3066) It was confusing that you had to run ./auto_update_tests.py binfmt to update a test checked by ./check.py wasm-opt. Instead, make ./auto_update_tests.py wasm-opt update those, so it's symmetrical. --- scripts/test/wasm_opt.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'scripts/test') diff --git a/scripts/test/wasm_opt.py b/scripts/test/wasm_opt.py index 986ce2f61..2c7d49eb7 100644 --- a/scripts/test/wasm_opt.py +++ b/scripts/test/wasm_opt.py @@ -204,3 +204,29 @@ def update_wasm_opt_tests(): support.run_command(shared.WASM_OPT + ['a.wasm', '--input-source-map=a.map', '-o', 'b.wasm', '--output-source-map=b.map', '-g']) actual = support.run_command(shared.WASM_DIS + ['b.wasm', '--source-map=b.map']) open(f, 'w').write(actual) + + print('\n[ checking binary format testcases... ]\n') + for wast in shared.get_tests(shared.options.binaryen_test, ['.wast']): + for debug_info in [0, 1]: + cmd = shared.WASM_AS + [wast, '-o', 'a.wasm', '-all'] + if debug_info: + cmd += ['-g'] + print(' '.join(cmd)) + if os.path.exists('a.wasm'): + os.unlink('a.wasm') + subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + assert os.path.exists('a.wasm') + + cmd = shared.WASM_DIS + ['a.wasm', '-o', 'a.wast'] + print(' '.join(cmd)) + if os.path.exists('a.wast'): + os.unlink('a.wast') + subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + assert os.path.exists('a.wast') + actual = open('a.wast').read() + binary_file = wast + '.fromBinary' + if not debug_info: + binary_file += '.noDebugInfo' + with open(binary_file, 'w') as o: + print('writey', binary_file) + o.write(actual) -- cgit v1.2.3