@@ -56,7 +56,7 @@ use std::io::prelude::*;
5656use std:: panic:: { self , catch_unwind, AssertUnwindSafe , PanicInfo } ;
5757use std:: path:: PathBuf ;
5858use std:: process;
59- use std:: process:: { Command , Termination } ;
59+ use std:: process:: { ExitStatus , Command , Termination } ;
6060use std:: sync:: mpsc:: { channel, Sender } ;
6161use std:: sync:: { Arc , Mutex } ;
6262use std:: thread;
@@ -1613,10 +1613,11 @@ fn spawn_test_subprocess(desc: TestDesc, monitor_ch: Sender<MonitorMsg>) {
16131613
16141614 let std:: process:: Output { stdout, stderr, status } = output;
16151615 let mut test_output = stdout;
1616+ formatters:: write_stderr_delimiter ( & mut test_output, & desc. name ) ;
16161617 test_output. extend_from_slice ( & stderr) ;
16171618
16181619 let result = match ( move || {
1619- let exit_code = status . code ( ) . ok_or ( "child process was terminated" ) ?;
1620+ let exit_code = get_exit_code ( status ) ?;
16201621 TestResult :: try_from ( exit_code) . map_err ( |_| {
16211622 format ! ( "child process returned unexpected exit code {}" , exit_code)
16221623 } )
@@ -1664,6 +1665,23 @@ fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box<dyn FnOnce() + Sen
16641665 unreachable ! ( "panic=abort callback should have exited the process" )
16651666}
16661667
1668+ #[ cfg( not( unix) ) ]
1669+ fn get_exit_code ( status : ExitStatus ) -> Result < i32 , String > {
1670+ status. code ( ) . ok_or ( "received no exit code from child process" . into ( ) )
1671+ }
1672+
1673+ #[ cfg( unix) ]
1674+ fn get_exit_code ( status : ExitStatus ) -> Result < i32 , String > {
1675+ use std:: os:: unix:: process:: ExitStatusExt ;
1676+ match status. code ( ) {
1677+ Some ( code) => Ok ( code) ,
1678+ None => match status. signal ( ) {
1679+ Some ( signal) => Err ( format ! ( "child process exited with signal {}" , signal) ) ,
1680+ None => Err ( "child process exited with unknown signal" . into ( ) ) ,
1681+ }
1682+ }
1683+ }
1684+
16671685#[ derive( Clone , PartialEq ) ]
16681686pub struct MetricMap ( BTreeMap < String , Metric > ) ;
16691687
0 commit comments