Restore running precompiled modules with the CLI (#3343)
* Restore running precompiled modules with the CLI This was accidentally broken when `Module::deserialize` was split out of `Module::new` long ago, so this adds the detection in the CLI to call the appropriate method to load the module. This feature is gated behind an `--allow-precompiled` flag to enable, by default, passing arbitrary user input to the `wasmtime` command. Closes #3338 * Fix test on Windows
This commit is contained in:
@@ -2,7 +2,7 @@ use anyhow::{bail, Result};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::process::{Command, Output};
|
||||
use tempfile::NamedTempFile;
|
||||
use tempfile::{NamedTempFile, TempDir};
|
||||
|
||||
// Run the wasmtime CLI with the provided args and return the `Output`.
|
||||
fn run_wasmtime_for_output(args: &[&str]) -> Result<Output> {
|
||||
@@ -381,3 +381,19 @@ fn exit_with_saved_fprs() -> Result<()> {
|
||||
assert!(output.stdout.is_empty());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_cwasm() -> Result<()> {
|
||||
let td = TempDir::new()?;
|
||||
let cwasm = td.path().join("foo.cwasm");
|
||||
let stdout = run_wasmtime(&[
|
||||
"compile",
|
||||
"tests/all/cli_tests/simple.wat",
|
||||
"-o",
|
||||
cwasm.to_str().unwrap(),
|
||||
])?;
|
||||
assert_eq!(stdout, "");
|
||||
let stdout = run_wasmtime(&["run", "--allow-precompiled", cwasm.to_str().unwrap()])?;
|
||||
assert_eq!(stdout, "");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user