diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-10-29 16:24:29 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-10-29 16:24:29 -0700 |
commit | 38b9478a1572af74b0aa7e45810fd5c7c4e27329 (patch) | |
tree | e2011c2c1d09f148ec3f569159456e893d723717 | |
parent | a25d742c05732e9168494b434e15889352e3ee60 (diff) | |
download | binaryen-38b9478a1572af74b0aa7e45810fd5c7c4e27329.tar.gz binaryen-38b9478a1572af74b0aa7e45810fd5c7c4e27329.tar.bz2 binaryen-38b9478a1572af74b0aa7e45810fd5c7c4e27329.zip |
improve check.py
-rw-r--r-- | README.md | 9 | ||||
-rwxr-xr-x | check.py | 24 |
2 files changed, 31 insertions, 2 deletions
@@ -73,6 +73,15 @@ That will emit `a.html`, `a.js`, and `a.asm.js`. That last file is the asm.js mo (or `python check.py`) will run `asm2wasm` on the testcases in `test/`, and verify their outputs. +The `check.py` script supports some options: + +``` +./check.py [--interpreter=/path/to/interpreter] [TEST1] [TEST2].. +``` + + * If an interpreter is provided, we run the output through it, checking for parse errors. + * If tests are provided, we run exactly those. If none are provided, we run them all. + ## License & Contributing Same as Emscripten: MIT license. @@ -1,15 +1,34 @@ #!/usr/bin/env python -import os, subprocess, difflib +import os, sys, subprocess, difflib + +interpreter = None +tests = [] + +for arg in sys.argv[1:]: + if arg.startswith('--interpreter='): + interpreter = arg.split('=')[1] + print '[ using wasm interpreter at "%s" ]' % interpreter + assert os.path.exists(interpreter), 'interpreter not found' + else: + tests.append(arg) + +if not interpreter: + print '[ no wasm interpreter provided, you should pass one as --interpreter=path/to/interpreter ]' print '[ checking testcases... ]\n' -for asm in sorted(os.listdir('test')): +if len(tests) == 0: + tests = sorted(os.listdir('test')) + +for asm in tests: if asm.endswith('.asm.js'): print ' ', asm, ' ', wasm = asm.replace('.asm.js', '.wast') actual, err = subprocess.Popen([os.path.join('bin', 'asm2wasm'), os.path.join('test', asm)], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() assert err == '', 'bad err:' + err + # verify in wasm + # verify output if not os.path.exists(os.path.join('test', wasm)): print actual raise Exception('output .wast file does not exist') @@ -22,3 +41,4 @@ for asm in sorted(os.listdir('test')): print 'OK' print '\n[ success! ]' + |