Skip to content

Commit d8fb568

Browse files
committed
fix spurious test failure with panic=abort
1 parent af9df2f commit d8fb568

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Diff for: tests/ui/panic-handler/weak-lang-item-2.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@
66

77
extern crate weak_lang_items as other;
88

9-
use std::thread;
10-
119
fn main() {
12-
let _ = thread::spawn(move|| {
10+
let _ = std::thread::spawn(move || {
11+
// The goal of the test is just to make sure other::foo() is called. Since the function
12+
// panics, it's executed in its own thread. That way, the panic is isolated within the
13+
// thread and wont't affect the overall exit code.
14+
//
15+
// That causes a spurious failures in panic=abort targets though: if the program exits
16+
// before the thread is fully initialized the test will pass, but if the thread gets
17+
// executed first the whole program will abort. Adding a 60 seconds sleep will (hopefully!)
18+
// ensure the program always exits before the thread is executed.
19+
std::thread::sleep(std::time::Duration::from_secs(60));
20+
1321
other::foo()
1422
});
1523
}

0 commit comments

Comments
 (0)