@@ -21,7 +21,7 @@ use std::collections::{HashSet, VecDeque};
21
21
use std:: ffi:: OsString ;
22
22
use std:: num:: NonZeroUsize ;
23
23
use std:: path:: { Component , Path , PathBuf , Prefix } ;
24
- use std:: process:: { Command , ExitStatus , Output } ;
24
+ use std:: process:: { Command , Output } ;
25
25
use std:: thread;
26
26
use test_result:: { Errored , TestOk , TestResult , TestRun } ;
27
27
@@ -602,7 +602,7 @@ impl dyn TestStatus {
602
602
cmd. stdin ( std:: fs:: File :: open ( stdin) . unwrap ( ) ) ;
603
603
}
604
604
605
- let ( cmd, status , stderr , stdout ) = run_command ( cmd) ?;
605
+ let ( cmd, output ) = run_command ( cmd) ?;
606
606
607
607
let mode = comments. mode ( revision) ?;
608
608
let cmd = check_test_result (
@@ -615,35 +615,29 @@ impl dyn TestStatus {
615
615
& config,
616
616
revision,
617
617
comments,
618
- status,
619
- & stdout,
620
- & stderr,
618
+ & output,
621
619
) ?;
622
620
623
621
if let Mode :: Run { .. } = * mode {
624
622
return run_test_binary ( mode, path, revision, comments, cmd, & config) ;
625
623
}
626
624
627
625
run_rustfix (
628
- & stderr , & stdout , path, comments, revision, & config, * mode, extra_args,
626
+ & output , path, comments, revision, & config, * mode, extra_args,
629
627
) ?;
630
628
Ok ( TestOk :: Ok )
631
629
}
632
630
}
633
631
634
- fn run_command ( mut cmd : Command ) -> Result < ( Command , ExitStatus , Vec < u8 > , Vec < u8 > ) , Errored > {
632
+ fn run_command ( mut cmd : Command ) -> Result < ( Command , Output ) , Errored > {
635
633
match cmd. output ( ) {
636
634
Err ( err) => Err ( Errored {
637
635
errors : vec ! [ ] ,
638
636
stderr : err. to_string ( ) . into_bytes ( ) ,
639
637
stdout : format ! ( "could not spawn `{:?}` as a process" , cmd. get_program( ) ) . into_bytes ( ) ,
640
638
command : cmd,
641
639
} ) ,
642
- Ok ( Output {
643
- status,
644
- stdout,
645
- stderr,
646
- } ) => Ok ( ( cmd, status, stderr, stdout) ) ,
640
+ Ok ( output) => Ok ( ( cmd, output) ) ,
647
641
}
648
642
}
649
643
@@ -764,8 +758,7 @@ fn run_test_binary(
764
758
}
765
759
766
760
fn run_rustfix (
767
- stderr : & [ u8 ] ,
768
- stdout : & [ u8 ] ,
761
+ output : & Output ,
769
762
path : & Path ,
770
763
comments : & Comments ,
771
764
revision : & str ,
@@ -786,7 +779,7 @@ fn run_rustfix(
786
779
let fixed_code = ( no_run_rustfix. is_none ( ) && global_rustfix. enabled ( ) )
787
780
. then_some ( ( ) )
788
781
. and_then ( |( ) | {
789
- let suggestions = std:: str:: from_utf8 ( stderr)
782
+ let suggestions = std:: str:: from_utf8 ( & output . stderr )
790
783
. unwrap ( )
791
784
. lines ( )
792
785
. flat_map ( |line| {
@@ -828,8 +821,8 @@ fn run_rustfix(
828
821
. map_err ( |err| Errored {
829
822
command : Command :: new ( format ! ( "rustfix {}" , path. display( ) ) ) ,
830
823
errors : vec ! [ Error :: Rustfix ( err) ] ,
831
- stderr : stderr. into ( ) ,
832
- stdout : stdout. into ( ) ,
824
+ stderr : output . stderr . clone ( ) ,
825
+ stdout : output . stdout . clone ( ) ,
833
826
} ) ?;
834
827
835
828
let edition = comments. edition ( revision) ?. into ( ) ;
@@ -936,12 +929,14 @@ fn check_test_result(
936
929
config : & Config ,
937
930
revision : & str ,
938
931
comments : & Comments ,
939
- status : ExitStatus ,
940
- stdout : & [ u8 ] ,
941
- stderr : & [ u8 ] ,
932
+ Output {
933
+ status,
934
+ stdout,
935
+ stderr,
936
+ } : & Output ,
942
937
) -> Result < Command , Errored > {
943
938
let mut errors = vec ! [ ] ;
944
- errors. extend ( mode. ok ( status) . err ( ) ) ;
939
+ errors. extend ( mode. ok ( * status) . err ( ) ) ;
945
940
// Always remove annotation comments from stderr.
946
941
let diagnostics = rustc_stderr:: process ( path, stderr) ;
947
942
check_test_output (
@@ -969,7 +964,7 @@ fn check_test_result(
969
964
command,
970
965
errors,
971
966
stderr : diagnostics. rendered ,
972
- stdout : stdout. into ( ) ,
967
+ stdout : stdout. clone ( ) ,
973
968
} )
974
969
}
975
970
}
0 commit comments