Skip to content

Commit cfb7a56

Browse files
authored
Rollup merge of #134528 - jieyouxu:fix-rustc-bootstrap-test, r=Kobzol
opt-dist: propagate channel info to bootstrap Fixes #133503. Previously, `tests/ui/bootstrap/rustc_bootstap.rs` [sic] failed during [beta bump](#133447 (comment)) in opt-dist tests. This is because: - `opt-dist` tried to run `./x test` against beta-channel dist `rustc` through `bootstrap`. - The dist build produced during the beta bump produces a `rustc` which correctly thinks that it is a beta compiler based on `src/ci/channel` info. - `opt-dist` tries to run `./x test` on the beta `rustc` from the dist build, but without specifying channel through a synthetic `config.toml`, so `bootstrap` tells `compiletest` that we're on the `nightly` channel (by default). - Now there's a channel mismatch: `compiletest` believes the `rustc` under test is a *nightly* rustc, but the `rustc` under test actually considers itself a *beta* rustc. This means that `//@ only-nightly` will be satisfied yet the test will fail as the *beta* rustc is not a *nightly* rustc. This PR: - Fixes the test failure during beta bump (i.e. #133503) by having `opt-dist` faithfully report the channel of the dist `rustc` being tested (i.e. "beta" in a beta bump PR). This will properly make the test be ignored during beta bump as the `rustc` under test is not a *nightly* rustc. - Fixes the test name `rustc_bootstap.rs` -> `rustc_bootstrap.rs`. No more stapping. - Slightly adjusts the doc comment in the test to make it more clear. I ran a try-job against the beta branch (explicitly running the opt-dist tests by modifying the job definition) with these changes in #134131, and it appears that the try-job was [successful](#134131 (comment)). The two commits in this PR are cherry-picked from #134131, with the test commit slightly modified (to also adjust the test comments). r? `@Kobzol` (or compiler or bootstrap or infra I guess?)
2 parents 369be18 + d6ceae0 commit cfb7a56

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/tools/opt-dist/src/tests.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> {
2525
let host_triple = env.host_tuple();
2626
let version = find_dist_version(&dist_dir)?;
2727

28+
let channel = version_to_channel(&version);
29+
2830
// Extract rustc, libstd, cargo and src archives to create the optimized sysroot
2931
let rustc_dir = extract_dist_dir(&format!("rustc-{version}-{host_triple}"))?.join("rustc");
3032
let libstd_dir = extract_dist_dir(&format!("rust-std-{version}-{host_triple}"))?
@@ -61,9 +63,13 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> {
6163
assert!(llvm_config.is_file());
6264

6365
let config_content = format!(
64-
r#"profile = "user"
66+
r#"
67+
profile = "user"
6568
change-id = 115898
6669
70+
[rust]
71+
channel = "{channel}"
72+
6773
[build]
6874
rustc = "{rustc}"
6975
cargo = "{cargo}"
@@ -116,3 +122,13 @@ fn find_dist_version(directory: &Utf8Path) -> anyhow::Result<String> {
116122
archive.strip_prefix("reproducible-artifacts-").unwrap().split_once('-').unwrap();
117123
Ok(version.to_string())
118124
}
125+
126+
/// Roughly convert a version string (`nightly`, `beta`, or `1.XY.Z`) to channel string (`nightly`,
127+
/// `beta` or `stable`).
128+
fn version_to_channel(version_str: &str) -> &'static str {
129+
match version_str {
130+
"nightly" => "nightly",
131+
"beta" => "beta",
132+
_ => "stable",
133+
}
134+
}

tests/ui/bootstrap/rustc_bootstap.rs renamed to tests/ui/bootstrap/rustc_bootstrap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//! Check `RUSTC_BOOTSTRAP`'s behavior in relation to feature stability and what rustc considers
2-
//! itself to be (stable vs non-stable ).
1+
//! Check the compiler's behavior when the perma-unstable env var `RUSTC_BOOTSTRAP` is set in the
2+
//! environment in relation to feature stability and which channel rustc considers itself to be.
33
//!
44
//! `RUSTC_BOOTSTRAP` accepts:
55
//!

0 commit comments

Comments
 (0)