@@ -55,9 +55,7 @@ const QUIET_MODE_MAX_COLUMN: usize = 100; // insert a '\n' after 100 tests in qu
5555mod formatters;
5656pub mod stats;
5757
58- use crate :: formatters:: {
59- JsonFormatter , OutputFormatter , PrettyFormatter , TerseFormatter ,
60- } ;
58+ use crate :: formatters:: { JsonFormatter , OutputFormatter , PrettyFormatter , TerseFormatter , JUnitFormatter } ;
6159
6260/// Whether to execute tests concurrently or not
6361#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
@@ -327,6 +325,7 @@ pub enum OutputFormat {
327325 Pretty ,
328326 Terse ,
329327 Json ,
328+ JUnit ,
330329}
331330
332331#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
@@ -441,8 +440,9 @@ fn optgroups() -> getopts::Options {
441440 "Configure formatting of output:
442441 pretty = Print verbose output;
443442 terse = Display one character per test;
444- json = Output a json document" ,
445- "pretty|terse|json" ,
443+ json = Output a json document;
444+ junit = Output a JUnit document" ,
445+ "pretty|terse|json|junit" ,
446446 )
447447 . optopt (
448448 "Z" ,
@@ -622,10 +622,18 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
622622 }
623623 OutputFormat :: Json
624624 }
625+ Some ( "junit" ) => {
626+ if !allow_unstable {
627+ return Some ( Err (
628+ "The \" junit\" format is only accepted on the nightly compiler" . into ( ) ,
629+ ) ) ;
630+ }
631+ OutputFormat :: JUnit
632+ }
625633
626634 Some ( v) => {
627635 return Some ( Err ( format ! (
628- "argument for --format must be pretty, terse, or json (was \
636+ "argument for --format must be pretty, terse, json, or junit (was \
629637 {})",
630638 v
631639 ) ) ) ;
@@ -704,6 +712,7 @@ struct ConsoleTestState {
704712 failures : Vec < ( TestDesc , Vec < u8 > ) > ,
705713 not_failures : Vec < ( TestDesc , Vec < u8 > ) > ,
706714 options : Options ,
715+ start_time : Instant ,
707716}
708717
709718impl ConsoleTestState {
@@ -726,6 +735,7 @@ impl ConsoleTestState {
726735 failures : Vec :: new ( ) ,
727736 not_failures : Vec :: new ( ) ,
728737 options : opts. options ,
738+ start_time : Instant :: now ( )
729739 } )
730740 }
731741
@@ -962,9 +972,9 @@ pub fn run_tests_console(
962972 is_multithreaded,
963973 ) ) ,
964974 OutputFormat :: Json => Box :: new ( JsonFormatter :: new ( output) ) ,
975+ OutputFormat :: JUnit => Box :: new ( JUnitFormatter :: new ( output) ) ,
965976 } ;
966977 let mut st = ConsoleTestState :: new ( opts) ?;
967-
968978 run_tests ( opts, tests, |x| callback ( & x, & mut st, & mut * out) ) ?;
969979
970980 assert ! ( st. current_test_count( ) == st. total) ;
@@ -1008,6 +1018,7 @@ fn should_sort_failures_before_printing_them() {
10081018 failures : vec ! [ ( test_b, Vec :: new( ) ) , ( test_a, Vec :: new( ) ) ] ,
10091019 options : Options :: new ( ) ,
10101020 not_failures : Vec :: new ( ) ,
1021+ start_time : Instant :: now ( )
10111022 } ;
10121023
10131024 out. write_failures ( & st) . unwrap ( ) ;
0 commit comments