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