-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-se
Capture output from threads spawned in tests This is revival of #75172. Original text: > Fixes #42474. > > r? `@dtolnay` since you expressed interest in this, but feel free to redirect if you aren't the right person anymore. --- Closes #75172.
- Loading branch information
Showing
14 changed files
with
184 additions
and
12 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
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
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
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
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,31 @@ | ||
// compile-flags: --test | ||
// run-fail | ||
// run-flags: --test-threads=1 | ||
// check-run-results | ||
// exec-env:RUST_BACKTRACE=0 | ||
// ignore-emscripten no threads support | ||
|
||
#[test] | ||
fn thready_pass() { | ||
println!("fee"); | ||
std::thread::spawn(|| { | ||
println!("fie"); | ||
println!("foe"); | ||
}) | ||
.join() | ||
.unwrap(); | ||
println!("fum"); | ||
} | ||
|
||
#[test] | ||
fn thready_fail() { | ||
println!("fee"); | ||
std::thread::spawn(|| { | ||
println!("fie"); | ||
println!("foe"); | ||
}) | ||
.join() | ||
.unwrap(); | ||
println!("fum"); | ||
panic!(); | ||
} |
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,21 @@ | ||
|
||
running 2 tests | ||
test thready_fail ... FAILED | ||
test thready_pass ... ok | ||
|
||
failures: | ||
|
||
---- thready_fail stdout ---- | ||
fee | ||
fie | ||
foe | ||
fum | ||
thread 'main' panicked at 'explicit panic', $DIR/test-thread-capture.rs:30:5 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
|
||
|
||
failures: | ||
thready_fail | ||
|
||
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
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,31 @@ | ||
// compile-flags: --test | ||
// run-fail | ||
// run-flags: --test-threads=1 --nocapture | ||
// check-run-results | ||
// exec-env:RUST_BACKTRACE=0 | ||
// ignore-emscripten no threads support | ||
|
||
#[test] | ||
fn thready_pass() { | ||
println!("fee"); | ||
std::thread::spawn(|| { | ||
println!("fie"); | ||
println!("foe"); | ||
}) | ||
.join() | ||
.unwrap(); | ||
println!("fum"); | ||
} | ||
|
||
#[test] | ||
fn thready_fail() { | ||
println!("fee"); | ||
std::thread::spawn(|| { | ||
println!("fie"); | ||
println!("foe"); | ||
}) | ||
.join() | ||
.unwrap(); | ||
println!("fum"); | ||
panic!(); | ||
} |
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,2 @@ | ||
thread 'main' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:30:5 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace |
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,20 @@ | ||
|
||
running 2 tests | ||
test thready_fail ... fee | ||
fie | ||
foe | ||
fum | ||
FAILED | ||
test thready_pass ... fee | ||
fie | ||
foe | ||
fum | ||
ok | ||
|
||
failures: | ||
|
||
failures: | ||
thready_fail | ||
|
||
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
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