@@ -70,6 +70,9 @@ use std::sync::{Arc, Mutex};
7070use std:: thread;
7171use std:: time:: { Duration , Instant } ;
7272
73+ #[ cfg( test) ]
74+ mod tests;
75+
7376const TEST_WARN_TIMEOUT_S : u64 = 60 ;
7477const QUIET_MODE_MAX_COLUMN : usize = 100 ; // insert a '\n' after 100 tests in quiet mode
7578
@@ -495,18 +498,18 @@ environment variable to a value other than "0". Logging is not captured by defau
495498
496499Test Attributes:
497500
498- #[test] - Indicates a function is a test to be run. This function
499- takes no arguments.
500- #[bench] - Indicates a function is a benchmark to be run. This
501- function takes one argument (test::Bencher).
502- #[should_panic] - This function (also labeled with #[test]) will only pass if
503- the code causes a panic (an assertion failure or panic!)
504- A message may be provided, which the failure string must
505- contain: #[should_panic(expected = "foo")].
506- #[ignore] - When applied to a function which is already attributed as a
507- test, then the test runner will ignore these tests during
508- normal test runs. Running with --ignored or --include-ignored will run
509- these tests."# ,
501+ ` #[test]` - Indicates a function is a test to be run. This function
502+ takes no arguments.
503+ ` #[bench]` - Indicates a function is a benchmark to be run. This
504+ function takes one argument (test::Bencher).
505+ ` #[should_panic]` - This function (also labeled with ` #[test]` ) will only pass if
506+ the code causes a panic (an assertion failure or panic!)
507+ A message may be provided, which the failure string must
508+ contain: #[should_panic(expected = "foo")].
509+ ` #[ignore]` - When applied to a function which is already attributed as a
510+ test, then the test runner will ignore these tests during
511+ normal test runs. Running with --ignored or --include-ignored will run
512+ these tests."# ,
510513 usage = options. usage( & message)
511514 ) ;
512515}
@@ -974,50 +977,6 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
974977 return out. write_run_finish ( & st) ;
975978}
976979
977- #[ test]
978- fn should_sort_failures_before_printing_them ( ) {
979- let test_a = TestDesc {
980- name : StaticTestName ( "a" ) ,
981- ignore : false ,
982- should_panic : ShouldPanic :: No ,
983- allow_fail : false ,
984- } ;
985-
986- let test_b = TestDesc {
987- name : StaticTestName ( "b" ) ,
988- ignore : false ,
989- should_panic : ShouldPanic :: No ,
990- allow_fail : false ,
991- } ;
992-
993- let mut out = PrettyFormatter :: new ( Raw ( Vec :: new ( ) ) , false , 10 , false ) ;
994-
995- let st = ConsoleTestState {
996- log_out : None ,
997- total : 0 ,
998- passed : 0 ,
999- failed : 0 ,
1000- ignored : 0 ,
1001- allowed_fail : 0 ,
1002- filtered_out : 0 ,
1003- measured : 0 ,
1004- metrics : MetricMap :: new ( ) ,
1005- failures : vec ! [ ( test_b, Vec :: new( ) ) , ( test_a, Vec :: new( ) ) ] ,
1006- options : Options :: new ( ) ,
1007- not_failures : Vec :: new ( ) ,
1008- } ;
1009-
1010- out. write_failures ( & st) . unwrap ( ) ;
1011- let s = match out. output_location ( ) {
1012- & Raw ( ref m) => String :: from_utf8_lossy ( & m[ ..] ) ,
1013- & Pretty ( _) => unreachable ! ( ) ,
1014- } ;
1015-
1016- let apos = s. find ( "a" ) . unwrap ( ) ;
1017- let bpos = s. find ( "b" ) . unwrap ( ) ;
1018- assert ! ( apos < bpos) ;
1019- }
1020-
1021980fn use_color ( opts : & TestOpts ) -> bool {
1022981 match opts. color {
1023982 AutoColor => !opts. nocapture && stdout_isatty ( ) ,
@@ -1775,6 +1734,3 @@ pub mod bench {
17751734 bs. bench ( f) ;
17761735 }
17771736}
1778-
1779- #[ cfg( test) ]
1780- mod tests;
0 commit comments