Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for libtest panic=abort mode
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// no-prefer-dynamic | ||
// compile-flags: --test -Cpanic=abort | ||
// run-flags: --test-threads=1 | ||
// run-fail | ||
// check-run-results | ||
|
||
// ignore-wasm no panic or subprocess support | ||
// ignore-emscripten no panic or subprocess support | ||
|
||
#![cfg(test)] | ||
|
||
use std::io::Write; | ||
|
||
#[test] | ||
fn it_works() { | ||
assert_eq!(1 + 1, 2); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn it_panics() { | ||
assert_eq!(1 + 1, 4); | ||
} | ||
|
||
#[test] | ||
fn it_fails() { | ||
println!("hello, world"); | ||
writeln!(std::io::stdout(), "testing123").unwrap(); | ||
writeln!(std::io::stderr(), "testing321").unwrap(); | ||
assert_eq!(1 + 1, 5); | ||
} | ||
|
||
#[test] | ||
fn it_exits() { | ||
std::process::exit(123); | ||
} |
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,29 @@ | ||
|
||
running 4 tests | ||
test it_exits ... FAILED | ||
test it_fails ... FAILED | ||
test it_panics ... ok | ||
test it_works ... ok | ||
|
||
failures: | ||
|
||
---- it_exits stdout ---- | ||
---- it_exits stderr ---- | ||
note: got unexpected return code 123 | ||
---- it_fails stdout ---- | ||
hello, world | ||
testing123 | ||
---- it_fails stderr ---- | ||
testing321 | ||
thread 'main' panicked at 'assertion failed: `(left == right)` | ||
left: `2`, | ||
right: `5`', $DIR/test-panic-abort.rs:30:5 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. | ||
|
||
|
||
failures: | ||
it_exits | ||
it_fails | ||
|
||
test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out | ||
|