File tree Expand file tree Collapse file tree 3 files changed +17
-17
lines changed Expand file tree Collapse file tree 3 files changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -169,11 +169,10 @@ impl<T: Write> PrettyFormatter<T> {
169169
170170 fn write_test_name ( & mut self , desc : & TestDesc ) -> io:: Result < ( ) > {
171171 let name = desc. padded_name ( self . max_name_len , desc. name . padding ( ) ) ;
172- let test_mode = desc. test_mode ( ) ;
173- if test_mode == "" {
174- self . write_plain ( & format ! ( "test {} ... " , name) ) ?;
175- } else {
172+ if let Some ( test_mode) = desc. test_mode ( ) {
176173 self . write_plain ( & format ! ( "test {} - {} ... " , name, test_mode) ) ?;
174+ } else {
175+ self . write_plain ( & format ! ( "test {} ... " , name) ) ?;
177176 }
178177
179178 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -158,11 +158,10 @@ impl<T: Write> TerseFormatter<T> {
158158
159159 fn write_test_name ( & mut self , desc : & TestDesc ) -> io:: Result < ( ) > {
160160 let name = desc. padded_name ( self . max_name_len , desc. name . padding ( ) ) ;
161- let test_mode = desc. test_mode ( ) ;
162- if test_mode == "" {
163- self . write_plain ( & format ! ( "test {} ... " , name) ) ?;
164- } else {
161+ if let Some ( test_mode) = desc. test_mode ( ) {
165162 self . write_plain ( & format ! ( "test {} - {} ... " , name, test_mode) ) ?;
163+ } else {
164+ self . write_plain ( & format ! ( "test {} ... " , name) ) ?;
166165 }
167166
168167 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -145,32 +145,34 @@ impl TestDesc {
145145 }
146146 }
147147
148+ /// Returns None for ignored test or that that are just run, otherwise give a description of the type of test.
149+ /// Descriptions include "should panic", "compile fail" and "compile".
148150 #[ cfg( not( bootstrap) ) ]
149- pub fn test_mode ( & self ) -> & ' static str {
151+ pub fn test_mode ( & self ) -> Option < & ' static str > {
150152 if self . ignore {
151- return & "" ;
153+ return None ;
152154 }
153155 match self . should_panic {
154156 options:: ShouldPanic :: Yes | options:: ShouldPanic :: YesWithMessage ( _) => {
155- return & "should panic" ;
157+ return Some ( "should panic" ) ;
156158 }
157159 options:: ShouldPanic :: No => { }
158160 }
159161 if self . allow_fail {
160- return & "allow fail" ;
162+ return Some ( "allow fail" ) ;
161163 }
162164 if self . compile_fail {
163- return & "compile fail" ;
165+ return Some ( "compile fail" ) ;
164166 }
165167 if self . no_run {
166- return & "compile" ;
168+ return Some ( "compile" ) ;
167169 }
168- & ""
170+ None
169171 }
170172
171173 #[ cfg( bootstrap) ]
172- pub fn test_mode ( & self ) -> & ' static str {
173- & ""
174+ pub fn test_mode ( & self ) -> Option < & ' static str > {
175+ None
174176 }
175177}
176178
You can’t perform that action at this time.
0 commit comments