summaryrefslogtreecommitdiff
path: root/scripts/test/binaryenjs.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/test/binaryenjs.py')
-rwxr-xr-xscripts/test/binaryenjs.py88
1 files changed, 44 insertions, 44 deletions
diff --git a/scripts/test/binaryenjs.py b/scripts/test/binaryenjs.py
index f701f25c1..a102c2ae4 100755
--- a/scripts/test/binaryenjs.py
+++ b/scripts/test/binaryenjs.py
@@ -22,56 +22,56 @@ from .shared import BINARYEN_JS, MOZJS, NODEJS, options, fail
def test_binaryen_js():
- if not (MOZJS or NODEJS):
- print('no vm to run binaryen.js tests')
- return
+ if not (MOZJS or NODEJS):
+ print('no vm to run binaryen.js tests')
+ return
- node_has_wasm = NODEJS and node_has_webassembly(NODEJS)
+ node_has_wasm = NODEJS and node_has_webassembly(NODEJS)
- if not os.path.exists(BINARYEN_JS):
- print('no binaryen.js build to test')
- return
+ if not os.path.exists(BINARYEN_JS):
+ print('no binaryen.js build to test')
+ return
- print('\n[ checking binaryen.js testcases... ]\n')
+ print('\n[ checking binaryen.js testcases... ]\n')
- for s in sorted(os.listdir(os.path.join(options.binaryen_test, 'binaryen.js'))):
- if not s.endswith('.js'):
- continue
- print(s)
- f = open('a.js', 'w')
- # avoid stdout/stderr ordering issues in some js shells - use just stdout
- f.write('''
- console.warn = function(x) { console.log(x) };
- ''')
- binaryen_js = open(BINARYEN_JS).read()
- f.write(binaryen_js)
- if NODEJS:
- f.write(node_test_glue())
- test_path = os.path.join(options.binaryen_test, 'binaryen.js', s)
- test_src = open(test_path).read()
- f.write(test_src)
- f.close()
+ for s in sorted(os.listdir(os.path.join(options.binaryen_test, 'binaryen.js'))):
+ if not s.endswith('.js'):
+ continue
+ print(s)
+ f = open('a.js', 'w')
+ # avoid stdout/stderr ordering issues in some js shells - use just stdout
+ f.write('''
+ console.warn = function(x) { console.log(x) };
+ ''')
+ binaryen_js = open(BINARYEN_JS).read()
+ f.write(binaryen_js)
+ if NODEJS:
+ f.write(node_test_glue())
+ test_path = os.path.join(options.binaryen_test, 'binaryen.js', s)
+ test_src = open(test_path).read()
+ f.write(test_src)
+ f.close()
- def test(engine):
- cmd = [engine, 'a.js']
- if 'fatal' not in s:
- out = run_command(cmd, stderr=subprocess.STDOUT)
- else:
- # expect an error - the specific error code will depend on the vm
- out = run_command(cmd, stderr=subprocess.STDOUT, expected_status=None)
- expected = open(os.path.join(options.binaryen_test, 'binaryen.js', s + '.txt')).read()
- if expected not in out:
- fail(out, expected)
+ def test(engine):
+ cmd = [engine, 'a.js']
+ if 'fatal' not in s:
+ out = run_command(cmd, stderr=subprocess.STDOUT)
+ else:
+ # expect an error - the specific error code will depend on the vm
+ out = run_command(cmd, stderr=subprocess.STDOUT, expected_status=None)
+ expected = open(os.path.join(options.binaryen_test, 'binaryen.js', s + '.txt')).read()
+ if expected not in out:
+ fail(out, expected)
- # run in all possible shells
- if MOZJS:
- test(MOZJS)
- if NODEJS:
- if node_has_wasm or 'WebAssembly.' not in test_src:
- test(NODEJS)
- else:
- print('Skipping ' + test_path + ' because WebAssembly might not be supported')
+ # run in all possible shells
+ if MOZJS:
+ test(MOZJS)
+ if NODEJS:
+ if node_has_wasm or 'WebAssembly.' not in test_src:
+ test(NODEJS)
+ else:
+ print('Skipping ' + test_path + ' because WebAssembly might not be supported')
if __name__ == "__main__":
- test_binaryen_js()
+ test_binaryen_js()