]> git.lizzy.rs Git - rust.git/commitdiff
test: Don't panic if some tests failed
authorAlex Crichton <alex@alexcrichton.com>
Mon, 17 Aug 2015 19:58:19 +0000 (12:58 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 17 Aug 2015 19:58:19 +0000 (12:58 -0700)
This commit removes the call to `panic!("Some tests failed")` at the end of all
tests run when running with libtest. The panic is replaced with
`std::process::exit` to have a nonzero error code, but this change both:

1. Makes the test runner no longer print out the extraneous panic message at the
   end of a failing test run that some tests failed. (this is already summarized
   in the output of the test run).
2. When running tests with `RUST_BACKTRACE` set it removes an extraneous
   backtrace from the output (only failing tests will have their backtraces in
   the output.

src/libtest/lib.rs

index 47c50f70a392a609ec61bc7eb2bb736e61b2b515..4de7e7c586606339ac29abd7635b9d7df3d0cf30 100644 (file)
@@ -250,7 +250,7 @@ pub fn test_main(args: &[String], tests: Vec<TestDescAndFn> ) {
         };
     match run_tests_console(&opts, tests) {
         Ok(true) => {}
-        Ok(false) => panic!("Some tests failed"),
+        Ok(false) => std::process::exit(101),
         Err(e) => panic!("io error when running tests: {:?}", e),
     }
 }