about summary refs log tree commit diff
path: root/src/libtest/lib.rs
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-02-14 10:06:12 -0500
committerNiko Matsakis <niko@alum.mit.edu>2018-02-22 17:56:24 -0500
commite446f706a89e3d5c26c01318bd70904d492ab8b2 (patch)
treec6acae38a028ee6bae2dfc6c4c2bc2ce4bcf38dd /src/libtest/lib.rs
parent0625d4c282a9fa2a5ba3c6448017898baccfcf9a (diff)
downloadrust-e446f706a89e3d5c26c01318bd70904d492ab8b2.tar.gz
rust-e446f706a89e3d5c26c01318bd70904d492ab8b2.zip
put the "unit test" logic into libtest
Also make `std::termination` module public and rename feature.

The lib feature needs a different name from the language feature.
Diffstat (limited to 'src/libtest/lib.rs')
-rw-r--r--src/libtest/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 9ea5f39b71f..932952d649b 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -40,6 +40,7 @@
 #![feature(set_stdio)]
 #![feature(panic_unwind)]
 #![feature(staged_api)]
+#![feature(termination_trait_lib)]
 
 extern crate getopts;
 extern crate term;
@@ -69,6 +70,7 @@ use std::iter::repeat;
 use std::path::PathBuf;
 use std::sync::mpsc::{channel, Sender};
 use std::sync::{Arc, Mutex};
+use std::termination::Termination;
 use std::thread;
 use std::time::{Instant, Duration};
 use std::borrow::Cow;
@@ -322,6 +324,13 @@ pub fn test_main_static(tests: &[TestDescAndFn]) {
     test_main(&args, owned_tests, Options::new())
 }
 
+/// Invoked when unit tests terminate. Should panic if the unit
+/// test is considered a failure. By default, invokes `report()`
+/// and checks for a `0` result.
+pub fn assert_test_result<T: Termination>(result: T) {
+    assert_eq!(result.report(), 0);
+}
+
 #[derive(Copy, Clone, Debug)]
 pub enum ColorConfig {
     AutoColor,