normalize download-rustc's prefix when running compiletests

This commit is contained in:
Pietro Albini 2022-11-16 10:07:42 +01:00
parent 80d535966c
commit 470423c3d2
No known key found for this signature in database
GPG key ID: CD76B35F7734769E
3 changed files with 21 additions and 9 deletions

View file

@ -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();
if self.dry_run() && DOWNLOAD_RUSTC.get().is_none() {
// avoid trying to actually download the commit
return false;
self.download_rustc_commit().is_some()
}
*DOWNLOAD_RUSTC.get_or_init(|| match &self.download_rustc_commit {
None => false,
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 None;
}
DOWNLOAD_RUSTC
.get_or_init(|| match &self.download_rustc_commit {
None => None,
Some(commit) => {
self.download_ci_rustc(commit);
true
Some(commit.clone())
}
})
.as_deref()
}
pub(crate) fn initial_rustfmt(&self) -> Option<PathBuf> {

View file

@ -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!(

View file

@ -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 {