summaryrefslogtreecommitdiff
path: root/auto_update_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'auto_update_tests.py')
-rwxr-xr-xauto_update_tests.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py
index 3b6c9bf24..75396655e 100755
--- a/auto_update_tests.py
+++ b/auto_update_tests.py
@@ -21,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))):
@@ -37,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')):
@@ -59,11 +59,11 @@ for t in sorted(os.listdir(os.path.join('test', '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)
+ 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'):
@@ -74,10 +74,10 @@ for t in sorted(os.listdir(os.path.join('test', 'passes'))):
actual = ''
for module, asserts in split_wast(t):
assert len(asserts) == 0
- open('split.wast', 'w').write(module)
+ 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)
- open(os.path.join('test', 'passes', passname + '.txt'), 'w').write(actual)
+ with open(os.path.join('test', 'passes', passname + '.txt'), 'w') as o: o.write(actual)
print '\n[ checking binary format testcases... ]\n'
@@ -95,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'
@@ -110,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)
@@ -138,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':