-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2290: Handle Wasm modules with no imports in the CLI r=MarkMcCaskey a=MarkMcCaskey Resolves #2282 Co-authored-by: Mark McCaskey <[email protected]>
- Loading branch information
Showing
7 changed files
with
107 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! Basic tests for the `run` subcommand | ||
use anyhow::bail; | ||
use std::process::Command; | ||
use wasmer_integration_tests_cli::{ASSET_PATH, C_ASSET_PATH, WASMER_PATH}; | ||
|
||
fn wasi_test_wasm_path() -> String { | ||
format!("{}/{}", C_ASSET_PATH, "qjs.wasm") | ||
} | ||
|
||
fn test_no_imports_wat_path() -> String { | ||
format!("{}/{}", ASSET_PATH, "fib.wat") | ||
} | ||
|
||
#[test] | ||
fn run_wasi_works() -> anyhow::Result<()> { | ||
let output = Command::new(WASMER_PATH) | ||
.arg("run") | ||
.arg(wasi_test_wasm_path()) | ||
.arg("--") | ||
.arg("-e") | ||
.arg("print(3 * (4 + 5))") | ||
.output()?; | ||
|
||
if !output.status.success() { | ||
bail!( | ||
"linking failed with: stdout: {}\n\nstderr: {}", | ||
std::str::from_utf8(&output.stdout) | ||
.expect("stdout is not utf8! need to handle arbitrary bytes"), | ||
std::str::from_utf8(&output.stderr) | ||
.expect("stderr is not utf8! need to handle arbitrary bytes") | ||
); | ||
} | ||
|
||
let stdout_output = std::str::from_utf8(&output.stdout).unwrap(); | ||
assert_eq!(stdout_output, "27\n"); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn run_no_imports_wasm_works() -> anyhow::Result<()> { | ||
let output = Command::new(WASMER_PATH) | ||
.arg("run") | ||
.arg(test_no_imports_wat_path()) | ||
.output()?; | ||
|
||
if !output.status.success() { | ||
bail!( | ||
"linking failed with: stdout: {}\n\nstderr: {}", | ||
std::str::from_utf8(&output.stdout) | ||
.expect("stdout is not utf8! need to handle arbitrary bytes"), | ||
std::str::from_utf8(&output.stderr) | ||
.expect("stderr is not utf8! need to handle arbitrary bytes") | ||
); | ||
} | ||
|
||
Ok(()) | ||
} |