diff options
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/panic-runtime/libtest-unwinds.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/panic-runtime/libtest-unwinds.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/test-panic-abort-disabled.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/test-panic-abort-disabled.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/test-panic-abort.rs | 36 | ||||
| -rw-r--r-- | src/test/ui/test-panic-abort.run.stdout | 29 |
6 files changed, 89 insertions, 14 deletions
diff --git a/src/test/ui/panic-runtime/libtest-unwinds.rs b/src/test/ui/panic-runtime/libtest-unwinds.rs deleted file mode 100644 index bc13072612a..00000000000 --- a/src/test/ui/panic-runtime/libtest-unwinds.rs +++ /dev/null @@ -1,10 +0,0 @@ -// error-pattern:is not compiled with this crate's panic strategy `abort` -// compile-flags:-C panic=abort -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(test)] - -extern crate test; - -fn main() { -} diff --git a/src/test/ui/panic-runtime/libtest-unwinds.stderr b/src/test/ui/panic-runtime/libtest-unwinds.stderr deleted file mode 100644 index 704b81ae1ce..00000000000 --- a/src/test/ui/panic-runtime/libtest-unwinds.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: the linked panic runtime `panic_unwind` is not compiled with this crate's panic strategy `abort` - -error: aborting due to previous error - diff --git a/src/test/ui/test-panic-abort-disabled.rs b/src/test/ui/test-panic-abort-disabled.rs new file mode 100644 index 00000000000..f24046ff0e8 --- /dev/null +++ b/src/test/ui/test-panic-abort-disabled.rs @@ -0,0 +1,20 @@ +// error-pattern:building tests with panic=abort is not yet supported +// no-prefer-dynamic +// compile-flags: --test -Cpanic=abort +// run-flags: --test-threads=1 + +// ignore-wasm no panic or subprocess support +// ignore-emscripten no panic or subprocess support + +#![cfg(test)] + +#[test] +fn it_works() { + assert_eq!(1 + 1, 2); +} + +#[test] +#[should_panic] +fn it_panics() { + assert_eq!(1 + 1, 4); +} diff --git a/src/test/ui/test-panic-abort-disabled.stderr b/src/test/ui/test-panic-abort-disabled.stderr new file mode 100644 index 00000000000..a8d9bad43ed --- /dev/null +++ b/src/test/ui/test-panic-abort-disabled.stderr @@ -0,0 +1,4 @@ +error: building tests with panic=abort is not yet supported + +error: aborting due to previous error + diff --git a/src/test/ui/test-panic-abort.rs b/src/test/ui/test-panic-abort.rs new file mode 100644 index 00000000000..415ecbf7b38 --- /dev/null +++ b/src/test/ui/test-panic-abort.rs @@ -0,0 +1,36 @@ +// no-prefer-dynamic +// compile-flags: --test -Cpanic=abort -Zpanic_abort_tests +// 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); +} diff --git a/src/test/ui/test-panic-abort.run.stdout b/src/test/ui/test-panic-abort.run.stdout new file mode 100644 index 00000000000..32c96b4f849 --- /dev/null +++ b/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 + |
