Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exit-status tests on Windows.
Browse files Browse the repository at this point in the history
sunfishcode committed May 1, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 55cf462 commit eb3837b
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
@@ -146,11 +146,12 @@ impl RunCommand {
// a message and exit.
if let Some(exit) = e.downcast_ref::<Exit>() {
eprintln!("Error: {}", exit);
if cfg!(unix) {
// On Unix, if it's a normal exit status, return it.
process::exit(exit.status().get());
// On Windows, exit status 3 indicates an abort (see below),
// so just return 1 indicating a non-zero status.
if cfg!(windows) {
process::exit(1);
}
process::exit(1);
process::exit(exit.status().get());
}

// If the program exited because of a trap, return an error code
12 changes: 10 additions & 2 deletions tests/all/cli_tests.rs
Original file line number Diff line number Diff line change
@@ -189,7 +189,11 @@ fn timeout_in_invoke() -> Result<()> {
fn exit125_wasi_snapshot0() -> Result<()> {
let wasm = build_wasm("tests/wasm/exit125_wasi_snapshot0.wat")?;
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
assert_eq!(output.status.code().unwrap(), 125);
if cfg!(windows) {
assert_eq!(output.status.code().unwrap(), 1);
} else {
assert_eq!(output.status.code().unwrap(), 125);
}
Ok(())
}

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

0 comments on commit eb3837b

Please sign in to comment.