From 470423c3d2cde3a62d5d4ac23840d734e8145366 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 16 Nov 2022 10:07:42 +0100 Subject: [PATCH] normalize download-rustc's prefix when running compiletests --- src/bootstrap/config.rs | 24 +++++++++++++++--------- src/bootstrap/test.rs | 4 ++++ src/tools/compiletest/src/runtest.rs | 2 ++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index af004aa509854..1590f456bb5e5 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -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 = OnceCell::new(); + self.download_rustc_commit().is_some() + } + + pub(crate) fn download_rustc_commit(&self) -> Option<&'static str> { + static DOWNLOAD_RUSTC: OnceCell> = 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 { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index d40452a94a3d6..b22b7ad4ae04a 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -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!( diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index d085023a27e96..74700c602dd2e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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 {