@@ -161,13 +161,15 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
161
161
externs : Externs ,
162
162
should_panic : bool , no_run : bool , as_test_harness : bool ,
163
163
compile_fail : bool , mut error_codes : Vec < String > , opts : & TestOptions ,
164
- maybe_sysroot : Option < PathBuf > ) {
164
+ maybe_sysroot : Option < PathBuf > ,
165
+ original : & str ) {
165
166
// the test harness wants its own `main` & top level functions, so
166
167
// never wrap the test in `fn main() { ... }`
167
- let test = maketest ( test, Some ( cratename) , as_test_harness, opts) ;
168
+ let new_test = maketest ( test, Some ( cratename) , as_test_harness, opts) ;
169
+ let test = format ! ( "```{}\n {}\n ```\n " , original, test) ;
168
170
let input = config:: Input :: Str {
169
171
name : driver:: anon_src ( ) ,
170
- input : test . to_owned ( ) ,
172
+ input : new_test . to_owned ( ) ,
171
173
} ;
172
174
let outputs = OutputTypes :: new ( & [ ( OutputType :: Exe , None ) ] ) ;
173
175
@@ -249,20 +251,22 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
249
251
if count > 0 && !compile_fail {
250
252
sess. fatal ( "aborting due to previous error(s)" )
251
253
} else if count == 0 && compile_fail {
252
- panic ! ( "test compiled while it wasn't supposed to" )
254
+ panic ! ( "test compiled while it wasn't supposed to: \n \n {} \n " , test )
253
255
}
254
256
if count > 0 && error_codes. len ( ) > 0 {
255
257
let out = String :: from_utf8 ( data. lock ( ) . unwrap ( ) . to_vec ( ) ) . unwrap ( ) ;
256
258
error_codes. retain ( |err| !out. contains ( err) ) ;
257
259
}
258
260
}
259
- Ok ( ( ) ) if compile_fail => panic ! ( "test compiled while it wasn't supposed to" ) ,
261
+ Ok ( ( ) ) if compile_fail => {
262
+ panic ! ( "test compiled while it wasn't supposed to:\n \n {}\n " , test)
263
+ }
260
264
_ => { }
261
265
}
262
266
}
263
267
Err ( _) => {
264
268
if !compile_fail {
265
- panic ! ( "couldn't compile the test" ) ;
269
+ panic ! ( "couldn't compile the test: \n \n {} \n " , test ) ;
266
270
}
267
271
if error_codes. len ( ) > 0 {
268
272
let out = String :: from_utf8 ( data. lock ( ) . unwrap ( ) . to_vec ( ) ) . unwrap ( ) ;
@@ -272,7 +276,7 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
272
276
}
273
277
274
278
if error_codes. len ( ) > 0 {
275
- panic ! ( "Some expected error codes were not found: {:?}" , error_codes) ;
279
+ panic ! ( "Some expected error codes were not found: {:?}\n \n {} \n " , error_codes, test ) ;
276
280
}
277
281
278
282
if no_run { return }
@@ -294,17 +298,18 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
294
298
cmd. env ( var, & newpath) ;
295
299
296
300
match cmd. output ( ) {
297
- Err ( e) => panic ! ( "couldn't run the test: {}{}" , e,
301
+ Err ( e) => panic ! ( "couldn't run the test: {}{}\n \n {} \n " , e,
298
302
if e. kind( ) == io:: ErrorKind :: PermissionDenied {
299
303
" - maybe your tempdir is mounted with noexec?"
300
- } else { "" } ) ,
304
+ } else { "" } , test ) ,
301
305
Ok ( out) => {
302
306
if should_panic && out. status . success ( ) {
303
- panic ! ( "test executable succeeded when it should have failed" ) ;
307
+ panic ! ( "test executable succeeded when it should have failed\n \n {} \n " , test ) ;
304
308
} else if !should_panic && !out. status . success ( ) {
305
- panic ! ( "test executable failed:\n {}\n {}" ,
309
+ panic ! ( "test executable failed:\n {}\n {}\n \n {} \n " ,
306
310
str :: from_utf8( & out. stdout) . unwrap_or( "" ) ,
307
- str :: from_utf8( & out. stderr) . unwrap_or( "" ) ) ;
311
+ str :: from_utf8( & out. stderr) . unwrap_or( "" ) ,
312
+ test) ;
308
313
}
309
314
}
310
315
}
@@ -406,7 +411,8 @@ impl Collector {
406
411
407
412
pub fn add_test ( & mut self , test : String ,
408
413
should_panic : bool , no_run : bool , should_ignore : bool ,
409
- as_test_harness : bool , compile_fail : bool , error_codes : Vec < String > ) {
414
+ as_test_harness : bool , compile_fail : bool , error_codes : Vec < String > ,
415
+ original : String ) {
410
416
let name = if self . use_headers {
411
417
let s = self . current_header . as_ref ( ) . map ( |s| & * * s) . unwrap_or ( "" ) ;
412
418
format ! ( "{}_{}" , s, self . cnt)
@@ -446,7 +452,8 @@ impl Collector {
446
452
compile_fail,
447
453
error_codes,
448
454
& opts,
449
- maybe_sysroot)
455
+ maybe_sysroot,
456
+ & original)
450
457
} )
451
458
} {
452
459
Ok ( ( ) ) => ( ) ,
0 commit comments