Implement conversion of test scripts to JavaScript #337
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now that the interpreter is almost 0xc-complete, this should come in handy.
This patch extends the script language with a couple of meta facilities. The first is quoting of scripts (by wrapping them into
(script <name>? ...)
); this binds a script in the same way a module def binds a module. The second is the extension of theoutput
command to.js
target files, which converts the referenced script to an equivalent JS runner.More importantly, you can access these facilities with simple command line switches. For example,
will convert a test script to self-contained JavaScript, with all Wasm modules embedded as binary strings.
Caveat: All
invoke
's currently become calls directly from JavaScript, no module wrappers. Thus tests involving i64 params/results do not work yet. Will be addressed in a follow-up.[Edit]
Extended to also support converting whole scripts to modified
.wast
files:When the output file extension is
.bin.wast
, then all embedded modules are represented as binary strings, otherwise textual. The only exception are modules in a newly introducedassert_malformed
command, which retain their original format, since cross-coding is meaningless in that case.The test runner is updated to use this functionality.