mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-24 02:01:35 +00:00
Add test for consuming interface types inputs (#1900)
This commit adds a test suite for consuming interface types modules as input and producing a JS polyfill output. The tests are relatively simple today and don't exercise a ton of functionality, but they should hopefully cover the breadth of at least some basics of what wasm interface types supports today. A few small fixes were applied along the way, such as: * Don't require modules to have a stack pointer * Allow passing `*.wat`, `*.wit`, or `*.wasm` files as input to `wasm-bindgen` instead of always requiring `*.wasm`.
This commit is contained in:
@ -12,17 +12,19 @@ Shared support for the wasm-bindgen-cli package, an internal dependency
|
||||
edition = '2018'
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.9"
|
||||
anyhow = "1.0"
|
||||
base64 = "0.9"
|
||||
log = "0.4"
|
||||
rustc-demangle = "0.1.13"
|
||||
serde_json = "1.0"
|
||||
tempfile = "3.0"
|
||||
walrus = "0.14.0"
|
||||
wasm-bindgen-anyref-xform = { path = '../anyref-xform', version = '=0.2.55' }
|
||||
wasm-bindgen-shared = { path = "../shared", version = '=0.2.55' }
|
||||
wasm-bindgen-multi-value-xform = { path = '../multi-value-xform', version = '=0.2.55' }
|
||||
wasm-bindgen-shared = { path = "../shared", version = '=0.2.55' }
|
||||
wasm-bindgen-threads-xform = { path = '../threads-xform', version = '=0.2.55' }
|
||||
wasm-bindgen-wasm-conventions = { path = '../wasm-conventions', version = '=0.2.55' }
|
||||
wasm-bindgen-wasm-interpreter = { path = "../wasm-interpreter", version = '=0.2.55' }
|
||||
wit-text = "0.1.1"
|
||||
wit-walrus = "0.1.0"
|
||||
wit-validator = "0.1.0"
|
||||
|
@ -264,8 +264,10 @@ impl Bindgen {
|
||||
(mem::replace(m, blank_module), &name[..])
|
||||
}
|
||||
Input::Path(ref path) => {
|
||||
let contents = fs::read(&path)
|
||||
let wasm = wit_text::parse_file(&path)
|
||||
.with_context(|| format!("failed to read `{}`", path.display()))?;
|
||||
wit_validator::validate(&wasm)
|
||||
.with_context(|| format!("failed to validate `{}`", path.display()))?;
|
||||
let module = walrus::ModuleConfig::new()
|
||||
// Skip validation of the module as LLVM's output is
|
||||
// generally already well-formed and so we won't gain much
|
||||
@ -278,7 +280,7 @@ impl Bindgen {
|
||||
.generate_name_section(!self.remove_name_section)
|
||||
.generate_producers_section(!self.remove_producers_section)
|
||||
.on_parse(wit_walrus::on_parse)
|
||||
.parse(&contents)
|
||||
.parse(&wasm)
|
||||
.context("failed to parse input file as wasm")?;
|
||||
let stem = match &self.out_name {
|
||||
Some(name) => &name,
|
||||
|
@ -92,8 +92,8 @@ pub fn process(
|
||||
|
||||
impl<'a> Context<'a> {
|
||||
fn init(&mut self) -> Result<(), Error> {
|
||||
let stack_pointer = wasm_bindgen_wasm_conventions::get_shadow_stack_pointer(self.module)?;
|
||||
self.aux.shadow_stack_pointer = Some(stack_pointer);
|
||||
self.aux.shadow_stack_pointer =
|
||||
wasm_bindgen_wasm_conventions::get_shadow_stack_pointer(self.module);
|
||||
|
||||
// Make a map from string name to ids of all exports
|
||||
for export in self.module.exports.iter() {
|
||||
|
Reference in New Issue
Block a user