@@ -610,11 +610,11 @@ fn run_test(build_manager: &BuildManager<'_>, mut config: TestConfig<'_>) -> Tes
610
610
) ?;
611
611
612
612
if let Mode :: Run { .. } = * mode {
613
- return run_test_binary ( mode, cmd, & config) ;
613
+ run_test_binary ( mode, cmd, config)
614
+ } else {
615
+ run_rustfix ( output, config, * mode, extra_args) ?;
616
+ Ok ( TestOk :: Ok )
614
617
}
615
-
616
- run_rustfix ( output, & config, * mode, extra_args) ?;
617
- Ok ( TestOk :: Ok )
618
618
}
619
619
620
620
fn run_command ( mut cmd : Command ) -> Result < ( Command , Output ) , Errored > {
@@ -689,8 +689,14 @@ fn build_aux_files(
689
689
Ok ( extra_args)
690
690
}
691
691
692
- fn run_test_binary ( mode : Spanned < Mode > , mut cmd : Command , config : & TestConfig ) -> TestResult {
692
+ fn run_test_binary ( mode : Spanned < Mode > , mut cmd : Command , config : TestConfig ) -> TestResult {
693
693
let revision = config. extension ( "run" ) ;
694
+ let config = TestConfig {
695
+ config : config. config ,
696
+ revision : & revision,
697
+ comments : config. comments ,
698
+ path : config. path ,
699
+ } ;
694
700
cmd. arg ( "--print" ) . arg ( "file-names" ) ;
695
701
let output = cmd. output ( ) . unwrap ( ) ;
696
702
assert ! ( output. status. success( ) ) ;
@@ -711,15 +717,7 @@ fn run_test_binary(mode: Spanned<Mode>, mut cmd: Command, config: &TestConfig) -
711
717
712
718
let mut errors = vec ! [ ] ;
713
719
714
- check_test_output (
715
- config. path ,
716
- & mut errors,
717
- & revision,
718
- & config. config ,
719
- config. comments ,
720
- & output. stdout ,
721
- & output. stderr ,
722
- ) ;
720
+ check_test_output ( & mut errors, & config, & output. stdout , & output. stderr ) ;
723
721
724
722
errors. extend ( mode. ok ( output. status ) . err ( ) ) ;
725
723
if errors. is_empty ( ) {
@@ -736,7 +734,7 @@ fn run_test_binary(mode: Spanned<Mode>, mut cmd: Command, config: &TestConfig) -
736
734
737
735
fn run_rustfix (
738
736
output : Output ,
739
- config : & TestConfig ,
737
+ config : TestConfig ,
740
738
mode : Mode ,
741
739
extra_args : Vec < OsString > ,
742
740
) -> Result < ( ) , Errored > {
@@ -823,19 +821,22 @@ fn run_rustfix(
823
821
) )
824
822
. collect ( ) ,
825
823
} ;
824
+ let config = TestConfig {
825
+ config : config. config ,
826
+ revision : config. revision ,
827
+ comments : & rustfix_comments,
828
+ path : config. path ,
829
+ } ;
826
830
827
831
let run = fixed_code. is_some ( ) ;
828
832
let mut errors = vec ! [ ] ;
829
833
let rustfix_path = check_output (
830
834
// Always check for `.fixed` files, even if there were reasons not to run rustfix.
831
835
// We don't want to leave around stray `.fixed` files
832
836
fixed_code. unwrap_or_default ( ) . as_bytes ( ) ,
833
- config. path ,
834
837
& mut errors,
835
838
"fixed" ,
836
- & config. config ,
837
- & rustfix_comments,
838
- config. revision ,
839
+ & config,
839
840
) ;
840
841
if !errors. is_empty ( ) {
841
842
return Err ( Errored {
@@ -854,7 +855,7 @@ fn run_rustfix(
854
855
& rustfix_path,
855
856
& config. config ,
856
857
config. revision ,
857
- & rustfix_comments ,
858
+ config . comments ,
858
859
) ?;
859
860
cmd. args ( extra_args) ;
860
861
// picking the crate name from the file name is problematic when `.revision_name` is inserted
@@ -904,15 +905,7 @@ fn check_test_result(
904
905
let revision = config. revision ;
905
906
// Always remove annotation comments from stderr.
906
907
let diagnostics = rustc_stderr:: process ( path, & output. stderr ) ;
907
- check_test_output (
908
- path,
909
- & mut errors,
910
- revision,
911
- & config. config ,
912
- comments,
913
- & output. stdout ,
914
- & diagnostics. rendered ,
915
- ) ;
908
+ check_test_output ( & mut errors, config, & output. stdout , & diagnostics. rendered ) ;
916
909
// Check error annotations in the source against output
917
910
check_annotations (
918
911
diagnostics. messages ,
@@ -934,19 +927,11 @@ fn check_test_result(
934
927
}
935
928
}
936
929
937
- fn check_test_output (
938
- path : & Path ,
939
- errors : & mut Vec < Error > ,
940
- revision : & str ,
941
- config : & Config ,
942
- comments : & Comments ,
943
- stdout : & [ u8 ] ,
944
- stderr : & [ u8 ] ,
945
- ) {
930
+ fn check_test_output ( errors : & mut Vec < Error > , config : & TestConfig , stdout : & [ u8 ] , stderr : & [ u8 ] ) {
946
931
// Check output files (if any)
947
932
// Check output files against actual output
948
- check_output ( stderr, path , errors, "stderr" , config, comments , revision ) ;
949
- check_output ( stdout, path , errors, "stdout" , config, comments , revision ) ;
933
+ check_output ( stderr, errors, "stderr" , config) ;
934
+ check_output ( stdout, errors, "stdout" , config) ;
950
935
}
951
936
952
937
fn check_annotations (
@@ -1115,25 +1100,28 @@ fn check_annotations(
1115
1100
1116
1101
fn check_output (
1117
1102
output : & [ u8 ] ,
1118
- path : & Path ,
1119
1103
errors : & mut Errors ,
1120
1104
kind : & ' static str ,
1121
- config : & Config ,
1122
- comments : & Comments ,
1123
- revision : & str ,
1105
+ config : & TestConfig ,
1124
1106
) -> PathBuf {
1125
- let target = config. target . as_ref ( ) . unwrap ( ) ;
1126
- let output = normalize ( output, comments, revision, kind) ;
1127
- let path = output_path ( path, comments, revised ( revision, kind) , target, revision) ;
1128
- match & config. output_conflict_handling {
1107
+ let target = config. config . target . as_ref ( ) . unwrap ( ) ;
1108
+ let output = normalize ( output, config. comments , config. revision , kind) ;
1109
+ let path = output_path (
1110
+ config. path ,
1111
+ config. comments ,
1112
+ revised ( config. revision , kind) ,
1113
+ target,
1114
+ config. revision ,
1115
+ ) ;
1116
+ match & config. config . output_conflict_handling {
1129
1117
OutputConflictHandling :: Error => {
1130
1118
let expected_output = std:: fs:: read ( & path) . unwrap_or_default ( ) ;
1131
1119
if output != expected_output {
1132
1120
errors. push ( Error :: OutputDiffers {
1133
1121
path : path. clone ( ) ,
1134
1122
actual : output. clone ( ) ,
1135
1123
expected : expected_output,
1136
- bless_command : config. bless_command . clone ( ) ,
1124
+ bless_command : config. config . bless_command . clone ( ) ,
1137
1125
} ) ;
1138
1126
}
1139
1127
}
0 commit comments