@@ -23,6 +23,7 @@ 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 ( "--test-failing-ui-pattern-tests" , ( "Run failing ui pattern tests" , test_failing_ui_pattern_tests) ) ;
26
27
runners. insert ( "--test-failing-rustc" , ( "Run failing rustc tests" , test_failing_rustc) ) ;
27
28
runners. insert ( "--projects" , ( "Run the tests of popular crates" , test_projects) ) ;
28
29
runners. insert ( "--test-libcore" , ( "Run libcore tests" , test_libcore) ) ;
@@ -860,6 +861,7 @@ fn test_rustc_inner<F>(
860
861
env : & Env ,
861
862
args : & TestArg ,
862
863
prepare_files_callback : F ,
864
+ should_run_test_callback : Option < Box < dyn Fn ( & Path ) -> bool > > ,
863
865
test_type : & str ,
864
866
) -> Result < ( ) , String >
865
867
where
@@ -876,6 +878,39 @@ where
876
878
}
877
879
878
880
if test_type == "ui" {
881
+ if let Some ( callback) = should_run_test_callback {
882
+ fn walk_dir < F , G > ( dir_path : PathBuf , dir_callback : F , file_callback : G ) -> Result < ( ) , String >
883
+ where
884
+ F : Fn ( & Path ) -> Result < ( ) , String > + Copy ,
885
+ G : Fn ( & Path ) -> Result < ( ) , String > + Copy ,
886
+ {
887
+ if dir_path. is_dir ( ) {
888
+ for entry in std:: fs:: read_dir ( dir_path) . unwrap ( ) {
889
+ let entry = entry;
890
+ let path = entry. unwrap ( ) . path ( ) ;
891
+ if path. is_dir ( ) {
892
+ dir_callback ( & path) ?;
893
+ walk_dir ( path, dir_callback, file_callback) ?; // Recursive call
894
+ } else if path. is_file ( ) {
895
+ file_callback ( & path) ?;
896
+ }
897
+ }
898
+ }
899
+ Ok ( ( ) )
900
+ }
901
+ walk_dir (
902
+ rust_path. join ( "tests/ui" ) ,
903
+ |_dir| Ok ( ( ) ) ,
904
+ |file_path| {
905
+ if callback ( file_path) {
906
+ println ! ( "file is {:?}" , & file_path) ;
907
+ Ok ( ( ) )
908
+ } else {
909
+ remove_file ( file_path) . map_err ( |e| e. to_string ( ) )
910
+ }
911
+ } ,
912
+ ) ?;
913
+ } else {
879
914
walk_dir (
880
915
rust_path. join ( "tests/ui" ) ,
881
916
|dir| {
@@ -923,7 +958,7 @@ where
923
958
}
924
959
925
960
walk_dir ( rust_path. join ( "tests/ui" ) , dir_handling, file_handling) ?;
926
-
961
+ }
927
962
let nb_parts = args. nb_parts . unwrap_or ( 0 ) ;
928
963
if nb_parts > 0 {
929
964
let current_part = args. current_part . unwrap ( ) ;
@@ -966,6 +1001,7 @@ where
966
1001
remove_file ( & rust_path. join ( path) ) ?;
967
1002
}
968
1003
}
1004
+
969
1005
}
970
1006
971
1007
// FIXME: create a function "display_if_not_quiet" or something along the line.
@@ -1004,22 +1040,24 @@ where
1004
1040
}
1005
1041
1006
1042
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" )
1043
+ test_rustc_inner ( env, args, |_| Ok ( false ) , None , "run-make" ) ?;
1044
+ test_rustc_inner ( env, args, |_| Ok ( false ) , None , "ui" )
1009
1045
}
1010
1046
1011
1047
fn test_failing_rustc ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1012
1048
let result1 = test_rustc_inner (
1013
1049
env,
1014
1050
args,
1015
1051
prepare_files_callback_failing ( "tests/failing-run-make-tests.txt" , "run-make" ) ,
1052
+ None ,
1016
1053
"run-make" ,
1017
1054
) ;
1018
1055
1019
1056
let result2 = test_rustc_inner (
1020
1057
env,
1021
1058
args,
1022
1059
prepare_files_callback_failing ( "tests/failing-ui-tests.txt" , "ui" ) ,
1060
+ None ,
1023
1061
"ui" ,
1024
1062
) ;
1025
1063
@@ -1031,16 +1069,29 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1031
1069
env,
1032
1070
args,
1033
1071
prepare_files_callback_success ( "tests/failing-ui-tests.txt" , "ui" ) ,
1072
+ None ,
1034
1073
"ui" ,
1035
1074
) ?;
1036
1075
test_rustc_inner (
1037
1076
env,
1038
1077
args,
1039
1078
prepare_files_callback_success ( "tests/failing-run-make-tests.txt" , "run-make" ) ,
1079
+ None ,
1040
1080
"run-make" ,
1041
1081
)
1042
1082
}
1043
1083
1084
+ fn test_failing_ui_pattern_tests ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1085
+ test_rustc_inner (
1086
+ env,
1087
+ args,
1088
+ |_| Ok ( false ) ,
1089
+ Some ( Box :: new ( |path| should_remove_test ( path) . unwrap_or ( false ) ) ) ,
1090
+ "ui" ,
1091
+ )
1092
+ }
1093
+
1094
+
1044
1095
fn prepare_files_callback_failing < ' a > (
1045
1096
file_path : & ' a str ,
1046
1097
test_type : & ' a str ,
0 commit comments