diff options
Diffstat (limited to 'auto_update_tests.py')
-rwxr-xr-x | auto_update_tests.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py index 8e33e1517..75396655e 100755 --- a/auto_update_tests.py +++ b/auto_update_tests.py @@ -2,6 +2,8 @@ import os, sys, subprocess, difflib +from scripts.support import run_command, split_wast + print '[ processing and updating testcases... ]\n' for asm in sorted(os.listdir('test')): @@ -19,7 +21,7 @@ for asm in sorted(os.listdir('test')): print '..', asm, wasm print ' ', ' '.join(cmd) actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() - open(os.path.join('test', wasm), 'w').write(actual) + with open(os.path.join('test', wasm), 'w') as o: o.write(actual) for dot_s_dir in ['dot_s', 'llvm_autogenerated']: for s in sorted(os.listdir(os.path.join('test', dot_s_dir))): @@ -35,7 +37,7 @@ for dot_s_dir in ['dot_s', 'llvm_autogenerated']: assert err == '', 'bad err:' + err expected_file = os.path.join('test', dot_s_dir, wasm) - open(expected_file, 'w').write(actual) + with open(expected_file, 'w') as o: o.write(actual) ''' for wasm in ['address.wast']:#os.listdir(os.path.join('test', 'spec')): @@ -54,24 +56,28 @@ for t in sorted(os.listdir(os.path.join('test', 'print'))): if t.endswith('.wast'): print '..', t wasm = os.path.basename(t).replace('.wast', '') - cmd = [os.path.join('bin', 'binaryen-shell'), os.path.join('test', 'print', t), '--print'] + cmd = [os.path.join('bin', 'wasm-shell'), os.path.join('test', 'print', t), '--print'] print ' ', ' '.join(cmd) actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() - open(os.path.join('test', 'print', wasm + '.txt'), 'w').write(actual) - cmd = [os.path.join('bin', 'binaryen-shell'), os.path.join('test', 'print', t), '--print-minified'] + with open(os.path.join('test', 'print', wasm + '.txt'), 'w') as o: o.write(actual) + cmd = [os.path.join('bin', 'wasm-shell'), os.path.join('test', 'print', t), '--print-minified'] print ' ', ' '.join(cmd) actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() - open(os.path.join('test', 'print', wasm + '.minified.txt'), 'w').write(actual) + with open(os.path.join('test', 'print', wasm + '.minified.txt'), 'w') as o: o.write(actual) for t in sorted(os.listdir(os.path.join('test', 'passes'))): if t.endswith('.wast'): print '..', t passname = os.path.basename(t).replace('.wast', '') opts = ['-O'] if passname == 'O' else ['--' + p for p in passname.split('_')] - cmd = [os.path.join('bin', 'binaryen-shell')] + opts + [os.path.join('test', 'passes', t), '--print'] - print ' ', ' '.join(cmd) - actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() - open(os.path.join('test', 'passes', passname + '.txt'), 'w').write(actual) + t = os.path.join('test', 'passes', t) + actual = '' + for module, asserts in split_wast(t): + assert len(asserts) == 0 + with open('split.wast', 'w') as o: o.write(module) + cmd = [os.path.join('bin', 'wasm-opt')] + opts + ['split.wast', '--print'] + actual += run_command(cmd) + with open(os.path.join('test', 'passes', passname + '.txt'), 'w') as o: o.write(actual) print '\n[ checking binary format testcases... ]\n' @@ -89,7 +95,7 @@ for wast in sorted(os.listdir('test')): subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) assert os.path.exists('a.wast') actual = open('a.wast').read() - open(os.path.join('test', wast + '.fromBinary'), 'w').write(actual) + with open(os.path.join('test', wast + '.fromBinary'), 'w') as o: o.write(actual) print '\n[ checking example testcases... ]\n' @@ -104,7 +110,7 @@ for t in sorted(os.listdir(os.path.join('test', 'example'))): continue print ' (will check trace in ', t, ')' src = 'trace.cpp' - open(src, 'w').write(out) + with open(src, 'w') as o: o.write(out) expected = os.path.join('test', 'example', t + '.txt') else: src = os.path.join('test', 'example', t) @@ -132,7 +138,7 @@ for t in sorted(os.listdir(os.path.join('test', 'example'))): proc = subprocess.Popen([output_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE) actual, err = proc.communicate() assert proc.returncode == 0, [proc.returncode, actual, err] - open(expected, 'w').write(actual) + with open(expected, 'w') as o: o.write(actual) finally: os.remove(output_file) if sys.platform == 'darwin': |