@@ -140,30 +140,22 @@ fn run_tests(&test_opts opts, &test_desc[] tests) -> bool {
140
140
ret true;
141
141
142
142
fn write_ok( & io:: writer out) {
143
- if ( term:: color_supported( ) ) {
144
- term:: fg( out. get_buf_writer( ) , term:: color_green) ;
145
- }
146
- out. write_str( "ok" ) ;
147
- if ( term:: color_supported( ) ) {
148
- term:: reset( out. get_buf_writer( ) ) ;
149
- }
143
+ write_pretty( out, "ok" , term:: color_green) ;
150
144
}
151
145
152
146
fn write_failed( & io:: writer out) {
153
- if ( term:: color_supported( ) ) {
154
- term:: fg( out. get_buf_writer( ) , term:: color_red) ;
155
- }
156
- out. write_str( "FAILED" ) ;
157
- if ( term:: color_supported( ) ) {
158
- term:: reset( out. get_buf_writer( ) ) ;
159
- }
147
+ write_pretty( out, "FAILED" , term:: color_red) ;
160
148
}
161
149
162
150
fn write_ignored( & io:: writer out) {
151
+ write_pretty( out, "ignored" , term:: color_yellow) ;
152
+ }
153
+
154
+ fn write_pretty( & io:: writer out, & str word, u8 color) {
163
155
if ( term:: color_supported( ) ) {
164
- term:: fg( out. get_buf_writer( ) , term :: color_yellow ) ;
156
+ term:: fg( out. get_buf_writer( ) , color ) ;
165
157
}
166
- out. write_str( "ignored" ) ;
158
+ out. write_str( word ) ;
167
159
if ( term:: color_supported( ) ) {
168
160
term:: reset( out. get_buf_writer( ) ) ;
169
161
}
0 commit comments