Skip to content

switch to tests to wast#7379

Merged
sokra merged 4 commits intowebpack:masterfrom
xtuc:refactor-use-wast-in-tests
May 25, 2018
Merged

switch to tests to wast#7379
sokra merged 4 commits intowebpack:masterfrom
xtuc:refactor-use-wast-in-tests

Conversation

@xtuc
Copy link
Copy Markdown
Member

@xtuc xtuc commented May 23, 2018

What kind of change does this PR introduce?

The issue is that currently we test against opaque wasm binary and doesn't help when debugging.

I only converted two tests for the demo. I'll continue if you agree.

Did you add tests for your changes?

Does this PR introduce a breaking change?

What needs to be documented once your changes are merged?

@webpack-bot
Copy link
Copy Markdown
Contributor

webpack-bot commented May 23, 2018

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

Comment thread lib/WebpackOptionsDefaulter.js Outdated
},
{
test: /\.wast$/i,
loader: "@webassemblyjs/wast-loader",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is wanted but I think it's a common use case to enable it by default?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using loaders by default comes with a lot of problems. I would keep it like other loaders.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the test suite move this into test/TestCases.template.js

Comment thread package.json Outdated
"@webassemblyjs/ast": "1.4.3",
"@webassemblyjs/wasm-edit": "1.4.3",
"@webassemblyjs/wasm-parser": "1.4.3",
"@webassemblyjs/wast-loader": "^1.5.4",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid duplicated deps (with other versions), we should align these, but it's already done by some PR i think.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in devDependencies instead

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if we move it from the default options

Copy link
Copy Markdown
Contributor

@ooflorent ooflorent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of supporting wast by default. This change looks good.

@xtuc xtuc changed the title switch to tests to wast [WIP] switch to tests to wast May 24, 2018
@xtuc
Copy link
Copy Markdown
Member Author

xtuc commented May 24, 2018

btw I have the wast-loader package now. I'm waiting your review @sokra to continue.

Comment thread lib/WebpackOptionsDefaulter.js Outdated
type: "webassembly/experimental"
},
{
test: /\.wast$/i,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recommended file extension for WebAssembly code in textual format is .wat.

https://webassembly.org/docs/text-format/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually wast (WebAssembly script format) and wat (text format) are two different syntaxes but i agree it's better to switch to .wat.

Comment thread lib/WebpackOptionsDefaulter.js Outdated
},
{
test: /\.wast$/i,
loader: "@webassemblyjs/wast-loader",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using loaders by default comes with a lot of problems. I would keep it like other loaders.

Comment thread test/cases/wasm/decoding/index.js Outdated
@@ -1,13 +1,13 @@
it("should support wasm compiled from c++", function() {
return import("./memory3.wasm").then(function(wasm) {
return import("./memory3.wast").then(function(wasm) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the decoding tests in wasm as they try to test special encodings of the wasm binary (like paddings). This is not possible with wast (wat)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other tests can be changed to .wat for better readability.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point yes

Comment thread package.json Outdated
"@webassemblyjs/ast": "1.4.3",
"@webassemblyjs/wasm-edit": "1.4.3",
"@webassemblyjs/wasm-parser": "1.4.3",
"@webassemblyjs/wast-loader": "^1.5.4",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in devDependencies instead

Comment thread lib/WebpackOptionsDefaulter.js Outdated
},
{
test: /\.wast$/i,
loader: "@webassemblyjs/wast-loader",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the test suite move this into test/TestCases.template.js

@webpack-bot
Copy link
Copy Markdown
Contributor

@xtuc Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@xtuc xtuc changed the title [WIP] switch to tests to wast switch to tests to wast May 24, 2018
@xtuc
Copy link
Copy Markdown
Member Author

xtuc commented May 24, 2018

I kept the LEB128 padded one to ensure we are parsing them, everything else has been changed to wast.

@sokra sokra closed this May 25, 2018
@sokra sokra reopened this May 25, 2018
@xtuc
Copy link
Copy Markdown
Member Author

xtuc commented May 25, 2018

As a side note, wabt's WASM to WAT adds a bit of latency, the test is probably failing because of that. Should we increase the timeout?

In the future we'll be able to do it with our own tools, which will be more efficient I think.

@webpack-bot
Copy link
Copy Markdown
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@sokra sokra closed this May 25, 2018
@sokra sokra reopened this May 25, 2018
@sokra sokra merged commit 4cd0cf5 into webpack:master May 25, 2018
@sokra
Copy link
Copy Markdown
Member

sokra commented May 25, 2018

Thanks

@xtuc xtuc deleted the refactor-use-wast-in-tests branch May 26, 2018 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants