forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#81367 - andersk:join-test-threads, r=dtolnay
libtest: Wait for test threads to exit after they report completion Otherwise we can miss bugs where a test reports that it succeeded but then panics within a TLS destructor. Example: ```rust use std::thread::sleep; use std::time::Duration; struct Foo; impl Drop for Foo { fn drop(&mut self) { sleep(Duration::from_secs(1)); panic!() } } thread_local!(static FOO: Foo = Foo); #[test] pub fn test() { FOO.with(|_| {}); } ``` Before this fix, `cargo test` incorrectly reports success. ```console $ cargo test Finished test [unoptimized + debuginfo] target(s) in 0.01s Running target/debug/deps/panicking_test-85130fa46b54f758 running 1 test test test ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s $ echo $? 0 ``` After this fix, the failure is visible. (The entire process is aborted due to rust-lang#24479.) ```console $ cargo test Finished test [unoptimized + debuginfo] target(s) in 0.01s Running target/debug/deps/panicking_test-76180625bc2ee3c9 running 1 test thread 'test' panicked at 'explicit panic', src/main.rs:9:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace fatal runtime error: failed to initiate panic, error 5 error: test failed, to rerun pass '--bin panicking-test' Caused by: process didn't exit successfully: `/tmp/panicking-test/target/debug/deps/panicking_test-76180625bc2ee3c9 --nocapture` (signal: 6, SIGABRT: process abort signal) $ echo $? 101 ```
- Loading branch information
Showing
1 changed file
with
64 additions
and
24 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