@@ -623,12 +623,10 @@ pub fn cargo_exe() -> PathBuf {
623
623
/// does not have access to the raw `ExitStatus` because `ProcessError` needs
624
624
/// to be serializable (for the Rustc cache), and `ExitStatus` does not
625
625
/// 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 > ,
632
630
}
633
631
634
632
/// Run and verify a [`ProcessBuilder`]
@@ -1042,34 +1040,32 @@ impl Execs {
1042
1040
}
1043
1041
1044
1042
#[ track_caller]
1045
- pub fn run ( & mut self ) {
1043
+ pub fn run ( & mut self ) -> RawOutput {
1046
1044
self . ran = true ;
1047
1045
let mut p = ( & self . process_builder ) . clone ( ) . unwrap ( ) ;
1048
1046
if let Some ( stdin) = self . expect_stdin . take ( ) {
1049
1047
p. stdin ( stdin) ;
1050
1048
}
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,
1053
1053
}
1054
1054
}
1055
1055
1056
1056
/// Runs the process, checks the expected output, and returns the first
1057
1057
/// JSON object on stdout.
1058
1058
#[ track_caller]
1059
1059
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 \
1067
1064
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
+ } )
1073
1069
}
1074
1070
1075
1071
#[ track_caller]
0 commit comments