diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-13 18:44:38 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-13 18:44:38 -0800 |
commit | 2d141917e87e73e2853cbf2538e7ccacc6095041 (patch) | |
tree | ecafeac7d3ff4e94b0ccca37f84c987a01730a5e /check.py | |
parent | 97b943c832dd3389b81c0896826977e0c447de28 (diff) | |
download | binaryen-2d141917e87e73e2853cbf2538e7ccacc6095041.tar.gz binaryen-2d141917e87e73e2853cbf2538e7ccacc6095041.tar.bz2 binaryen-2d141917e87e73e2853cbf2538e7ccacc6095041.zip |
add shell tests
Diffstat (limited to 'check.py')
-rwxr-xr-x | check.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -18,6 +18,14 @@ def fail(actual, expected): ''.join([a.rstrip()+'\n' for a in difflib.unified_diff(expected.split('\n'), actual.split('\n'), fromfile='expected', tofile='actual')]) )) +def fail_if_not_identical(actual, expected): + if expected != actual: + fail(actual, expected) + +def fail_if_not_contained(actual, expected): + if expected not in actual: + fail(actual, expected) + if not interpreter: print '[ no wasm interpreter provided, you should pass one as --interpreter=path/to/interpreter ]' @@ -64,6 +72,18 @@ for asm in tests: raise Exception('wasm interpreter error: ' + err) # failed to pretty-print raise Exception('wasm interpreter error') +print '\n[ checking binaryen-shell... ]\n' + +actual, err = subprocess.Popen([os.path.join('bin', 'binaryen-shell'), '--help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() +fail_if_not_contained(actual, 'binaryen shell') +fail_if_not_contained(actual, 'options:') +fail_if_not_contained(actual, 'passes:') +fail_if_not_contained(actual, ' -lower-if-else') + +print ' '.join([os.path.join('bin', 'binaryen-shell'), '-print-before', '-print-after', '-lower-if-else', os.path.join('test', 'if_else.wast')]) +actual, err = subprocess.Popen([os.path.join('bin', 'binaryen-shell'), '-print-before', '-print-after', '-lower-if-else', os.path.join('test', 'if_else.wast')], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() +fail_if_not_identical(actual, open(os.path.join('test', 'if_else.txt')).read()) + print '\n[ checking binaryen-shell testcases... ]\n' for t in tests: |