Implement the allow-unknown-exports option for the run command.

This commit implements the `--allow-unknown-exports` option to the CLI run
command that will ignore unknown exports in a command module rather than
return an error.

Fixes #2587.
This commit is contained in:
Peter Huene
2021-05-06 14:19:14 -07:00
parent 6a1a169c62
commit 91f64d40d4
3 changed files with 53 additions and 1 deletions

View File

@@ -162,6 +162,24 @@ fn module_interposition() -> Result<()> {
Ok(())
}
#[test]
fn allow_unknown_exports() -> Result<()> {
let store = Store::default();
let mut linker = Linker::new(&store);
let module = Module::new(
store.engine(),
r#"(module (func (export "_start")) (global (export "g") i32 (i32.const 0)))"#,
)?;
assert!(linker.module("module", &module).is_err());
let mut linker = Linker::new(&store);
linker.allow_unknown_exports(true);
linker.module("module", &module)?;
Ok(())
}
#[test]
fn no_leak() -> Result<()> {
struct DropMe(Rc<Cell<bool>>);