@@ -573,61 +573,47 @@ fn build_aux(
573
573
Ok ( extra_args)
574
574
}
575
575
576
- fn run_test (
577
- build_manager : & BuildManager < ' _ > ,
578
- TestConfig {
579
- mut config,
580
- revision,
581
- comments,
582
- path,
583
- } : TestConfig < ' _ > ,
584
- ) -> TestResult {
576
+ fn run_test ( build_manager : & BuildManager < ' _ > , mut config : TestConfig < ' _ > ) -> TestResult {
585
577
let extra_args = build_aux_files (
586
- & path. parent ( ) . unwrap ( ) . join ( "auxiliary" ) ,
587
- comments,
588
- revision,
589
- & config,
578
+ & config . path . parent ( ) . unwrap ( ) . join ( "auxiliary" ) ,
579
+ config . comments ,
580
+ config . revision ,
581
+ & config. config ,
590
582
build_manager,
591
583
) ?;
592
584
593
- // Put aux builds into a separate directory per path so that multiple aux files
594
- // from different directories (but with the same file name) don't collide.
595
- let relative = strip_path_prefix ( path. parent ( ) . unwrap ( ) , & config. out_dir ) ;
596
-
597
- config. out_dir . extend ( relative) ;
585
+ config. patch_out_dir ( ) ;
598
586
599
- let mut cmd = build_command ( path, & config, revision, comments) ?;
587
+ let mut cmd = build_command (
588
+ config. path ,
589
+ & config. config ,
590
+ config. revision ,
591
+ config. comments ,
592
+ ) ?;
600
593
cmd. args ( & extra_args) ;
601
- let stdin = path. with_extension ( if revision. is_empty ( ) {
602
- "stdin" . into ( )
603
- } else {
604
- format ! ( "{revision}.stdin" )
605
- } ) ;
594
+ let stdin = config. path . with_extension ( config. extension ( "stdin" ) ) ;
606
595
if stdin. exists ( ) {
607
596
cmd. stdin ( std:: fs:: File :: open ( stdin) . unwrap ( ) ) ;
608
597
}
609
598
610
599
let ( cmd, output) = run_command ( cmd) ?;
611
600
612
- let mode = comments . mode ( revision ) ?;
601
+ let mode = config . mode ( ) ?;
613
602
let ( cmd, output) = check_test_result (
614
603
cmd,
615
604
match * mode {
616
605
Mode :: Run { .. } => Mode :: Pass ,
617
606
_ => * mode,
618
607
} ,
619
- path,
620
608
& config,
621
- revision,
622
- comments,
623
609
output,
624
610
) ?;
625
611
626
612
if let Mode :: Run { .. } = * mode {
627
- return run_test_binary ( mode, path , revision , comments , cmd, & config) ;
613
+ return run_test_binary ( mode, cmd, & config) ;
628
614
}
629
615
630
- run_rustfix ( output, path , comments , revision , & config, * mode, extra_args) ?;
616
+ run_rustfix ( output, & config, * mode, extra_args) ?;
631
617
Ok ( TestOk :: Ok )
632
618
}
633
619
@@ -703,19 +689,8 @@ fn build_aux_files(
703
689
Ok ( extra_args)
704
690
}
705
691
706
- fn run_test_binary (
707
- mode : Spanned < Mode > ,
708
- path : & Path ,
709
- revision : & str ,
710
- comments : & Comments ,
711
- mut cmd : Command ,
712
- config : & Config ,
713
- ) -> TestResult {
714
- let revision = if revision. is_empty ( ) {
715
- "run" . to_string ( )
716
- } else {
717
- format ! ( "run.{revision}" )
718
- } ;
692
+ fn run_test_binary ( mode : Spanned < Mode > , mut cmd : Command , config : & TestConfig ) -> TestResult {
693
+ let revision = config. extension ( "run" ) ;
719
694
cmd. arg ( "--print" ) . arg ( "file-names" ) ;
720
695
let output = cmd. output ( ) . unwrap ( ) ;
721
696
assert ! ( output. status. success( ) ) ;
@@ -724,9 +699,9 @@ fn run_test_binary(
724
699
let file = files. next ( ) . unwrap ( ) ;
725
700
assert_eq ! ( files. next( ) , None ) ;
726
701
let file = std:: str:: from_utf8 ( file) . unwrap ( ) ;
727
- let exe_file = config. out_dir . join ( file) ;
702
+ let exe_file = config. config . out_dir . join ( file) ;
728
703
let mut exe = Command :: new ( & exe_file) ;
729
- let stdin = path. with_extension ( format ! ( "{revision}.stdin" ) ) ;
704
+ let stdin = config . path . with_extension ( format ! ( "{revision}.stdin" ) ) ;
730
705
if stdin. exists ( ) {
731
706
exe. stdin ( std:: fs:: File :: open ( stdin) . unwrap ( ) ) ;
732
707
}
@@ -737,11 +712,11 @@ fn run_test_binary(
737
712
let mut errors = vec ! [ ] ;
738
713
739
714
check_test_output (
740
- path,
715
+ config . path ,
741
716
& mut errors,
742
717
& revision,
743
- config,
744
- comments,
718
+ & config . config ,
719
+ config . comments ,
745
720
& output. stdout ,
746
721
& output. stderr ,
747
722
) ;
@@ -761,17 +736,11 @@ fn run_test_binary(
761
736
762
737
fn run_rustfix (
763
738
output : Output ,
764
- path : & Path ,
765
- comments : & Comments ,
766
- revision : & str ,
767
- config : & Config ,
739
+ config : & TestConfig ,
768
740
mode : Mode ,
769
741
extra_args : Vec < OsString > ,
770
742
) -> Result < ( ) , Errored > {
771
- let no_run_rustfix =
772
- comments. find_one_for_revision ( revision, "`no-rustfix` annotations" , |r| {
773
- r. no_rustfix . clone ( )
774
- } ) ?;
743
+ let no_run_rustfix = config. find_one ( "`no-rustfix` annotations" , |r| r. no_rustfix . clone ( ) ) ?;
775
744
776
745
let global_rustfix = match mode {
777
746
Mode :: Pass | Mode :: Run { .. } | Mode :: Panic => RustfixMode :: Disabled ,
@@ -805,7 +774,7 @@ fn run_rustfix(
805
774
if suggestions. is_empty ( ) {
806
775
None
807
776
} else {
808
- let path_str = path. display ( ) . to_string ( ) ;
777
+ let path_str = config . path . display ( ) . to_string ( ) ;
809
778
for sugg in & suggestions {
810
779
for snip in & sugg. snippets {
811
780
if snip. file_name != path_str {
@@ -814,20 +783,20 @@ fn run_rustfix(
814
783
}
815
784
}
816
785
Some ( rustfix:: apply_suggestions (
817
- & std:: fs:: read_to_string ( path) . unwrap ( ) ,
786
+ & std:: fs:: read_to_string ( config . path ) . unwrap ( ) ,
818
787
& suggestions,
819
788
) )
820
789
}
821
790
} )
822
791
. transpose ( )
823
792
. map_err ( |err| Errored {
824
- command : Command :: new ( format ! ( "rustfix {}" , path. display( ) ) ) ,
793
+ command : Command :: new ( format ! ( "rustfix {}" , config . path. display( ) ) ) ,
825
794
errors : vec ! [ Error :: Rustfix ( err) ] ,
826
795
stderr : output. stderr ,
827
796
stdout : output. stdout ,
828
797
} ) ?;
829
798
830
- let edition = comments . edition ( revision ) ?. into ( ) ;
799
+ let edition = config . edition ( ) ?. into ( ) ;
831
800
let rustfix_comments = Comments {
832
801
revisions : None ,
833
802
revisioned : std:: iter:: once ( (
@@ -837,23 +806,14 @@ fn run_rustfix(
837
806
ignore : vec ! [ ] ,
838
807
only : vec ! [ ] ,
839
808
stderr_per_bitwidth : false ,
840
- compile_flags : comments
841
- . for_revision ( revision)
842
- . flat_map ( |r| r. compile_flags . iter ( ) . cloned ( ) )
843
- . collect ( ) ,
844
- env_vars : comments
845
- . for_revision ( revision)
846
- . flat_map ( |r| r. env_vars . iter ( ) . cloned ( ) )
847
- . collect ( ) ,
809
+ compile_flags : config. collect ( |r| r. compile_flags . iter ( ) . cloned ( ) ) ,
810
+ env_vars : config. collect ( |r| r. env_vars . iter ( ) . cloned ( ) ) ,
848
811
normalize_stderr : vec ! [ ] ,
849
812
normalize_stdout : vec ! [ ] ,
850
813
error_in_other_files : vec ! [ ] ,
851
814
error_matches : vec ! [ ] ,
852
815
require_annotations_for_level : Default :: default ( ) ,
853
- aux_builds : comments
854
- . for_revision ( revision)
855
- . flat_map ( |r| r. aux_builds . iter ( ) . cloned ( ) )
856
- . collect ( ) ,
816
+ aux_builds : config. collect ( |r| r. aux_builds . iter ( ) . cloned ( ) ) ,
857
817
edition,
858
818
mode : OptWithLine :: new ( Mode :: Pass , Span :: default ( ) ) ,
859
819
no_rustfix : OptWithLine :: new ( ( ) , Span :: default ( ) ) ,
@@ -870,16 +830,16 @@ fn run_rustfix(
870
830
// Always check for `.fixed` files, even if there were reasons not to run rustfix.
871
831
// We don't want to leave around stray `.fixed` files
872
832
fixed_code. unwrap_or_default ( ) . as_bytes ( ) ,
873
- path,
833
+ config . path ,
874
834
& mut errors,
875
835
"fixed" ,
876
- config,
836
+ & config . config ,
877
837
& rustfix_comments,
878
- revision,
838
+ config . revision ,
879
839
) ;
880
840
if !errors. is_empty ( ) {
881
841
return Err ( Errored {
882
- command : Command :: new ( format ! ( "checking {}" , path. display( ) ) ) ,
842
+ command : Command :: new ( format ! ( "checking {}" , config . path. display( ) ) ) ,
883
843
errors,
884
844
stderr : vec ! [ ] ,
885
845
stdout : vec ! [ ] ,
@@ -890,11 +850,18 @@ fn run_rustfix(
890
850
return Ok ( ( ) ) ;
891
851
}
892
852
893
- let mut cmd = build_command ( & rustfix_path, config, revision, & rustfix_comments) ?;
853
+ let mut cmd = build_command (
854
+ & rustfix_path,
855
+ & config. config ,
856
+ config. revision ,
857
+ & rustfix_comments,
858
+ ) ?;
894
859
cmd. args ( extra_args) ;
895
860
// picking the crate name from the file name is problematic when `.revision_name` is inserted
896
861
cmd. arg ( "--crate-name" ) . arg (
897
- path. file_stem ( )
862
+ config
863
+ . path
864
+ . file_stem ( )
898
865
. unwrap ( )
899
866
. to_str ( )
900
867
. unwrap ( )
@@ -927,21 +894,21 @@ fn revised(revision: &str, extension: &str) -> String {
927
894
fn check_test_result (
928
895
command : Command ,
929
896
mode : Mode ,
930
- path : & Path ,
931
- config : & Config ,
932
- revision : & str ,
933
- comments : & Comments ,
897
+ config : & TestConfig ,
934
898
output : Output ,
935
899
) -> Result < ( Command , Output ) , Errored > {
936
900
let mut errors = vec ! [ ] ;
937
901
errors. extend ( mode. ok ( output. status ) . err ( ) ) ;
902
+ let path = config. path ;
903
+ let comments = config. comments ;
904
+ let revision = config. revision ;
938
905
// Always remove annotation comments from stderr.
939
906
let diagnostics = rustc_stderr:: process ( path, & output. stderr ) ;
940
907
check_test_output (
941
908
path,
942
909
& mut errors,
943
910
revision,
944
- config,
911
+ & config . config ,
945
912
comments,
946
913
& output. stdout ,
947
914
& diagnostics. rendered ,
0 commit comments