Add tests for the interface types output of wasm-bindgen #1898
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.
This commit expands the test suite with assertions about the output of
the interface types pass in wasm-bindgen. The goal here is to actually
assert that we produce the right output and have a suite of reference
files to show how the interface types output is changing over time.
The
reference
test suite added in the previous PR has been updated towork for interface types as well, generating
*.wit
file assertionswhich are printed via the
wit-printer
crate on crates.io.Along the way a number of bugs were fixed with the interface types
output, such as:
Non-determinism in output caused by iteration of a
HashMap
Avoiding JS generation entirely in interface types mode, ensuring that
we don't export extraneous intrinsics that aren't otherwise needed.
Fixing location of the stack pointer for modules where it's GC'd out.
It's now rooted in the aux section of wasm-bindgen so it's available
to later passes, like the multi-value pass.
Interface types emission now works in debug mode, meaning the
--release
flag is no longer required. This previously did not workbecause the
__wbindgen_throw
intrinsic was required in debug mode.This comes about because of the
malloc_failure
andinternal_error
functions in the anyref pass. The purpose of these functions is to
signal fatal runtime errors, if any, in a way that's usable to the
user. For wasm interface types though we can replace calls to these
functions with
unreachable
to avoid needing to import theintrinsic. This has the accidental side effect of making
wasm_bindgen::throw_str
"just work" with wasm interface types byaborting the program, but that's not actually entirely intended. It's
hoped that a split of a
wasm-bindgen-core
crate would solve thisissue for the future.