Skip to content

Commit

Permalink
Add test for libtest panic=abort mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tmandry committed Sep 28, 2019
1 parent 8ae1ec6 commit 8837684
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/test/ui/test-panic-abort.rs
@@ -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 changes: 29 additions & 0 deletions src/test/ui/test-panic-abort.run.stdout
@@ -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

0 comments on commit 8837684

Please sign in to comment.