]>
Commit | Line | Data |
---|---|---|
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 | ||
54a0048b SL |
11 | fn check_for_no_backtrace(test: std::process::Output) { |
12 | assert!(!test.status.success()); | |
13 | let err = String::from_utf8_lossy(&test.stderr); | |
14 | let mut it = err.lines(); | |
15 | ||
16 | assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true)); | |
17 | assert_eq!(it.next(), Some("note: Run with `RUST_BACKTRACE=1` for a backtrace.")); | |
18 | assert_eq!(it.next().map(|l| l.starts_with("thread '<main>' panicked at")), Some(true)); | |
19 | assert_eq!(it.next(), None); | |
20 | } | |
21 | ||
7453a54e SL |
22 | fn main() { |
23 | let args: Vec<String> = std::env::args().collect(); | |
24 | if args.len() > 1 && args[1] == "run_test" { | |
25 | let _ = std::thread::spawn(|| { | |
26 | panic!(); | |
27 | }).join(); | |
28 | ||
29 | panic!(); | |
30 | } else { | |
31 | let test = std::process::Command::new(&args[0]).arg("run_test") | |
32 | .env_remove("RUST_BACKTRACE") | |
33 | .output() | |
34 | .unwrap(); | |
54a0048b SL |
35 | check_for_no_backtrace(test); |
36 | let test = std::process::Command::new(&args[0]).arg("run_test") | |
37 | .env("RUST_BACKTRACE","0") | |
38 | .output() | |
39 | .unwrap(); | |
40 | check_for_no_backtrace(test); | |
7453a54e SL |
41 | } |
42 | } |