@@ -23,6 +23,10 @@ fn get_runners() -> Runners {
23
23
runners. insert ( "--test-rustc" , ( "Run all rustc tests" , test_rustc as Runner ) ) ;
24
24
runners
25
25
. insert ( "--test-successful-rustc" , ( "Run successful rustc tests" , test_successful_rustc) ) ;
26
+ runners. insert (
27
+ "--test-failing-ui-pattern-tests" ,
28
+ ( "Run failing ui pattern tests" , test_failing_ui_pattern_tests) ,
29
+ ) ;
26
30
runners. insert ( "--test-failing-rustc" , ( "Run failing rustc tests" , test_failing_rustc) ) ;
27
31
runners. insert ( "--projects" , ( "Run the tests of popular crates" , test_projects) ) ;
28
32
runners. insert ( "--test-libcore" , ( "Run libcore tests" , test_libcore) ) ;
@@ -860,6 +864,7 @@ fn test_rustc_inner<F>(
860
864
env : & Env ,
861
865
args : & TestArg ,
862
866
prepare_files_callback : F ,
867
+ should_run_test_callback : Option < Box < dyn Fn ( & Path ) -> bool > > ,
863
868
test_type : & str ,
864
869
) -> Result < ( ) , String >
865
870
where
@@ -876,54 +881,91 @@ where
876
881
}
877
882
878
883
if test_type == "ui" {
879
- walk_dir (
880
- rust_path. join ( "tests/ui" ) ,
881
- |dir| {
882
- let dir_name = dir. file_name ( ) . and_then ( |name| name. to_str ( ) ) . unwrap_or ( "" ) ;
883
- if [
884
- "abi" ,
885
- "extern" ,
886
- "unsized-locals" ,
887
- "proc-macro" ,
888
- "threads-sendsync" ,
889
- "borrowck" ,
890
- "test-attrs" ,
891
- ]
892
- . iter ( )
893
- . any ( |name| * name == dir_name)
894
- {
895
- std:: fs:: remove_dir_all ( dir) . map_err ( |error| {
896
- format ! ( "Failed to remove folder `{}`: {:?}" , dir. display( ) , error)
897
- } ) ?;
884
+ if let Some ( callback) = should_run_test_callback {
885
+ fn walk_dir < F , G > (
886
+ dir_path : PathBuf ,
887
+ dir_callback : F ,
888
+ file_callback : G ,
889
+ ) -> Result < ( ) , String >
890
+ where
891
+ F : Fn ( & Path ) -> Result < ( ) , String > + Copy ,
892
+ G : Fn ( & Path ) -> Result < ( ) , String > + Copy ,
893
+ {
894
+ if dir_path. is_dir ( ) {
895
+ for entry in std:: fs:: read_dir ( dir_path) . unwrap ( ) {
896
+ let entry = entry;
897
+ let path = entry. unwrap ( ) . path ( ) ;
898
+ if path. is_dir ( ) {
899
+ dir_callback ( & path) ?;
900
+ walk_dir ( path, dir_callback, file_callback) ?; // Recursive call
901
+ } else if path. is_file ( ) {
902
+ file_callback ( & path) ?;
903
+ }
904
+ }
898
905
}
899
906
Ok ( ( ) )
900
- } ,
901
- |_| Ok ( ( ) ) ,
902
- ) ?;
903
-
904
- // These two functions are used to remove files that are known to not be working currently
905
- // with the GCC backend to reduce noise.
906
- fn dir_handling ( dir : & Path ) -> Result < ( ) , String > {
907
- if dir. file_name ( ) . map ( |name| name == "auxiliary" ) . unwrap_or ( true ) {
908
- return Ok ( ( ) ) ;
909
907
}
910
- walk_dir ( dir, dir_handling, file_handling)
911
- }
912
- fn file_handling ( file_path : & Path ) -> Result < ( ) , String > {
913
- if !file_path. extension ( ) . map ( |extension| extension == "rs" ) . unwrap_or ( false ) {
914
- return Ok ( ( ) ) ;
908
+ walk_dir (
909
+ rust_path. join ( "tests/ui" ) ,
910
+ |_dir| Ok ( ( ) ) ,
911
+ |file_path| {
912
+ if callback ( file_path) {
913
+ println ! ( "file is {:?}" , & file_path) ;
914
+ Ok ( ( ) )
915
+ } else {
916
+ remove_file ( file_path) . map_err ( |e| e. to_string ( ) )
917
+ }
918
+ } ,
919
+ ) ?;
920
+ } else {
921
+ walk_dir (
922
+ rust_path. join ( "tests/ui" ) ,
923
+ |dir| {
924
+ let dir_name = dir. file_name ( ) . and_then ( |name| name. to_str ( ) ) . unwrap_or ( "" ) ;
925
+ if [
926
+ "abi" ,
927
+ "extern" ,
928
+ "unsized-locals" ,
929
+ "proc-macro" ,
930
+ "threads-sendsync" ,
931
+ "borrowck" ,
932
+ "test-attrs" ,
933
+ ]
934
+ . iter ( )
935
+ . any ( |name| * name == dir_name)
936
+ {
937
+ std:: fs:: remove_dir_all ( dir) . map_err ( |error| {
938
+ format ! ( "Failed to remove folder `{}`: {:?}" , dir. display( ) , error)
939
+ } ) ?;
940
+ }
941
+ Ok ( ( ) )
942
+ } ,
943
+ |_| Ok ( ( ) ) ,
944
+ ) ?;
945
+
946
+ // These two functions are used to remove files that are known to not be working currently
947
+ // with the GCC backend to reduce noise.
948
+ fn dir_handling ( dir : & Path ) -> Result < ( ) , String > {
949
+ if dir. file_name ( ) . map ( |name| name == "auxiliary" ) . unwrap_or ( true ) {
950
+ return Ok ( ( ) ) ;
951
+ }
952
+ walk_dir ( dir, dir_handling, file_handling)
915
953
}
916
- let path_str = file_path. display ( ) . to_string ( ) . replace ( "\\ " , "/" ) ;
917
- if should_not_remove_test ( & path_str) {
918
- return Ok ( ( ) ) ;
919
- } else if should_remove_test ( file_path) ? {
920
- return remove_file ( & file_path) ;
954
+ fn file_handling ( file_path : & Path ) -> Result < ( ) , String > {
955
+ if !file_path. extension ( ) . map ( |extension| extension == "rs" ) . unwrap_or ( false ) {
956
+ return Ok ( ( ) ) ;
957
+ }
958
+ let path_str = file_path. display ( ) . to_string ( ) . replace ( "\\ " , "/" ) ;
959
+ if should_not_remove_test ( & path_str) {
960
+ return Ok ( ( ) ) ;
961
+ } else if should_remove_test ( file_path) ? {
962
+ return remove_file ( & file_path) ;
963
+ }
964
+ Ok ( ( ) )
921
965
}
922
- Ok ( ( ) )
923
- }
924
-
925
- walk_dir ( rust_path. join ( "tests/ui" ) , dir_handling, file_handling) ?;
926
966
967
+ walk_dir ( rust_path. join ( "tests/ui" ) , dir_handling, file_handling) ?;
968
+ }
927
969
let nb_parts = args. nb_parts . unwrap_or ( 0 ) ;
928
970
if nb_parts > 0 {
929
971
let current_part = args. current_part . unwrap ( ) ;
@@ -1004,22 +1046,24 @@ where
1004
1046
}
1005
1047
1006
1048
fn test_rustc ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1007
- test_rustc_inner ( env, args, |_| Ok ( false ) , "run-make" ) ?;
1008
- test_rustc_inner ( env, args, |_| Ok ( false ) , "ui" )
1049
+ test_rustc_inner ( env, args, |_| Ok ( false ) , None , "run-make" ) ?;
1050
+ test_rustc_inner ( env, args, |_| Ok ( false ) , None , "ui" )
1009
1051
}
1010
1052
1011
1053
fn test_failing_rustc ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1012
1054
let result1 = test_rustc_inner (
1013
1055
env,
1014
1056
args,
1015
1057
prepare_files_callback_failing ( "tests/failing-run-make-tests.txt" , "run-make" ) ,
1058
+ None ,
1016
1059
"run-make" ,
1017
1060
) ;
1018
1061
1019
1062
let result2 = test_rustc_inner (
1020
1063
env,
1021
1064
args,
1022
1065
prepare_files_callback_failing ( "tests/failing-ui-tests.txt" , "ui" ) ,
1066
+ None ,
1023
1067
"ui" ,
1024
1068
) ;
1025
1069
@@ -1031,16 +1075,28 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1031
1075
env,
1032
1076
args,
1033
1077
prepare_files_callback_success ( "tests/failing-ui-tests.txt" , "ui" ) ,
1078
+ None ,
1034
1079
"ui" ,
1035
1080
) ?;
1036
1081
test_rustc_inner (
1037
1082
env,
1038
1083
args,
1039
1084
prepare_files_callback_success ( "tests/failing-run-make-tests.txt" , "run-make" ) ,
1085
+ None ,
1040
1086
"run-make" ,
1041
1087
)
1042
1088
}
1043
1089
1090
+ fn test_failing_ui_pattern_tests ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1091
+ test_rustc_inner (
1092
+ env,
1093
+ args,
1094
+ |_| Ok ( false ) ,
1095
+ Some ( Box :: new ( |path| should_remove_test ( path) . unwrap_or ( false ) ) ) ,
1096
+ "ui" ,
1097
+ )
1098
+ }
1099
+
1044
1100
fn prepare_files_callback_failing < ' a > (
1045
1101
file_path : & ' a str ,
1046
1102
test_type : & ' a str ,
0 commit comments