]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/multi-panic.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / run-pass / multi-panic.rs
CommitLineData
7453a54e
SL
1// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
5bcae85e
SL
11// ignore-emscripten
12
54a0048b
SL
13fn check_for_no_backtrace(test: std::process::Output) {
14 assert!(!test.status.success());
15 let err = String::from_utf8_lossy(&test.stderr);
16 let mut it = err.lines();
17
18 assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true));
19 assert_eq!(it.next(), Some("note: Run with `RUST_BACKTRACE=1` for a backtrace."));
3157f602 20 assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true));
54a0048b
SL
21 assert_eq!(it.next(), None);
22}
23
7453a54e
SL
24fn main() {
25 let args: Vec<String> = std::env::args().collect();
26 if args.len() > 1 && args[1] == "run_test" {
27 let _ = std::thread::spawn(|| {
28 panic!();
29 }).join();
30
31 panic!();
32 } else {
33 let test = std::process::Command::new(&args[0]).arg("run_test")
34 .env_remove("RUST_BACKTRACE")
35 .output()
36 .unwrap();
54a0048b
SL
37 check_for_no_backtrace(test);
38 let test = std::process::Command::new(&args[0]).arg("run_test")
39 .env("RUST_BACKTRACE","0")
40 .output()
41 .unwrap();
42 check_for_no_backtrace(test);
7453a54e
SL
43 }
44}