-
Notifications
You must be signed in to change notification settings - Fork 851
Get wasm2asm building again #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
279fdee
e358263
262b51d
d792ee1
662f376
891581b
b49dda4
899def2
5b85fd0
9fc9144
a072c3d
19bce00
9abb406
cb57f4f
e75d546
b803ad9
77434a0
281b6e0
c5ba2ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,7 +147,8 @@ def to_end(j): | |
| return ret | ||
|
|
||
|
|
||
| def run_command(cmd, expected_status=0, stderr=None, expected_err=None): | ||
| def run_command(cmd, expected_status=0, stderr=None, | ||
| expected_err=None, err_contains=False): | ||
| if expected_err is not None: | ||
| assert stderr == subprocess.PIPE or stderr is None,\ | ||
| "Can't redirect stderr if using expected_err" | ||
|
|
@@ -157,7 +158,9 @@ def run_command(cmd, expected_status=0, stderr=None, expected_err=None): | |
| out, err = proc.communicate() | ||
| if proc.returncode != expected_status: | ||
| raise Exception(('run_command failed', err)) | ||
| if expected_err is not None and err != expected_err: | ||
| err_correct = expected_err is None or \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need the new contained-but-not-equal mode? is equality too much for some test?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the MOZJS case in test_wasm2asm() cannot use equality because the error message contains timing information that is not test-independent.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need timing information? What is actually used there?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The full stderr of mozjs for successful test looks like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see. Yeah, that's hard to remove. Looks good then, maybe add a comment though to say why we just check for the subset (if there isn't one already). |
||
| (expected_err in err if err_contains else expected_err == err) | ||
| if not err_correct: | ||
| raise Exception(('run_command unexpected stderr', | ||
| "expected '%s', actual '%s'" % (expected_err, err))) | ||
| return out | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #!/usr/bin/env python2 | ||
|
|
||
| import os | ||
|
|
||
| from support import run_command | ||
| from shared import (WASM2ASM, MOZJS, NODEJS, fail_if_not_identical, tests) | ||
|
|
||
|
|
||
| def test_wasm2asm(): | ||
| print '\n[ checking wasm2asm testcases... ]\n' | ||
|
|
||
| # tests with i64s, invokes, etc. | ||
| blacklist = ['atomics.wast', 'address.wast'] | ||
| spec_tests = [os.path.join('spec', t) for t in | ||
| sorted(os.listdir(os.path.join('test', 'spec')))] | ||
| for wasm in tests + spec_tests: | ||
| if not wasm.endswith('.wast') or os.path.basename(wasm) in blacklist: | ||
| continue | ||
|
|
||
| asm = os.path.basename(wasm).replace('.wast', '.2asm.js') | ||
| expected_file = os.path.join('test', asm) | ||
| if not os.path.exists(expected_file): | ||
| continue | ||
|
|
||
| print '..', wasm | ||
|
|
||
| cmd = WASM2ASM + [os.path.join('test', wasm)] | ||
| out = run_command(cmd) | ||
|
|
||
| # verify output | ||
| expected = open(expected_file).read() | ||
| fail_if_not_identical(out, expected) | ||
|
|
||
| open('a.2asm.js', 'w').write(out) | ||
|
|
||
| if NODEJS: | ||
| # verify asm.js is valid js | ||
| out = run_command([NODEJS, 'a.2asm.js']) | ||
| fail_if_not_identical(out, '') | ||
|
|
||
| if MOZJS: | ||
| # verify asm.js validates | ||
| # check only subset of err because mozjs emits timing info | ||
| out = run_command([MOZJS, '-w', 'a.2asm.js'], | ||
| expected_err='Successfully compiled asm.js code', | ||
| err_contains=True) | ||
| fail_if_not_identical(out, '') | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_wasm2asm() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intentionally not enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since there aren't many tests right now anyway. I was planning to enable the tests in a future PR that would finish 32 bit support and add more tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.