rust/tests/ui/panic-runtime/lto-unwind.rs
许杰友 Jieyou Xu (Joe) a5d72f45ba tests: cleanup tests/ui/panic-runtime/lto-unwind.rs
- Ignore an unused variable and remove `#![allow(unused_variables)]`.
- Replace `ignore-*` with `needs-subprocess`.
2025-01-23 20:51:29 +08:00

35 lines
712 B
Rust

//@ run-pass
//@ compile-flags:-C lto -C panic=unwind
//@ needs-unwind
//@ no-prefer-dynamic
//@ needs-subprocess
use std::process::Command;
use std::env;
struct Bomb;
impl Drop for Bomb {
fn drop(&mut self) {
println!("hurray you ran me");
}
}
fn main() {
let mut args = env::args_os();
let _ = args.next().unwrap();
if let Some(s) = args.next() {
if &*s == "foo" {
let _bomb = Bomb;
panic!("try to catch me");
}
}
let s = Command::new(env::args_os().next().unwrap()).arg("foo").output();
let s = s.unwrap();
assert!(!s.status.success());
assert!(String::from_utf8_lossy(&s.stdout).contains("hurray you ran me"));
}