mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
add test that multi-threaded panics aren't interleaved
This commit is contained in:
parent
6e2780775f
commit
de14f1f932
15
tests/ui/backtrace/synchronized-panic-handler.rs
Normal file
15
tests/ui/backtrace/synchronized-panic-handler.rs
Normal file
@ -0,0 +1,15 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ edition:2021
|
||||
use std::thread;
|
||||
const PANIC_MESSAGE: &str = "oops oh no woe is me";
|
||||
|
||||
fn entry() {
|
||||
panic!("{PANIC_MESSAGE}")
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (a, b) = (thread::spawn(entry), thread::spawn(entry));
|
||||
assert_eq!(&**a.join().unwrap_err().downcast::<String>().unwrap(), PANIC_MESSAGE);
|
||||
assert_eq!(&**b.join().unwrap_err().downcast::<String>().unwrap(), PANIC_MESSAGE);
|
||||
}
|
5
tests/ui/backtrace/synchronized-panic-handler.run.stderr
Normal file
5
tests/ui/backtrace/synchronized-panic-handler.run.stderr
Normal file
@ -0,0 +1,5 @@
|
||||
thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:thread '8<unnamed>:5' panicked at :
|
||||
oops oh no woe is me$DIR/synchronized-panic-handler.rs
|
||||
:note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
8:5:
|
||||
oops oh no woe is me
|
Loading…
Reference in New Issue
Block a user