2019-07-27 00:54:25 +03:00
|
|
|
//@ run-pass
|
2025-01-23 16:36:54 +08:00
|
|
|
//@ needs-subprocess
|
2022-03-19 16:13:18 +01:00
|
|
|
//@ needs-unwind
|
2025-09-26 13:59:06 +02:00
|
|
|
//@ ignore-backends: gcc
|
2016-08-09 01:39:37 +02:00
|
|
|
|
2016-03-28 14:41:55 +02:00
|
|
|
fn check_for_no_backtrace(test: std::process::Output) {
|
|
|
|
|
assert!(!test.status.success());
|
|
|
|
|
let err = String::from_utf8_lossy(&test.stderr);
|
2024-03-15 19:09:24 +01:00
|
|
|
let mut it = err.lines().filter(|l| !l.is_empty());
|
2016-03-28 14:41:55 +02:00
|
|
|
|
2023-09-11 00:59:31 -04:00
|
|
|
assert_eq!(
|
|
|
|
|
it.next().map(|l| l.starts_with("thread '<unnamed>' (") && l.contains("panicked")),
|
|
|
|
|
Some(true),
|
|
|
|
|
"out: ```{err}```",
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(it.next().is_some(), true, "out: ```{err}```");
|
2024-03-15 19:09:24 +01:00
|
|
|
assert_eq!(
|
|
|
|
|
it.next(),
|
|
|
|
|
Some(
|
|
|
|
|
"note: run with `RUST_BACKTRACE=1` \
|
|
|
|
|
environment variable to display a backtrace"
|
2023-09-11 00:59:31 -04:00
|
|
|
),
|
|
|
|
|
"out: ```{err}```",
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
it.next().map(|l| l.starts_with("thread 'main' (") && l.contains("panicked at")),
|
|
|
|
|
Some(true),
|
|
|
|
|
"out: ```{err}```",
|
2024-03-15 19:09:24 +01:00
|
|
|
);
|
2023-09-11 00:59:31 -04:00
|
|
|
assert_eq!(it.next().is_some(), true, "out: ```{err}```");
|
|
|
|
|
assert_eq!(it.next(), None, "out: ```{err}```");
|
2016-03-28 14:41:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-25 18:16:43 +01:00
|
|
|
fn main() {
|
|
|
|
|
let args: Vec<String> = std::env::args().collect();
|
|
|
|
|
if args.len() > 1 && args[1] == "run_test" {
|
|
|
|
|
let _ = std::thread::spawn(|| {
|
|
|
|
|
panic!();
|
2024-03-15 19:09:24 +01:00
|
|
|
})
|
|
|
|
|
.join();
|
2016-01-25 18:16:43 +01:00
|
|
|
|
|
|
|
|
panic!();
|
|
|
|
|
} else {
|
2024-03-15 19:09:24 +01:00
|
|
|
let test = std::process::Command::new(&args[0])
|
|
|
|
|
.arg("run_test")
|
|
|
|
|
.env_remove("RUST_BACKTRACE")
|
|
|
|
|
.output()
|
|
|
|
|
.unwrap();
|
2016-03-28 14:41:55 +02:00
|
|
|
check_for_no_backtrace(test);
|
2024-03-15 19:09:24 +01:00
|
|
|
let test = std::process::Command::new(&args[0])
|
|
|
|
|
.arg("run_test")
|
|
|
|
|
.env("RUST_BACKTRACE", "0")
|
|
|
|
|
.output()
|
|
|
|
|
.unwrap();
|
2016-03-28 14:41:55 +02:00
|
|
|
check_for_no_backtrace(test);
|
2016-01-25 18:16:43 +01:00
|
|
|
}
|
|
|
|
|
}
|