Skip to content

Commit

Permalink
fix test_rlib_dep_reader_call failure when $CARGO_HOME isn't in the u…
Browse files Browse the repository at this point in the history
…ser's $HOME
  • Loading branch information
trxcllnt authored and sylvestre committed Dec 22, 2024
1 parent 709309e commit 9a5b681
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2314,12 +2314,6 @@ impl RlibDepReader {
stderr,
} = cmd.output()?;

if !status.success() {
bail!(
"Failed to compile a minimal rlib with {}",
executable.display()
)
}
if !stdout.is_empty() {
bail!(
"rustc stdout non-empty when compiling a minimal rlib: {:?}",
Expand All @@ -2332,6 +2326,12 @@ impl RlibDepReader {
String::from_utf8_lossy(&stderr)
)
}
if !status.success() {
bail!(
"Failed to compile a minimal rlib with {}",
executable.display()
)
}

// The goal of this cache is to avoid repeated lookups when building a single project. Let's budget 3MB.
// Allowing for a 100 byte path, 50 dependencies per rlib and 20 characters per crate name, this roughly
Expand Down Expand Up @@ -3169,11 +3169,20 @@ proc_macro false
let cargo_home = std::env::var("CARGO_HOME");
assert!(cargo_home.is_ok());

let mut env_vars = vec![];
if let Some(rustup_home) = std::env::var_os("RUSTUP_HOME") {
env_vars.push(("RUSTUP_HOME".into(), rustup_home));
}

let mut rustc_path = PathBuf::from(cargo_home.unwrap());
rustc_path.push("bin");
rustc_path.push("rustc");
let rlib_dep_reader = RlibDepReader::new_with_check(rustc_path, &[]);
assert!(rlib_dep_reader.is_ok());

let rlib_dep_reader = RlibDepReader::new_with_check(rustc_path, &env_vars);
let is_ok = rlib_dep_reader.is_ok();
// Unwrap so the error is reported in the test output
let _ = rlib_dep_reader.unwrap();
assert!(is_ok);
}

#[cfg(feature = "dist-client")]
Expand Down

0 comments on commit 9a5b681

Please sign in to comment.