2019-07-26 21:54:25 +00:00
|
|
|
// run-pass
|
2017-10-18 01:45:42 +00:00
|
|
|
// ignore-emscripten no processes
|
2019-04-24 16:26:33 +00:00
|
|
|
// ignore-sgx no processes
|
2022-03-19 15:13:18 +00:00
|
|
|
// needs-unwind
|
2016-08-08 23:39:37 +00:00
|
|
|
|
2016-03-28 12:41:55 +00:00
|
|
|
fn check_for_no_backtrace(test: std::process::Output) {
|
|
|
|
assert!(!test.status.success());
|
|
|
|
let err = String::from_utf8_lossy(&test.stderr);
|
|
|
|
let mut it = err.lines();
|
|
|
|
|
|
|
|
assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true));
|
2019-05-20 00:08:52 +00:00
|
|
|
assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \
|
2020-01-10 14:36:22 +00:00
|
|
|
environment variable to display a backtrace"));
|
2016-05-22 14:36:55 +00:00
|
|
|
assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true));
|
2016-03-28 12:41:55 +00:00
|
|
|
assert_eq!(it.next(), None);
|
|
|
|
}
|
|
|
|
|
2016-01-25 17:16:43 +00:00
|
|
|
fn main() {
|
|
|
|
let args: Vec<String> = std::env::args().collect();
|
|
|
|
if args.len() > 1 && args[1] == "run_test" {
|
|
|
|
let _ = std::thread::spawn(|| {
|
|
|
|
panic!();
|
|
|
|
}).join();
|
|
|
|
|
|
|
|
panic!();
|
|
|
|
} else {
|
2016-01-28 11:56:06 +00:00
|
|
|
let test = std::process::Command::new(&args[0]).arg("run_test")
|
|
|
|
.env_remove("RUST_BACKTRACE")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
2016-03-28 12:41:55 +00:00
|
|
|
check_for_no_backtrace(test);
|
|
|
|
let test = std::process::Command::new(&args[0]).arg("run_test")
|
|
|
|
.env("RUST_BACKTRACE","0")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
check_for_no_backtrace(test);
|
2016-01-25 17:16:43 +00:00
|
|
|
}
|
|
|
|
}
|