2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2024-03-06 20:19:20 +00:00
|
|
|
//@ needs-threads
|
2025-01-23 08:36:54 +00:00
|
|
|
//@ needs-subprocess
|
2016-08-08 23:39:37 +00:00
|
|
|
|
2015-04-15 19:27:05 +00:00
|
|
|
use std::process::Command;
|
2024-08-24 03:32:52 +00:00
|
|
|
use std::{env, thread};
|
2015-04-15 19:27:05 +00:00
|
|
|
|
|
|
|
struct Handle(i32);
|
|
|
|
|
|
|
|
impl Drop for Handle {
|
2024-08-24 03:32:52 +00:00
|
|
|
fn drop(&mut self) {
|
|
|
|
panic!();
|
|
|
|
}
|
2015-04-15 19:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
thread_local!(static HANDLE: Handle = Handle(0));
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let args = env::args().collect::<Vec<_>>();
|
|
|
|
if args.len() == 1 {
|
|
|
|
let out = Command::new(&args[0]).arg("test").output().unwrap();
|
|
|
|
let stderr = std::str::from_utf8(&out.stderr).unwrap();
|
2024-08-24 03:32:52 +00:00
|
|
|
assert!(stderr.contains("explicit panic"), "bad failure message:\n{}\n", stderr);
|
2015-04-15 19:27:05 +00:00
|
|
|
} else {
|
|
|
|
// TLS dtors are not always run on process exit
|
|
|
|
thread::spawn(|| {
|
|
|
|
HANDLE.with(|h| {
|
|
|
|
println!("{}", h.0);
|
|
|
|
});
|
2024-08-24 03:32:52 +00:00
|
|
|
})
|
|
|
|
.join()
|
|
|
|
.unwrap();
|
2015-04-15 19:27:05 +00:00
|
|
|
}
|
|
|
|
}
|