Skip to content

Commit

Permalink
Add cli_exit_with_code test
Browse files Browse the repository at this point in the history
  • Loading branch information
badeend committed Oct 6, 2024
1 parent 2f48c77 commit 4fcfe6f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/test-programs/src/bin/cli_exit_with_code.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use test_programs::wasi::cli::exit::exit_with_code;

fn main() {
exit_with_code(42);
}
1 change: 1 addition & 0 deletions crates/test-programs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ wit_bindgen::generate!({
"../wasi-keyvalue/wit",
],
world: "wasmtime:test/test",
features: ["cli-exit-with-code"],
generate_all,
});

Expand Down
10 changes: 10 additions & 0 deletions tests/all/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,16 @@ mod test_programs {
Ok(())
}

#[test]
fn cli_exit_with_code() -> Result<()> {
let output = get_wasmtime_command()?
.args(&["run", "-Wcomponent-model", "-Scli-exit-with-code", CLI_EXIT_WITH_CODE_COMPONENT])
.output()?;
assert!(!output.status.success());
assert_eq!(output.status.code(), Some(42));
Ok(())
}

#[test]
fn cli_exit_panic() -> Result<()> {
let output = get_wasmtime_command()?
Expand Down

0 comments on commit 4fcfe6f

Please sign in to comment.