diff --git a/crates/test-programs/src/bin/cli_exit_with_code.rs b/crates/test-programs/src/bin/cli_exit_with_code.rs new file mode 100644 index 000000000000..97b6024ccb2b --- /dev/null +++ b/crates/test-programs/src/bin/cli_exit_with_code.rs @@ -0,0 +1,5 @@ +use test_programs::wasi::cli::exit::exit_with_code; + +fn main() { + exit_with_code(42); +} diff --git a/crates/test-programs/src/lib.rs b/crates/test-programs/src/lib.rs index f7931273db84..bcb00225af25 100644 --- a/crates/test-programs/src/lib.rs +++ b/crates/test-programs/src/lib.rs @@ -20,6 +20,7 @@ wit_bindgen::generate!({ "../wasi-keyvalue/wit", ], world: "wasmtime:test/test", + features: ["cli-exit-with-code"], generate_all, }); diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs index 797fe4c64e60..e05ff1b5ca88 100644 --- a/tests/all/cli_tests.rs +++ b/tests/all/cli_tests.rs @@ -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()?