2019-07-26 16:54:25 -05:00
|
|
|
// run-pass
|
2018-01-02 07:11:41 -06:00
|
|
|
// ignore-cloudabi no processes
|
2017-10-17 20:45:42 -05:00
|
|
|
// ignore-emscripten no processes
|
2019-04-24 11:26:33 -05:00
|
|
|
// ignore-sgx no processes
|
2016-08-08 18:39:37 -05:00
|
|
|
|
2016-03-28 07:41:55 -05: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-19 19:08:52 -05:00
|
|
|
assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \
|
2020-01-10 08:36:22 -06:00
|
|
|
environment variable to display a backtrace"));
|
2016-05-22 09:36:55 -05:00
|
|
|
assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true));
|
2016-03-28 07:41:55 -05:00
|
|
|
assert_eq!(it.next(), None);
|
|
|
|
}
|
|
|
|
|
2016-01-25 11:16:43 -06: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 05:56:06 -06:00
|
|
|
let test = std::process::Command::new(&args[0]).arg("run_test")
|
|
|
|
.env_remove("RUST_BACKTRACE")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
2016-03-28 07:41:55 -05: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 11:16:43 -06:00
|
|
|
}
|
|
|
|
}
|