Merge pull request #413 from NCGThompson/check-rustup-home-flag

Honor `$RUSTUP_HOME`
This commit is contained in:
antoyo 2024-01-19 10:46:23 -05:00 committed by GitHub
commit e4e9365882
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -488,8 +488,10 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
}
fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
let toolchain = get_toolchain()?;
let toolchain = format!("+{channel}-{host}",
channel = get_toolchain()?, // May also include date
host = args.config_info.host_triple
);
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(
@ -524,6 +526,18 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
Ok(cargo)
}
})?;
let rustc = String::from_utf8(
run_command_with_env(&[&"rustup", &toolchain, &"which", &"rustc"], rust_dir, Some(env))?.stdout,
)
.map_err(|error| format!("Failed to retrieve rustc path: {:?}", error))
.and_then(|rustc| {
let rustc = rustc.trim().to_owned();
if rustc.is_empty() {
Err(format!("`rustc` path is empty"))
} else {
Ok(rustc)
}
})?;
let llvm_filecheck = match run_command_with_env(
&[
&"bash",
@ -556,7 +570,7 @@ verbose-tests = true
[build]
cargo = "{cargo}"
local-rebuild = true
rustc = "{home}/.rustup/toolchains/{toolchain}-{host_triple}/bin/rustc"
rustc = "{rustc}"
[target.x86_64-unknown-linux-gnu]
llvm-filecheck = "{llvm_filecheck}"
@ -564,10 +578,8 @@ llvm-filecheck = "{llvm_filecheck}"
[llvm]
download-ci-llvm = false
"#,
cargo = cargo.trim(),
home = env.get("HOME").unwrap(),
toolchain = toolchain,
host_triple = args.config_info.host_triple,
cargo = cargo,
rustc = rustc,
llvm_filecheck = llvm_filecheck.trim(),
),
)