Skip to content

Commit eb3837b

Browse files
committed
Fix exit-status tests on Windows.
1 parent 55cf462 commit eb3837b

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/commands/run.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ impl RunCommand {
146146
// a message and exit.
147147
if let Some(exit) = e.downcast_ref::<Exit>() {
148148
eprintln!("Error: {}", exit);
149-
if cfg!(unix) {
150-
// On Unix, if it's a normal exit status, return it.
151-
process::exit(exit.status().get());
149+
// On Windows, exit status 3 indicates an abort (see below),
150+
// so just return 1 indicating a non-zero status.
151+
if cfg!(windows) {
152+
process::exit(1);
152153
}
153-
process::exit(1);
154+
process::exit(exit.status().get());
154155
}
155156

156157
// If the program exited because of a trap, return an error code

tests/all/cli_tests.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ fn timeout_in_invoke() -> Result<()> {
189189
fn exit125_wasi_snapshot0() -> Result<()> {
190190
let wasm = build_wasm("tests/wasm/exit125_wasi_snapshot0.wat")?;
191191
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
192-
assert_eq!(output.status.code().unwrap(), 125);
192+
if cfg!(windows) {
193+
assert_eq!(output.status.code().unwrap(), 1);
194+
} else {
195+
assert_eq!(output.status.code().unwrap(), 125);
196+
}
193197
Ok(())
194198
}
195199

@@ -198,7 +202,11 @@ fn exit125_wasi_snapshot0() -> Result<()> {
198202
fn exit125_wasi_snapshot1() -> Result<()> {
199203
let wasm = build_wasm("tests/wasm/exit125_wasi_snapshot1.wat")?;
200204
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
201-
assert_eq!(output.status.code().unwrap(), 125);
205+
if cfg!(windows) {
206+
assert_eq!(output.status.code().unwrap(), 1);
207+
} else {
208+
assert_eq!(output.status.code().unwrap(), 125);
209+
}
202210
Ok(())
203211
}
204212

0 commit comments

Comments
 (0)