File tree 3 files changed +17
-17
lines changed
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> {
169
169
170
170
fn write_test_name ( & mut self , desc : & TestDesc ) -> io:: Result < ( ) > {
171
171
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 ( ) {
176
173
self . write_plain ( & format ! ( "test {} - {} ... " , name, test_mode) ) ?;
174
+ } else {
175
+ self . write_plain ( & format ! ( "test {} ... " , name) ) ?;
177
176
}
178
177
179
178
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -158,11 +158,10 @@ impl<T: Write> TerseFormatter<T> {
158
158
159
159
fn write_test_name ( & mut self , desc : & TestDesc ) -> io:: Result < ( ) > {
160
160
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 ( ) {
165
162
self . write_plain ( & format ! ( "test {} - {} ... " , name, test_mode) ) ?;
163
+ } else {
164
+ self . write_plain ( & format ! ( "test {} ... " , name) ) ?;
166
165
}
167
166
168
167
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -145,32 +145,34 @@ impl TestDesc {
145
145
}
146
146
}
147
147
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".
148
150
#[ cfg( not( bootstrap) ) ]
149
- pub fn test_mode ( & self ) -> & ' static str {
151
+ pub fn test_mode ( & self ) -> Option < & ' static str > {
150
152
if self . ignore {
151
- return & "" ;
153
+ return None ;
152
154
}
153
155
match self . should_panic {
154
156
options:: ShouldPanic :: Yes | options:: ShouldPanic :: YesWithMessage ( _) => {
155
- return & "should panic" ;
157
+ return Some ( "should panic" ) ;
156
158
}
157
159
options:: ShouldPanic :: No => { }
158
160
}
159
161
if self . allow_fail {
160
- return & "allow fail" ;
162
+ return Some ( "allow fail" ) ;
161
163
}
162
164
if self . compile_fail {
163
- return & "compile fail" ;
165
+ return Some ( "compile fail" ) ;
164
166
}
165
167
if self . no_run {
166
- return & "compile" ;
168
+ return Some ( "compile" ) ;
167
169
}
168
- & ""
170
+ None
169
171
}
170
172
171
173
#[ cfg( bootstrap) ]
172
- pub fn test_mode ( & self ) -> & ' static str {
173
- & ""
174
+ pub fn test_mode ( & self ) -> Option < & ' static str > {
175
+ None
174
176
}
175
177
}
176
178
You can’t perform that action at this time.
0 commit comments