]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rt-explody-panic-payloads.rs
Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
[rust.git] / src / test / ui / rt-explody-panic-payloads.rs
1 // run-pass
2 // ignore-emscripten no processes
3 // ignore-sgx no processes
4 // ignore-wasm32-bare no unwinding panic
5 // ignore-avr no unwinding panic
6 // ignore-nvptx64 no unwinding panic
7
8 use std::env;
9 use std::process::Command;
10
11 struct Bomb;
12
13 impl Drop for Bomb {
14     fn drop(&mut self) {
15         std::panic::panic_any(Bomb);
16     }
17 }
18
19 fn main() {
20     let args = env::args().collect::<Vec<_>>();
21     let output = match &args[..] {
22         [me] => Command::new(&me).arg("plant the").output(),
23         [..] => std::panic::panic_any(Bomb),
24     }.expect("running the command should have succeeded");
25     println!("{:#?}", output);
26     let stderr = std::str::from_utf8(&output.stderr);
27     assert!(stderr.map(|v| {
28         v.ends_with("drop of the panic payload panicked")
29     }).unwrap_or(false));
30 }