Skip to content

Commit 4f84385

Browse files
committed
feat(test.rs): Clone only 1 layer in build_system
1 parent 560e65c commit 4f84385

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

build_system/src/test.rs

+24-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ fn get_runners() -> Runners {
3131
"--test-failing-rustc",
3232
("Run failing rustc tests", test_failing_rustc),
3333
);
34-
runners.insert("--projects", ("Run the tests of popular crates", test_projects));
34+
runners.insert(
35+
"--projects",
36+
("Run the tests of popular crates", test_projects),
37+
);
3538
runners.insert("--test-libcore", ("Run libcore tests", test_libcore));
3639
runners.insert("--clean", ("Empty cargo target directory", clean));
3740
runners.insert("--build-sysroot", ("Build sysroot", build_sysroot));
@@ -494,16 +497,32 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
494497
let rust_dir = Some(Path::new("rust"));
495498
// If the repository was already cloned, command will fail, so doesn't matter.
496499
let _ = run_command_with_output_and_env(
497-
&[&"git", &"clone", &"https://github.com/rust-lang/rust.git"],
500+
&[
501+
&"git",
502+
&"clone",
503+
&"https://github.com/rust-lang/rust.git",
504+
&"--depth",
505+
&"1",
506+
],
498507
None,
499508
Some(env),
500509
);
501510
run_command(&[&"git", &"checkout", &"--", &"tests/"], rust_dir)?;
502-
run_command_with_output_and_env(&[&"git", &"fetch"], rust_dir, Some(env))?;
503511
let rustc_commit = match rustc_version_info(env.get("RUSTC").map(|s| s.as_str()))?.commit_hash {
504512
Some(commit_hash) => commit_hash,
505513
None => return Err("Couldn't retrieve rustc commit hash".to_string()),
506514
};
515+
run_command_with_output_and_env(
516+
&[
517+
&"git",
518+
&"fetch",
519+
&"https://github.com/rust-lang/rust.git",
520+
&rustc_commit.as_str(),
521+
&"--depth=1",
522+
],
523+
rust_dir,
524+
Some(env),
525+
)?;
507526
if rustc_commit != "unknown" {
508527
run_command_with_output_and_env(
509528
&[&"git", &"checkout", &rustc_commit],
@@ -703,7 +722,7 @@ fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> {
703722
//"https://github.com/rust-lang/cargo", // TODO: very slow, only run on master?
704723
];
705724

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

0 commit comments

Comments
 (0)