@@ -56,7 +56,7 @@ use std::io::prelude::*;
56
56
use std:: panic:: { self , catch_unwind, AssertUnwindSafe , PanicInfo } ;
57
57
use std:: path:: PathBuf ;
58
58
use std:: process;
59
- use std:: process:: { Command , Termination } ;
59
+ use std:: process:: { ExitStatus , Command , Termination } ;
60
60
use std:: sync:: mpsc:: { channel, Sender } ;
61
61
use std:: sync:: { Arc , Mutex } ;
62
62
use std:: thread;
@@ -1613,10 +1613,11 @@ fn spawn_test_subprocess(desc: TestDesc, monitor_ch: Sender<MonitorMsg>) {
1613
1613
1614
1614
let std:: process:: Output { stdout, stderr, status } = output;
1615
1615
let mut test_output = stdout;
1616
+ formatters:: write_stderr_delimiter ( & mut test_output, & desc. name ) ;
1616
1617
test_output. extend_from_slice ( & stderr) ;
1617
1618
1618
1619
let result = match ( move || {
1619
- let exit_code = status . code ( ) . ok_or ( "child process was terminated" ) ?;
1620
+ let exit_code = get_exit_code ( status ) ?;
1620
1621
TestResult :: try_from ( exit_code) . map_err ( |_| {
1621
1622
format ! ( "child process returned unexpected exit code {}" , exit_code)
1622
1623
} )
@@ -1664,6 +1665,23 @@ fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box<dyn FnOnce() + Sen
1664
1665
unreachable ! ( "panic=abort callback should have exited the process" )
1665
1666
}
1666
1667
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
+
1667
1685
#[ derive( Clone , PartialEq ) ]
1668
1686
pub struct MetricMap ( BTreeMap < String , Metric > ) ;
1669
1687
0 commit comments