Skip to content

Commit 23c97b5

Browse files
Replace xargs command with pure Rust
1 parent 87c284c commit 23c97b5

File tree

2 files changed

+42
-24
lines changed

2 files changed

+42
-24
lines changed

build_system/src/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,12 @@ fn build_sysroot_inner(
196196
)
197197
})?;
198198
run_command(
199-
&[&"cp", &"-r", &start_dir.join("sysroot_src/library/"), &sysroot_src_path],
199+
&[
200+
&"cp",
201+
&"-r",
202+
&start_dir.join("sysroot_src/library/"),
203+
&sysroot_src_path,
204+
],
200205
None,
201206
)?;
202207

build_system/src/test.rs

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ where
929929
fn file_handling(file: &Path) -> Result<(), String> {
930930
let path_str = file.display().to_string().replace("\\", "/");
931931
if !path_str.ends_with(".rs") {
932-
return Ok(())
932+
return Ok(());
933933
} else if should_not_remove_test(&path_str) {
934934
return Ok(());
935935
} else if should_remove_test(file, &path_str) {
@@ -1052,35 +1052,48 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10521052
Some(Path::new("rust")),
10531053
)?;
10541054
// Putting back only the failing ones.
1055-
run_command(
1056-
&[
1057-
&"xargs",
1058-
&"-a",
1059-
&"../failing-ui-tests.txt",
1060-
&"-d'\n'",
1061-
&"git",
1062-
&"checkout",
1063-
&"--",
1064-
],
1065-
Some(Path::new("rust")),
1066-
)?;
1055+
let path = "failing-ui-tests.txt";
1056+
if let Ok(files) = std::fs::read_to_string(path) {
1057+
for file in files
1058+
.split('\n')
1059+
.map(|line| line.trim())
1060+
.filter(|line| !line.is_empty())
1061+
{
1062+
run_command(
1063+
&[&"git", &"checkout", &"--", &file],
1064+
Some(Path::new("rust")),
1065+
)?;
1066+
}
1067+
} else {
1068+
println!(
1069+
"Failed to read `{}`, not putting back failing ui tests",
1070+
path
1071+
);
1072+
}
10671073
Ok(true)
10681074
})
10691075
}
10701076

10711077
fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10721078
test_rustc_inner(env, args, || {
10731079
// Removing the failing tests.
1074-
run_command(
1075-
&[
1076-
&"xargs",
1077-
&"-a",
1078-
&"../failing-ui-tests.txt",
1079-
&"-d'\n'",
1080-
&"rm",
1081-
],
1082-
Some(Path::new("rust")),
1083-
)?;
1080+
let path = "failing-ui-tests.txt";
1081+
if let Ok(files) = std::fs::read_to_string(path) {
1082+
for file in files
1083+
.split('\n')
1084+
.map(|line| line.trim())
1085+
.filter(|line| !line.is_empty())
1086+
{
1087+
let path = Path::new("rust").join(file);
1088+
std::fs::remove_file(&path)
1089+
.map_err(|error| format!("failed to remove `{}`: {:?}", path.display(), error))?;
1090+
}
1091+
} else {
1092+
println!(
1093+
"Failed to read `{}`, not putting back failing ui tests",
1094+
path
1095+
);
1096+
}
10841097
Ok(true)
10851098
})
10861099
}

0 commit comments

Comments
 (0)