@@ -722,6 +722,16 @@ impl Execs {
722722 self
723723 }
724724
725+ pub fn enable_mac_dsym ( & mut self ) -> & mut Self {
726+ if cfg ! ( target_os = "macos" ) {
727+ self . env ( "CARGO_PROFILE_DEV_SPLIT_DEBUGINFO" , "packed" )
728+ . env ( "CARGO_PROFILE_TEST_SPLIT_DEBUGINFO" , "packed" )
729+ . env ( "CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO" , "packed" )
730+ . env ( "CARGO_PROFILE_BENCH_SPLIT_DEBUGINFO" , "packed" ) ;
731+ }
732+ self
733+ }
734+
725735 pub fn run ( & mut self ) {
726736 self . ran = true ;
727737 let p = ( & self . process_builder ) . clone ( ) . unwrap ( ) ;
@@ -788,13 +798,17 @@ impl Execs {
788798 match res {
789799 Ok ( out) => self . match_output ( & out) ,
790800 Err ( e) => {
791- let err = e. downcast_ref :: < ProcessError > ( ) ;
792- if let Some ( & ProcessError {
793- output : Some ( ref out) ,
801+ if let Some ( ProcessError {
802+ stdout : Some ( stdout) ,
803+ stderr : Some ( stderr) ,
804+ code,
794805 ..
795- } ) = err
806+ } ) = e . downcast_ref :: < ProcessError > ( )
796807 {
797- return self . match_output ( out) ;
808+ return self
809+ . match_status ( * code, stdout, stderr)
810+ . and ( self . match_stdout ( stdout, stderr) )
811+ . and ( self . match_stderr ( stdout, stderr) ) ;
798812 }
799813 Err ( format ! ( "could not exec process {}: {:?}" , process, e) )
800814 }
@@ -803,119 +817,91 @@ impl Execs {
803817
804818 fn match_output ( & self , actual : & Output ) -> MatchResult {
805819 self . verify_checks_output ( actual) ;
806- self . match_status ( actual)
807- . and ( self . match_stdout ( actual) )
808- . and ( self . match_stderr ( actual) )
820+ self . match_status ( actual. status . code ( ) , & actual . stdout , & actual . stderr )
821+ . and ( self . match_stdout ( & actual. stdout , & actual . stderr ) )
822+ . and ( self . match_stderr ( & actual. stdout , & actual . stderr ) )
809823 }
810824
811- fn match_status ( & self , actual : & Output ) -> MatchResult {
825+ fn match_status ( & self , code : Option < i32 > , stdout : & [ u8 ] , stderr : & [ u8 ] ) -> MatchResult {
812826 match self . expect_exit_code {
813827 None => Ok ( ( ) ) ,
814- Some ( code ) if actual . status . code ( ) == Some ( code ) => Ok ( ( ) ) ,
828+ Some ( expected ) if code == Some ( expected ) => Ok ( ( ) ) ,
815829 Some ( _) => Err ( format ! (
816- "exited with {}\n --- stdout\n {}\n --- stderr\n {}" ,
817- actual . status ,
818- String :: from_utf8_lossy( & actual . stdout) ,
819- String :: from_utf8_lossy( & actual . stderr)
830+ "exited with {:? }\n --- stdout\n {}\n --- stderr\n {}" ,
831+ code ,
832+ String :: from_utf8_lossy( & stdout) ,
833+ String :: from_utf8_lossy( & stderr)
820834 ) ) ,
821835 }
822836 }
823837
824- fn match_stdout ( & self , actual : & Output ) -> MatchResult {
838+ fn match_stdout ( & self , stdout : & [ u8 ] , stderr : & [ u8 ] ) -> MatchResult {
825839 self . match_std (
826840 self . expect_stdout . as_ref ( ) ,
827- & actual . stdout ,
841+ stdout,
828842 "stdout" ,
829- & actual . stderr ,
843+ stderr,
830844 MatchKind :: Exact ,
831845 ) ?;
832846 for expect in self . expect_stdout_contains . iter ( ) {
833- self . match_std (
834- Some ( expect) ,
835- & actual. stdout ,
836- "stdout" ,
837- & actual. stderr ,
838- MatchKind :: Partial ,
839- ) ?;
847+ self . match_std ( Some ( expect) , stdout, "stdout" , stderr, MatchKind :: Partial ) ?;
840848 }
841849 for expect in self . expect_stderr_contains . iter ( ) {
842- self . match_std (
843- Some ( expect) ,
844- & actual. stderr ,
845- "stderr" ,
846- & actual. stdout ,
847- MatchKind :: Partial ,
848- ) ?;
850+ self . match_std ( Some ( expect) , stderr, "stderr" , stdout, MatchKind :: Partial ) ?;
849851 }
850852 for & ( ref expect, number) in self . expect_stdout_contains_n . iter ( ) {
851853 self . match_std (
852854 Some ( expect) ,
853- & actual . stdout ,
855+ stdout,
854856 "stdout" ,
855- & actual . stderr ,
857+ stderr,
856858 MatchKind :: PartialN ( number) ,
857859 ) ?;
858860 }
859861 for expect in self . expect_stdout_not_contains . iter ( ) {
860862 self . match_std (
861863 Some ( expect) ,
862- & actual . stdout ,
864+ stdout,
863865 "stdout" ,
864- & actual . stderr ,
866+ stderr,
865867 MatchKind :: NotPresent ,
866868 ) ?;
867869 }
868870 for expect in self . expect_stderr_not_contains . iter ( ) {
869871 self . match_std (
870872 Some ( expect) ,
871- & actual . stderr ,
873+ stderr,
872874 "stderr" ,
873- & actual . stdout ,
875+ stdout,
874876 MatchKind :: NotPresent ,
875877 ) ?;
876878 }
877879 for expect in self . expect_stderr_unordered . iter ( ) {
878- self . match_std (
879- Some ( expect) ,
880- & actual. stderr ,
881- "stderr" ,
882- & actual. stdout ,
883- MatchKind :: Unordered ,
884- ) ?;
880+ self . match_std ( Some ( expect) , stderr, "stderr" , stdout, MatchKind :: Unordered ) ?;
885881 }
886882 for expect in self . expect_neither_contains . iter ( ) {
887883 self . match_std (
888884 Some ( expect) ,
889- & actual . stdout ,
885+ stdout,
890886 "stdout" ,
891- & actual . stdout ,
887+ stdout,
892888 MatchKind :: NotPresent ,
893889 ) ?;
894890
895891 self . match_std (
896892 Some ( expect) ,
897- & actual . stderr ,
893+ stderr,
898894 "stderr" ,
899- & actual . stderr ,
895+ stderr,
900896 MatchKind :: NotPresent ,
901897 ) ?;
902898 }
903899
904900 for expect in self . expect_either_contains . iter ( ) {
905- let match_std = self . match_std (
906- Some ( expect) ,
907- & actual. stdout ,
908- "stdout" ,
909- & actual. stdout ,
910- MatchKind :: Partial ,
911- ) ;
912- let match_err = self . match_std (
913- Some ( expect) ,
914- & actual. stderr ,
915- "stderr" ,
916- & actual. stderr ,
917- MatchKind :: Partial ,
918- ) ;
901+ let match_std =
902+ self . match_std ( Some ( expect) , stdout, "stdout" , stdout, MatchKind :: Partial ) ;
903+ let match_err =
904+ self . match_std ( Some ( expect) , stderr, "stderr" , stderr, MatchKind :: Partial ) ;
919905
920906 if let ( Err ( _) , Err ( _) ) = ( match_std, match_err) {
921907 return Err ( format ! (
@@ -928,12 +914,12 @@ impl Execs {
928914 }
929915
930916 for ( with, without) in self . expect_stderr_with_without . iter ( ) {
931- self . match_with_without ( & actual . stderr , with, without) ?;
917+ self . match_with_without ( stderr, with, without) ?;
932918 }
933919
934920 if let Some ( ref objects) = self . expect_json {
935- let stdout = str :: from_utf8 ( & actual . stdout )
936- . map_err ( |_| "stdout was not utf8 encoded" . to_owned ( ) ) ?;
921+ let stdout =
922+ str :: from_utf8 ( stdout ) . map_err ( |_| "stdout was not utf8 encoded" . to_owned ( ) ) ?;
937923 let lines = stdout
938924 . lines ( )
939925 . filter ( |line| line. starts_with ( '{' ) )
@@ -952,8 +938,8 @@ impl Execs {
952938 }
953939
954940 if !self . expect_json_contains_unordered . is_empty ( ) {
955- let stdout = str :: from_utf8 ( & actual . stdout )
956- . map_err ( |_| "stdout was not utf8 encoded" . to_owned ( ) ) ?;
941+ let stdout =
942+ str :: from_utf8 ( stdout ) . map_err ( |_| "stdout was not utf8 encoded" . to_owned ( ) ) ?;
957943 let mut lines = stdout
958944 . lines ( )
959945 . filter ( |line| line. starts_with ( '{' ) )
@@ -980,12 +966,12 @@ impl Execs {
980966 Ok ( ( ) )
981967 }
982968
983- fn match_stderr ( & self , actual : & Output ) -> MatchResult {
969+ fn match_stderr ( & self , stdout : & [ u8 ] , stderr : & [ u8 ] ) -> MatchResult {
984970 self . match_std (
985971 self . expect_stderr . as_ref ( ) ,
986- & actual . stderr ,
972+ stderr,
987973 "stderr" ,
988- & actual . stdout ,
974+ stdout,
989975 MatchKind :: Exact ,
990976 )
991977 }
0 commit comments