|
20 | 20 | import sys |
21 | 21 | import unittest |
22 | 22 |
|
23 | | -from scripts.test.support import run_command, split_wast, node_test_glue, node_has_webassembly |
| 23 | +from scripts.test.support import run_command, split_wast |
24 | 24 | from scripts.test.shared import ( |
25 | | - BIN_DIR, MOZJS, NATIVECC, NATIVEXX, NODEJS, BINARYEN_JS, WASM_AS, |
| 25 | + BIN_DIR, NATIVECC, NATIVEXX, NODEJS, WASM_AS, |
26 | 26 | WASM_CTOR_EVAL, WASM_OPT, WASM_SHELL, WASM_METADCE, WASM_DIS, WASM_REDUCE, |
27 | 27 | binary_format_check, delete_from_orbit, fail, fail_with_error, |
28 | 28 | fail_if_not_identical, fail_if_not_contained, has_vanilla_emcc, |
|
36 | 36 | from scripts.test import asm2wasm |
37 | 37 | from scripts.test import lld |
38 | 38 | from scripts.test import wasm2js |
| 39 | +from scripts.test import binaryenjs |
39 | 40 |
|
40 | 41 | if options.interpreter: |
41 | 42 | print '[ using wasm interpreter at "%s" ]' % options.interpreter |
@@ -387,58 +388,6 @@ def fix_actual(x): |
387 | 388 | check_expected(actual, os.path.join(options.binaryen_test, 'spec', 'expected-output', os.path.basename(wast) + '.log')) |
388 | 389 |
|
389 | 390 |
|
390 | | -def run_binaryen_js_tests(): |
391 | | - if not (MOZJS or NODEJS): |
392 | | - print 'no vm to run binaryen.js tests' |
393 | | - return |
394 | | - |
395 | | - node_has_wasm = NODEJS and node_has_webassembly(NODEJS) |
396 | | - |
397 | | - if not os.path.exists(BINARYEN_JS): |
398 | | - print 'no binaryen.js build to test' |
399 | | - return |
400 | | - |
401 | | - print '\n[ checking binaryen.js testcases... ]\n' |
402 | | - |
403 | | - for s in sorted(os.listdir(os.path.join(options.binaryen_test, 'binaryen.js'))): |
404 | | - if not s.endswith('.js'): |
405 | | - continue |
406 | | - print s |
407 | | - f = open('a.js', 'w') |
408 | | - # avoid stdout/stderr ordering issues in some js shells - use just stdout |
409 | | - f.write(''' |
410 | | - console.warn = function(x) { console.log(x) }; |
411 | | - ''') |
412 | | - binaryen_js = open(BINARYEN_JS).read() |
413 | | - f.write(binaryen_js) |
414 | | - if NODEJS: |
415 | | - f.write(node_test_glue()) |
416 | | - test_path = os.path.join(options.binaryen_test, 'binaryen.js', s) |
417 | | - test_src = open(test_path).read() |
418 | | - f.write(test_src) |
419 | | - f.close() |
420 | | - |
421 | | - def test(engine): |
422 | | - cmd = [engine, 'a.js'] |
423 | | - if 'fatal' not in s: |
424 | | - out = run_command(cmd, stderr=subprocess.STDOUT) |
425 | | - else: |
426 | | - # expect an error - the specific error code will depend on the vm |
427 | | - out = run_command(cmd, stderr=subprocess.STDOUT, expected_status=None) |
428 | | - expected = open(os.path.join(options.binaryen_test, 'binaryen.js', s + '.txt')).read() |
429 | | - if expected not in out: |
430 | | - fail(out, expected) |
431 | | - |
432 | | - # run in all possible shells |
433 | | - if MOZJS: |
434 | | - test(MOZJS) |
435 | | - if NODEJS: |
436 | | - if node_has_wasm or 'WebAssembly.' not in test_src: |
437 | | - test(NODEJS) |
438 | | - else: |
439 | | - print 'Skipping ' + test_path + ' because WebAssembly might not be supported' |
440 | | - |
441 | | - |
442 | 391 | def run_validator_tests(): |
443 | 392 | print '\n[ running validation tests... ]\n' |
444 | 393 | # Ensure the tests validate by default |
@@ -579,7 +528,7 @@ def main(): |
579 | 528 | run_wasm_reduce_tests() |
580 | 529 |
|
581 | 530 | run_spec_tests() |
582 | | - run_binaryen_js_tests() |
| 531 | + binaryenjs.test_binaryen_js() |
583 | 532 | lld.test_wasm_emscripten_finalize() |
584 | 533 | wasm2js.test_wasm2js() |
585 | 534 | run_validator_tests() |
|
0 commit comments