Skip to content

Commit 8e41146

Browse files
committed
improvs
1 parent cec2f39 commit 8e41146

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

build_system/src/test.rs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,39 +1160,31 @@ fn remove_files_callback<'a>(
11601160
test_type: &'a str,
11611161
) -> impl Fn(&Path) -> Result<bool, String> + 'a {
11621162
move |rust_path| {
1163-
let files = std::fs::read_to_string(file_path).unwrap_or_default();
1164-
let first_file_name = files.lines().next().unwrap_or("");
1165-
// If the first line ends with a `/`, we treat all lines in the file as a directory.
1166-
if first_file_name.ends_with('/') {
1167-
// Removing the failing tests.
1168-
if let Ok(files) = std::fs::read_to_string(file_path) {
1169-
for file in
1170-
files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty())
1171-
{
1172-
let path = rust_path.join(file);
1163+
// Attempt to read the file
1164+
if let Ok(files) = std::fs::read_to_string(file_path) {
1165+
// Iterate over each line in the file
1166+
for file in files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty()) {
1167+
let path = rust_path.join(file);
1168+
1169+
// If the line ends with a `/`, treat it as a directory
1170+
if file.ends_with('/') {
11731171
if let Err(e) = std::fs::remove_dir_all(&path) {
11741172
println!("Failed to remove directory `{}`: {}", path.display(), e);
11751173
}
1174+
} else {
1175+
// Otherwise, treat it as a file
1176+
if let Err(e) = std::fs::remove_file(&path) {
1177+
println!("Failed to remove file `{}`: {}", path.display(), e);
1178+
}
11761179
}
1177-
} else {
1178-
println!(
1179-
"Failed to read `{}`, not putting back failing {} tests",
1180-
file_path, test_type
1181-
);
11821180
}
11831181
} else {
1184-
// Removing the failing tests.
1185-
if let Ok(files) = std::fs::read_to_string(file_path) {
1186-
for file in
1187-
files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty())
1188-
{
1189-
let path = rust_path.join(file);
1190-
remove_file(&path)?;
1191-
}
1192-
} else {
1193-
println!("Failed to read `{}`, not putting back failing ui tests", file_path);
1194-
}
1182+
println!(
1183+
"Failed to read `{}`, not putting back failing {} tests",
1184+
file_path, test_type
1185+
);
11951186
}
1187+
11961188
Ok(true)
11971189
}
11981190
}

0 commit comments

Comments
 (0)