Add test for libtest panic=abort mode
This commit is contained in:
parent
8ae1ec60cc
commit
88376842a0
2 changed files with 65 additions and 0 deletions
36
src/test/ui/test-panic-abort.rs
Normal file
36
src/test/ui/test-panic-abort.rs
Normal file
|
@ -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);
|
||||
}
|
29
src/test/ui/test-panic-abort.run.stdout
Normal file
29
src/test/ui/test-panic-abort.run.stdout
Normal file
|
@ -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
|
||||
|
Loading…
Reference in a new issue