Skip to content

Commit de14f1f

Browse files
committed
add test that multi-threaded panics aren't interleaved
1 parent 6e27807 commit de14f1f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ run-pass
2+
//@ check-run-results
3+
//@ edition:2021
4+
use std::thread;
5+
const PANIC_MESSAGE: &str = "oops oh no woe is me";
6+
7+
fn entry() {
8+
panic!("{PANIC_MESSAGE}")
9+
}
10+
11+
fn main() {
12+
let (a, b) = (thread::spawn(entry), thread::spawn(entry));
13+
assert_eq!(&**a.join().unwrap_err().downcast::<String>().unwrap(), PANIC_MESSAGE);
14+
assert_eq!(&**b.join().unwrap_err().downcast::<String>().unwrap(), PANIC_MESSAGE);
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:thread '8<unnamed>:5' panicked at :
2+
oops oh no woe is me$DIR/synchronized-panic-handler.rs
3+
:note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
8:5:
5+
oops oh no woe is me

0 commit comments

Comments
 (0)