Merge pull request #432 from tempdragon/master
Use shallow clone in test.rs to reduce cloning overhead
This commit is contained in:
commit
79c8780d84
@ -499,17 +499,42 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
|
|||||||
&"clone",
|
&"clone",
|
||||||
&"https://github.com/rust-lang/rust.git",
|
&"https://github.com/rust-lang/rust.git",
|
||||||
&rust_dir_path,
|
&rust_dir_path,
|
||||||
|
&"--depth",
|
||||||
|
&"1",
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
Some(env),
|
Some(env),
|
||||||
);
|
);
|
||||||
let rust_dir: Option<&Path> = Some(&rust_dir_path);
|
let rust_dir: Option<&Path> = Some(&rust_dir_path);
|
||||||
run_command(&[&"git", &"checkout", &"--", &"tests/"], rust_dir)?;
|
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 {
|
let rustc_commit = match rustc_version_info(env.get("RUSTC").map(|s| s.as_str()))?.commit_hash {
|
||||||
Some(commit_hash) => commit_hash,
|
Some(commit_hash) => commit_hash,
|
||||||
None => return Err("Couldn't retrieve rustc commit hash".to_string()),
|
None => return Err("Couldn't retrieve rustc commit hash".to_string()),
|
||||||
};
|
};
|
||||||
|
let has_commit = {
|
||||||
|
if let Ok(ty) = run_command_with_env(
|
||||||
|
&[&"git", &"cat-file", &"-t", &rustc_commit.as_str()],
|
||||||
|
rust_dir,
|
||||||
|
Some(env),
|
||||||
|
) {
|
||||||
|
String::from_utf8_lossy(&ty.stdout).to_string() == "commit"
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if !has_commit {
|
||||||
|
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" {
|
if rustc_commit != "unknown" {
|
||||||
run_command_with_output_and_env(
|
run_command_with_output_and_env(
|
||||||
&[&"git", &"checkout", &rustc_commit],
|
&[&"git", &"checkout", &rustc_commit],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user