@@ -176,7 +176,7 @@ fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions {
176
176
fn runtest ( test : & str , cratename : & str , cfgs : Vec < String > , libs : SearchPaths ,
177
177
externs : core:: Externs ,
178
178
should_panic : bool , no_run : bool , as_test_harness : bool ,
179
- compile_fail : bool , opts : & TestOptions ) {
179
+ compile_fail : bool , mut error_codes : Vec < String > , opts : & TestOptions ) {
180
180
// the test harness wants its own `main` & top level functions, so
181
181
// never wrap the test in `fn main() { ... }`
182
182
let test = maketest ( test, Some ( cratename) , as_test_harness, opts) ;
@@ -232,7 +232,7 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
232
232
None ,
233
233
codemap. clone ( ) ) ;
234
234
let old = io:: set_panic ( box Sink ( data. clone ( ) ) ) ;
235
- let _bomb = Bomb ( data, old. unwrap_or ( box io:: stdout ( ) ) ) ;
235
+ let _bomb = Bomb ( data. clone ( ) , old. unwrap_or ( box io:: stdout ( ) ) ) ;
236
236
237
237
// Compile the code
238
238
let diagnostic_handler = errors:: Handler :: with_emitter ( true , false , box emitter) ;
@@ -273,13 +273,28 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
273
273
} else if count == 0 && compile_fail == true {
274
274
panic ! ( "test compiled while it wasn't supposed to" )
275
275
}
276
+ if count > 0 && error_codes. len ( ) > 0 {
277
+ let out = String :: from_utf8 ( data. lock ( ) . unwrap ( ) . to_vec ( ) ) . unwrap ( ) ;
278
+ error_codes = error_codes. into_iter ( ) . filter ( |err| !out. contains ( err) ) . collect ( ) ;
279
+ }
276
280
}
277
281
Ok ( ( ) ) if compile_fail => panic ! ( "test compiled while it wasn't supposed to" ) ,
278
282
_ => { }
279
283
}
280
284
}
281
- Err ( _) if compile_fail == false => panic ! ( "couldn't compile the test" ) ,
282
- _ => { }
285
+ Err ( _) => {
286
+ if compile_fail == false {
287
+ panic ! ( "couldn't compile the test" ) ;
288
+ }
289
+ if error_codes. len ( ) > 0 {
290
+ let out = String :: from_utf8 ( data. lock ( ) . unwrap ( ) . to_vec ( ) ) . unwrap ( ) ;
291
+ error_codes. retain ( |err| !out. contains ( err) ) ;
292
+ }
293
+ }
294
+ }
295
+
296
+ if error_codes. len ( ) > 0 {
297
+ panic ! ( "Some expected error codes were not found: {:?}" , error_codes) ;
283
298
}
284
299
285
300
if no_run { return }
@@ -411,7 +426,7 @@ impl Collector {
411
426
412
427
pub fn add_test ( & mut self , test : String ,
413
428
should_panic : bool , no_run : bool , should_ignore : bool ,
414
- as_test_harness : bool , compile_fail : bool ) {
429
+ as_test_harness : bool , compile_fail : bool , error_codes : Vec < String > ) {
415
430
let name = if self . use_headers {
416
431
let s = self . current_header . as_ref ( ) . map ( |s| & * * s) . unwrap_or ( "" ) ;
417
432
format ! ( "{}_{}" , s, self . cnt)
@@ -442,6 +457,7 @@ impl Collector {
442
457
no_run,
443
458
as_test_harness,
444
459
compile_fail,
460
+ error_codes,
445
461
& opts) ;
446
462
} )
447
463
} ) ;
0 commit comments