]> git.proxmox.com Git - rustc.git/blobdiff - src/test/run-pass/multi-panic.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / run-pass / multi-panic.rs
index 6a0d7278b5e16481fd5c9c486730ee2cb846aabc..8e0b14128c83b0896cb93b218ad8c5b61829c460 100644 (file)
@@ -8,6 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+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));
+    assert_eq!(it.next(), Some("note: Run with `RUST_BACKTRACE=1` for a backtrace."));
+    assert_eq!(it.next().map(|l| l.starts_with("thread '<main>' panicked at")), Some(true));
+    assert_eq!(it.next(), None);
+}
+
 fn main() {
     let args: Vec<String> = std::env::args().collect();
     if args.len() > 1 && args[1] == "run_test" {
@@ -21,13 +32,11 @@ fn main() {
                                                        .env_remove("RUST_BACKTRACE")
                                                        .output()
                                                        .unwrap();
-        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));
-        assert_eq!(it.next(), Some("note: Run with `RUST_BACKTRACE=1` for a backtrace."));
-        assert_eq!(it.next().map(|l| l.starts_with("thread '<main>' panicked at")), Some(true));
-        assert_eq!(it.next(), None);
+        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);
     }
 }