@@ -232,40 +232,42 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
232232 ..config:: basic_options ( ) . clone ( )
233233 } ;
234234
235- let ( libdir, outdir) = driver:: spawn_thread_pool ( sessopts, |sessopts| {
236- // Shuffle around a few input and output handles here. We're going to pass
237- // an explicit handle into rustc to collect output messages, but we also
238- // want to catch the error message that rustc prints when it fails.
239- //
240- // We take our thread-local stderr (likely set by the test runner) and replace
241- // it with a sink that is also passed to rustc itself. When this function
242- // returns the output of the sink is copied onto the output of our own thread.
243- //
244- // The basic idea is to not use a default Handler for rustc, and then also
245- // not print things by default to the actual stderr.
246- struct Sink ( Arc < Mutex < Vec < u8 > > > ) ;
247- impl Write for Sink {
248- fn write ( & mut self , data : & [ u8 ] ) -> io:: Result < usize > {
249- Write :: write ( & mut * self . 0 . lock ( ) . unwrap ( ) , data)
250- }
251- fn flush ( & mut self ) -> io:: Result < ( ) > { Ok ( ( ) ) }
235+ // Shuffle around a few input and output handles here. We're going to pass
236+ // an explicit handle into rustc to collect output messages, but we also
237+ // want to catch the error message that rustc prints when it fails.
238+ //
239+ // We take our thread-local stderr (likely set by the test runner) and replace
240+ // it with a sink that is also passed to rustc itself. When this function
241+ // returns the output of the sink is copied onto the output of our own thread.
242+ //
243+ // The basic idea is to not use a default Handler for rustc, and then also
244+ // not print things by default to the actual stderr.
245+ struct Sink ( Arc < Mutex < Vec < u8 > > > ) ;
246+ impl Write for Sink {
247+ fn write ( & mut self , data : & [ u8 ] ) -> io:: Result < usize > {
248+ Write :: write ( & mut * self . 0 . lock ( ) . unwrap ( ) , data)
252249 }
253- struct Bomb ( Arc < Mutex < Vec < u8 > > > , Box < Write +Send > ) ;
254- impl Drop for Bomb {
255- fn drop ( & mut self ) {
256- let _ = self . 1 . write_all ( & self . 0 . lock ( ) . unwrap ( ) ) ;
257- }
250+ fn flush ( & mut self ) -> io:: Result < ( ) > { Ok ( ( ) ) }
251+ }
252+ struct Bomb ( Arc < Mutex < Vec < u8 > > > , Box < Write +Send > ) ;
253+ impl Drop for Bomb {
254+ fn drop ( & mut self ) {
255+ let _ = self . 1 . write_all ( & self . 0 . lock ( ) . unwrap ( ) ) ;
258256 }
259- let data = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ;
257+ }
258+ let data = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ;
259+
260+ let old = io:: set_panic ( Some ( box Sink ( data. clone ( ) ) ) ) ;
261+ let _bomb = Bomb ( data. clone ( ) , old. unwrap_or ( box io:: stdout ( ) ) ) ;
262+
263+ let ( libdir, outdir, compile_result) = driver:: spawn_thread_pool ( sessopts, |sessopts| {
260264 let codemap = Lrc :: new ( CodeMap :: new_doctest (
261265 sessopts. file_path_mapping ( ) , filename. clone ( ) , line as isize - line_offset as isize
262266 ) ) ;
263267 let emitter = errors:: emitter:: EmitterWriter :: new ( box Sink ( data. clone ( ) ) ,
264268 Some ( codemap. clone ( ) ) ,
265269 false ,
266270 false ) ;
267- let old = io:: set_panic ( Some ( box Sink ( data. clone ( ) ) ) ) ;
268- let _bomb = Bomb ( data. clone ( ) , old. unwrap_or ( box io:: stdout ( ) ) ) ;
269271
270272 // Compile the code
271273 let diagnostic_handler = errors:: Handler :: with_emitter ( true , false , box emitter) ;
@@ -310,28 +312,28 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
310312 Err ( _) | Ok ( Err ( CompileIncomplete :: Errored ( _) ) ) => Err ( ( ) )
311313 } ;
312314
313- match ( compile_result, compile_fail) {
314- ( Ok ( ( ) ) , true ) => {
315- panic ! ( "test compiled while it wasn't supposed to" )
316- }
317- ( Ok ( ( ) ) , false ) => { }
318- ( Err ( ( ) ) , true ) => {
319- if error_codes. len ( ) > 0 {
320- let out = String :: from_utf8 ( data. lock ( ) . unwrap ( ) . to_vec ( ) ) . unwrap ( ) ;
321- error_codes. retain ( |err| !out. contains ( err) ) ;
322- }
323- }
324- ( Err ( ( ) ) , false ) => {
325- panic ! ( "couldn't compile the test" )
315+ ( libdir, outdir, compile_result)
316+ } ) ;
317+
318+ match ( compile_result, compile_fail) {
319+ ( Ok ( ( ) ) , true ) => {
320+ panic ! ( "test compiled while it wasn't supposed to" )
321+ }
322+ ( Ok ( ( ) ) , false ) => { }
323+ ( Err ( ( ) ) , true ) => {
324+ if error_codes. len ( ) > 0 {
325+ let out = String :: from_utf8 ( data. lock ( ) . unwrap ( ) . to_vec ( ) ) . unwrap ( ) ;
326+ error_codes. retain ( |err| !out. contains ( err) ) ;
326327 }
327328 }
328-
329- if error_codes. len ( ) > 0 {
330- panic ! ( "Some expected error codes were not found: {:?}" , error_codes) ;
329+ ( Err ( ( ) ) , false ) => {
330+ panic ! ( "couldn't compile the test" )
331331 }
332+ }
332333
333- ( libdir, outdir)
334- } ) ;
334+ if error_codes. len ( ) > 0 {
335+ panic ! ( "Some expected error codes were not found: {:?}" , error_codes) ;
336+ }
335337
336338 if no_run { return }
337339
@@ -546,7 +548,7 @@ impl Collector {
546548 debug ! ( "Creating test {}: {}" , name, test) ;
547549 self . tests . push ( testing:: TestDescAndFn {
548550 desc : testing:: TestDesc {
549- name : testing:: DynTestName ( name) ,
551+ name : testing:: DynTestName ( name. clone ( ) ) ,
550552 ignore : should_ignore,
551553 // compiler failures are test failures
552554 should_panic : testing:: ShouldPanic :: No ,
@@ -556,7 +558,7 @@ impl Collector {
556558 let panic = io:: set_panic ( None ) ;
557559 let print = io:: set_print ( None ) ;
558560 match {
559- rustc_driver:: in_rustc_thread ( move || with_globals ( move || {
561+ rustc_driver:: in_named_rustc_thread ( name , move || with_globals ( move || {
560562 io:: set_panic ( panic) ;
561563 io:: set_print ( print) ;
562564 run_test ( & test,
0 commit comments