Skip to content

Commit 470423c

Browse files
committed
normalize download-rustc's prefix when running compiletests
1 parent 80d5359 commit 470423c

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/bootstrap/config.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -1506,19 +1506,25 @@ impl Config {
15061506

15071507
/// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source.
15081508
pub(crate) fn download_rustc(&self) -> bool {
1509-
static DOWNLOAD_RUSTC: OnceCell<bool> = OnceCell::new();
1509+
self.download_rustc_commit().is_some()
1510+
}
1511+
1512+
pub(crate) fn download_rustc_commit(&self) -> Option<&'static str> {
1513+
static DOWNLOAD_RUSTC: OnceCell<Option<String>> = OnceCell::new();
15101514
if self.dry_run() && DOWNLOAD_RUSTC.get().is_none() {
15111515
// avoid trying to actually download the commit
1512-
return false;
1516+
return None;
15131517
}
15141518

1515-
*DOWNLOAD_RUSTC.get_or_init(|| match &self.download_rustc_commit {
1516-
None => false,
1517-
Some(commit) => {
1518-
self.download_ci_rustc(commit);
1519-
true
1520-
}
1521-
})
1519+
DOWNLOAD_RUSTC
1520+
.get_or_init(|| match &self.download_rustc_commit {
1521+
None => None,
1522+
Some(commit) => {
1523+
self.download_ci_rustc(commit);
1524+
Some(commit.clone())
1525+
}
1526+
})
1527+
.as_deref()
15221528
}
15231529

15241530
pub(crate) fn initial_rustfmt(&self) -> Option<PathBuf> {

src/bootstrap/test.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
16711671

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

1674+
if let Some(commit) = builder.config.download_rustc_commit() {
1675+
cmd.env("FAKE_DOWNLOAD_RUSTC_PREFIX", format!("/rustc/{commit}"));
1676+
}
1677+
16741678
builder.ci_env.force_coloring_in_ci(&mut cmd);
16751679

16761680
builder.info(&format!(

src/tools/compiletest/src/runtest.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3536,6 +3536,8 @@ impl<'test> TestCx<'test> {
35363536
Some(self.config.sysroot_base.join("lib").join("rustlib").join("src").join("rust")),
35373537
// Virtual `/rustc/$sha` remapped paths (if `remap-debuginfo` is enabled):
35383538
option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").map(PathBuf::from),
3539+
// Virtual `/rustc/$sha` coming from download-rustc:
3540+
std::env::var_os("FAKE_DOWNLOAD_RUSTC_PREFIX").map(PathBuf::from),
35393541
];
35403542
for base_dir in source_bases {
35413543
if let Some(base_dir) = base_dir {

0 commit comments

Comments
 (0)