Skip to content

Commit

Permalink
feat(test.rs): Clone only 1 layer in build_system
Browse files Browse the repository at this point in the history
  • Loading branch information
tempdragon committed Feb 12, 2024
1 parent 560e65c commit 4f84385
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ fn get_runners() -> Runners {
"--test-failing-rustc",
("Run failing rustc tests", test_failing_rustc),
);
runners.insert("--projects", ("Run the tests of popular crates", test_projects));
runners.insert(
"--projects",
("Run the tests of popular crates", test_projects),
);
runners.insert("--test-libcore", ("Run libcore tests", test_libcore));
runners.insert("--clean", ("Empty cargo target directory", clean));
runners.insert("--build-sysroot", ("Build sysroot", build_sysroot));
Expand Down Expand Up @@ -494,16 +497,32 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
let rust_dir = Some(Path::new("rust"));
// If the repository was already cloned, command will fail, so doesn't matter.
let _ = run_command_with_output_and_env(
&[&"git", &"clone", &"https://github.com/rust-lang/rust.git"],
&[
&"git",
&"clone",
&"https://github.com/rust-lang/rust.git",
&"--depth",
&"1",
],
None,
Some(env),
);
run_command(&[&"git", &"checkout", &"--", &"tests/"], rust_dir)?;
run_command_with_output_and_env(&[&"git", &"fetch"], rust_dir, Some(env))?;
let rustc_commit = match rustc_version_info(env.get("RUSTC").map(|s| s.as_str()))?.commit_hash {
Some(commit_hash) => commit_hash,
None => return Err("Couldn't retrieve rustc commit hash".to_string()),
};
run_command_with_output_and_env(
&[
&"git",
&"fetch",
&"https://github.com/rust-lang/rust.git",
&rustc_commit.as_str(),
&"--depth=1",
],
rust_dir,
Some(env),
)?;
if rustc_commit != "unknown" {
run_command_with_output_and_env(
&[&"git", &"checkout", &rustc_commit],
Expand Down Expand Up @@ -703,7 +722,7 @@ fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> {
//"https://github.com/rust-lang/cargo", // TODO: very slow, only run on master?
];

let run_tests = |projects_path, iter: &mut dyn Iterator<Item=&&str>| -> Result<(), String> {
let run_tests = |projects_path, iter: &mut dyn Iterator<Item = &&str>| -> Result<(), String> {
for project in iter {
let clone_result = git_clone(project, Some(projects_path), true)?;
let repo_path = Path::new(&clone_result.repo_dir);
Expand All @@ -727,8 +746,7 @@ fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> {
let start = current_part * count;
// We remove the projects we don't want to test.
run_tests(projects_path, &mut projects.iter().skip(start).take(count))?;
}
else {
} else {
run_tests(projects_path, &mut projects.iter())?;
}

Expand Down

0 comments on commit 4f84385

Please sign in to comment.