Skip to content

Commit

Permalink
normalize download-rustc's prefix when running compiletests
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Nov 16, 2022
1 parent 80d5359 commit 470423c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,19 +1506,25 @@ impl Config {

/// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source.
pub(crate) fn download_rustc(&self) -> bool {
static DOWNLOAD_RUSTC: OnceCell<bool> = OnceCell::new();
self.download_rustc_commit().is_some()
}

pub(crate) fn download_rustc_commit(&self) -> Option<&'static str> {
static DOWNLOAD_RUSTC: OnceCell<Option<String>> = OnceCell::new();
if self.dry_run() && DOWNLOAD_RUSTC.get().is_none() {
// avoid trying to actually download the commit
return false;
return None;
}

*DOWNLOAD_RUSTC.get_or_init(|| match &self.download_rustc_commit {
None => false,
Some(commit) => {
self.download_ci_rustc(commit);
true
}
})
DOWNLOAD_RUSTC
.get_or_init(|| match &self.download_rustc_commit {
None => None,
Some(commit) => {
self.download_ci_rustc(commit);
Some(commit.clone())
}
})
.as_deref()
}

pub(crate) fn initial_rustfmt(&self) -> Option<PathBuf> {
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the

cmd.arg("--channel").arg(&builder.config.channel);

if let Some(commit) = builder.config.download_rustc_commit() {
cmd.env("FAKE_DOWNLOAD_RUSTC_PREFIX", format!("/rustc/{commit}"));
}

builder.ci_env.force_coloring_in_ci(&mut cmd);

builder.info(&format!(
Expand Down
2 changes: 2 additions & 0 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3536,6 +3536,8 @@ impl<'test> TestCx<'test> {
Some(self.config.sysroot_base.join("lib").join("rustlib").join("src").join("rust")),
// Virtual `/rustc/$sha` remapped paths (if `remap-debuginfo` is enabled):
option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").map(PathBuf::from),
// Virtual `/rustc/$sha` coming from download-rustc:
std::env::var_os("FAKE_DOWNLOAD_RUSTC_PREFIX").map(PathBuf::from),
];
for base_dir in source_bases {
if let Some(base_dir) = base_dir {
Expand Down

0 comments on commit 470423c

Please sign in to comment.