-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect --nocapture in panic=abort test mode
- Loading branch information
Showing
4 changed files
with
88 additions
and
9 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
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,39 @@ | ||
// no-prefer-dynamic | ||
// compile-flags: --test -Cpanic=abort -Zpanic_abort_tests | ||
// run-flags: --test-threads=1 --nocapture | ||
// run-fail | ||
// check-run-results | ||
// exec-env:RUST_BACKTRACE=0 | ||
|
||
// ignore-wasm no panic or subprocess support | ||
// ignore-emscripten no panic or subprocess support | ||
|
||
#![cfg(test)] | ||
|
||
use std::io::Write; | ||
|
||
#[test] | ||
fn it_works() { | ||
println!("about to succeed"); | ||
assert_eq!(1 + 1, 2); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn it_panics() { | ||
println!("about to panic"); | ||
assert_eq!(1 + 1, 4); | ||
} | ||
|
||
#[test] | ||
fn it_fails() { | ||
println!("about to fail"); | ||
assert_eq!(1 + 1, 4); | ||
} | ||
|
||
#[test] | ||
fn it_writes_to_stdio() { | ||
println!("hello, world"); | ||
writeln!(std::io::stdout(), "testing123").unwrap(); | ||
writeln!(std::io::stderr(), "testing321").unwrap(); | ||
} |
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,9 @@ | ||
thread 'main' panicked at 'assertion failed: `(left == right)` | ||
left: `2`, | ||
right: `4`', $DIR/test-panic-abort-nocapture.rs:31:5 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
thread 'main' panicked at 'assertion failed: `(left == right)` | ||
left: `2`, | ||
right: `4`', $DIR/test-panic-abort-nocapture.rs:25:5 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
testing321 |
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,23 @@ | ||
|
||
running 4 tests | ||
test it_fails ... about to fail | ||
FAILED | ||
test it_panics ... about to panic | ||
ok | ||
test it_works ... about to succeed | ||
ok | ||
test it_writes_to_stdio ... hello, world | ||
testing123 | ||
ok | ||
|
||
failures: | ||
|
||
---- it_fails stdout ---- | ||
---- it_fails stderr ---- | ||
|
||
|
||
failures: | ||
it_fails | ||
|
||
test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out | ||
|