]> git.lizzy.rs Git - rust.git/blob - tests/ui/process/multi-panic.rs
Rollup merge of #106692 - eggyal:mv-binary_heap.rs-binary_heap/mod.rs, r=Mark-Simulacrum
[rust.git] / tests / ui / process / multi-panic.rs
1 // run-pass
2 // ignore-emscripten no processes
3 // ignore-sgx no processes
4 // needs-unwind
5
6 fn check_for_no_backtrace(test: std::process::Output) {
7     assert!(!test.status.success());
8     let err = String::from_utf8_lossy(&test.stderr);
9     let mut it = err.lines();
10
11     assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true));
12     assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \
13                                 environment variable to display a backtrace"));
14     assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true));
15     assert_eq!(it.next(), None);
16 }
17
18 fn main() {
19     let args: Vec<String> = std::env::args().collect();
20     if args.len() > 1 && args[1] == "run_test" {
21         let _ = std::thread::spawn(|| {
22             panic!();
23         }).join();
24
25         panic!();
26     } else {
27         let test = std::process::Command::new(&args[0]).arg("run_test")
28                                                        .env_remove("RUST_BACKTRACE")
29                                                        .output()
30                                                        .unwrap();
31         check_for_no_backtrace(test);
32         let test = std::process::Command::new(&args[0]).arg("run_test")
33                                                        .env("RUST_BACKTRACE","0")
34                                                        .output()
35                                                        .unwrap();
36         check_for_no_backtrace(test);
37     }
38 }