@@ -623,12 +623,10 @@ pub fn cargo_exe() -> PathBuf {
623623/// does not have access to the raw `ExitStatus` because `ProcessError` needs
624624/// to be serializable (for the Rustc cache), and `ExitStatus` does not
625625/// provide a constructor.
626- struct RawOutput {
627- #[ allow( dead_code) ]
628- code : Option < i32 > ,
629- stdout : Vec < u8 > ,
630- #[ allow( dead_code) ]
631- stderr : Vec < u8 > ,
626+ pub struct RawOutput {
627+ pub code : Option < i32 > ,
628+ pub stdout : Vec < u8 > ,
629+ pub stderr : Vec < u8 > ,
632630}
633631
634632/// Run and verify a [`ProcessBuilder`]
@@ -1042,34 +1040,32 @@ impl Execs {
10421040 }
10431041
10441042 #[ track_caller]
1045- pub fn run ( & mut self ) {
1043+ pub fn run ( & mut self ) -> RawOutput {
10461044 self . ran = true ;
10471045 let mut p = ( & self . process_builder ) . clone ( ) . unwrap ( ) ;
10481046 if let Some ( stdin) = self . expect_stdin . take ( ) {
10491047 p. stdin ( stdin) ;
10501048 }
1051- if let Err ( e) = self . match_process ( & p) {
1052- panic_error ( & format ! ( "test failed running {}" , p) , e) ;
1049+
1050+ match self . match_process ( & p) {
1051+ Err ( e) => panic_error ( & format ! ( "test failed running {}" , p) , e) ,
1052+ Ok ( output) => output,
10531053 }
10541054 }
10551055
10561056 /// Runs the process, checks the expected output, and returns the first
10571057 /// JSON object on stdout.
10581058 #[ track_caller]
10591059 pub fn run_json ( & mut self ) -> serde_json:: Value {
1060- self . ran = true ;
1061- let p = ( & self . process_builder ) . clone ( ) . unwrap ( ) ;
1062- match self . match_process ( & p) {
1063- Err ( e) => panic_error ( & format ! ( "test failed running {}" , p) , e) ,
1064- Ok ( output) => serde_json:: from_slice ( & output. stdout ) . unwrap_or_else ( |e| {
1065- panic ! (
1066- "\n failed to parse JSON: {}\n \
1060+ let output = self . run ( ) ;
1061+ serde_json:: from_slice ( & output. stdout ) . unwrap_or_else ( |e| {
1062+ panic ! (
1063+ "\n failed to parse JSON: {}\n \
10671064 output was:\n {}\n ",
1068- e,
1069- String :: from_utf8_lossy( & output. stdout)
1070- ) ;
1071- } ) ,
1072- }
1065+ e,
1066+ String :: from_utf8_lossy( & output. stdout)
1067+ ) ;
1068+ } )
10731069 }
10741070
10751071 #[ track_caller]
0 commit comments