@@ -1112,39 +1112,31 @@ fn prepare_files_callback_success<'a>(
11121112 test_type : & ' a str ,
11131113) -> impl Fn ( & Path ) -> Result < bool , String > + ' a {
11141114 move |rust_path| {
1115- let files = std:: fs:: read_to_string ( file_path) . unwrap_or_default ( ) ;
1116- let first_file_name = files. lines ( ) . next ( ) . unwrap_or ( "" ) ;
1117- // If the first line ends with a `/`, we treat all lines in the file as a directory.
1118- if first_file_name. ends_with ( '/' ) {
1119- // Removing the failing tests.
1120- if let Ok ( files) = std:: fs:: read_to_string ( file_path) {
1121- for file in
1122- files. split ( '\n' ) . map ( |line| line. trim ( ) ) . filter ( |line| !line. is_empty ( ) )
1123- {
1124- let path = rust_path. join ( file) ;
1115+ // Attempt to read the file
1116+ if let Ok ( files) = std:: fs:: read_to_string ( file_path) {
1117+ // Iterate over each line in the file
1118+ for file in files. split ( '\n' ) . map ( |line| line. trim ( ) ) . filter ( |line| !line. is_empty ( ) ) {
1119+ let path = rust_path. join ( file) ;
1120+
1121+ // If the line ends with a `/`, treat it as a directory
1122+ if file. ends_with ( '/' ) {
11251123 if let Err ( e) = std:: fs:: remove_dir_all ( & path) {
11261124 println ! ( "Failed to remove directory `{}`: {}" , path. display( ) , e) ;
11271125 }
1126+ } else {
1127+ // Otherwise, treat it as a file
1128+ if let Err ( e) = std:: fs:: remove_file ( & path) {
1129+ println ! ( "Failed to remove file `{}`: {}" , path. display( ) , e) ;
1130+ }
11281131 }
1129- } else {
1130- println ! (
1131- "Failed to read `{}`, not putting back failing {} tests" ,
1132- file_path, test_type
1133- ) ;
11341132 }
11351133 } else {
1136- // Removing the failing tests.
1137- if let Ok ( files) = std:: fs:: read_to_string ( file_path) {
1138- for file in
1139- files. split ( '\n' ) . map ( |line| line. trim ( ) ) . filter ( |line| !line. is_empty ( ) )
1140- {
1141- let path = rust_path. join ( file) ;
1142- remove_file ( & path) ?;
1143- }
1144- } else {
1145- println ! ( "Failed to read `{}`, not putting back failing ui tests" , file_path) ;
1146- }
1134+ println ! (
1135+ "Failed to read `{}`, not putting back failing {} tests" ,
1136+ file_path, test_type
1137+ ) ;
11471138 }
1139+
11481140 Ok ( true )
11491141 }
11501142}
0 commit comments