@@ -176,7 +176,7 @@ fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions {
176176fn runtest ( test : & str , cratename : & str , cfgs : Vec < String > , libs : SearchPaths ,
177177 externs : core:: Externs ,
178178 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 ) {
180180 // the test harness wants its own `main` & top level functions, so
181181 // never wrap the test in `fn main() { ... }`
182182 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,
232232 None ,
233233 codemap. clone ( ) ) ;
234234 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 ( ) ) ) ;
236236
237237 // Compile the code
238238 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,
273273 } else if count == 0 && compile_fail == true {
274274 panic ! ( "test compiled while it wasn't supposed to" )
275275 }
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+ }
276280 }
277281 Ok ( ( ) ) if compile_fail => panic ! ( "test compiled while it wasn't supposed to" ) ,
278282 _ => { }
279283 }
280284 }
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) ;
283298 }
284299
285300 if no_run { return }
@@ -411,7 +426,7 @@ impl Collector {
411426
412427 pub fn add_test ( & mut self , test : String ,
413428 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 > ) {
415430 let name = if self . use_headers {
416431 let s = self . current_header . as_ref ( ) . map ( |s| & * * s) . unwrap_or ( "" ) ;
417432 format ! ( "{}_{}" , s, self . cnt)
@@ -442,6 +457,7 @@ impl Collector {
442457 no_run,
443458 as_test_harness,
444459 compile_fail,
460+ error_codes,
445461 & opts) ;
446462 } )
447463 } ) ;
0 commit comments