-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
test: Add basic WebAssembly test #16760
Conversation
cd894c3
to
f8bc445
Compare
ci: https://ci.nodejs.org/job/node-test-pull-request/11194/ /cc @nodejs/tsc what is the best practice for the licensing on this one? the WASM is generated from WAT code that came from an APACHE 2.0 project... we could potentially just write some new code for this but the base function is fairly straight forward. |
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.
Thank you!
test/parallel/test-wasm-simple.js
Outdated
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly'); | ||
|
||
WebAssembly.instantiate(buffer, {}).then((results) => { | ||
assert.equal(results.instance.exports.addTwo(10, 20), 30, 'Exported function should add two numbers.'); |
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.
Does this pass make lint
? I think we have a rule against assert.equal
(in favour of assert.strictEqual
)
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.
updated to fix lint
f8bc445
to
9538932
Compare
Isn't this just testing a strictly V8 feature? Wouldn't it be best to leave this to the V8 test suite? |
@mscdex It will also be testing |
test/parallel/test-wasm-simple.js
Outdated
const fixtures = require('../common/fixtures'); | ||
const fs = require('fs'); | ||
|
||
const buffer = fs.readFileSync(fixtures.path('simple.wasm')); |
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.
fixtures.readSync('simple.wasm')
and then drop the fs
module from the test?
9538932
to
70ab5a2
Compare
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/master/demo/wat2wasm/examples.js#L27-L32
70ab5a2
to
71036dd
Compare
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.
LGTM
|
||
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly'); | ||
|
||
WebAssembly.instantiate(buffer, {}).then((results) => { |
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.
Nit: common.mustCall
around the then
would be better.
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.
oh, right … we might also want common.crashOnUnhandledRejection()
to make sure it really crashes when the promise gets rejected
edit: this test might be trickier than first thought 😄
assert.strictEqual( | ||
results.instance.exports.addTwo(10, 20), | ||
30, | ||
'Exported function should add two numbers.', |
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.
Suggestion: it would likely be better to either omit the message here or include the expected
and actual
values in the message.
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.
is this worth blocking on or should we land and fix in a follow up?
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.
yea, we should just land this
Landed in 74e7a4a, thanks for the PR & congratulations to being a Node contributor now! 🎉 |
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/49b7984544ddaf14d5e2f1ad9115dad7e9a2b299/demo/wat2wasm/examples.js#L27-L32 PR-URL: #16760 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/49b7984544ddaf14d5e2f1ad9115dad7e9a2b299/demo/wat2wasm/examples.js#L27-L32 PR-URL: #16760 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/49b7984544ddaf14d5e2f1ad9115dad7e9a2b299/demo/wat2wasm/examples.js#L27-L32 PR-URL: #16760 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Tests a basic WebAssembly module that adds two numbers. wasm example from the WebAssembly/wabt repo licensed Apache 2.0. Refs: https://github.com/WebAssembly/wabt/blob/49b7984544ddaf14d5e2f1ad9115dad7e9a2b299/demo/wat2wasm/examples.js#L27-L32 PR-URL: #16760 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Tests a basic WebAssembly module that adds two numbers.
wasm example from the WebAssembly/wabt repo licensed Apache 2.0.
Not sure if there are licensing concerns. Please let me know if we need to add anything else.
Refs: https://github.com/WebAssembly/wabt/blob/master/demo/wat2wasm/examples.js#L27-L32
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test