diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-23 14:44:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-23 14:44:21 +0100 |
| commit | cfb7a566767f384218a1ae28f0722477bc56648e (patch) | |
| tree | 76d78401c263767131e9efc244883dbe9d3ed733 | |
| parent | 369be1855dd7b8eb1f5b21e90b3f2b9ce0e81d96 (diff) | |
| parent | d6ceae0fd89ad0f9e882aea1f9e92dff673fcfba (diff) | |
| download | rust-cfb7a566767f384218a1ae28f0722477bc56648e.tar.gz rust-cfb7a566767f384218a1ae28f0722477bc56648e.zip | |
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](https://github.com/rust-lang/rust/pull/133447#issuecomment-2501298794) 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](https://github.com/rust-lang/rust/pull/134131#issuecomment-2555492215). 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?)
| -rw-r--r-- | src/tools/opt-dist/src/tests.rs | 18 | ||||
| -rw-r--r-- | tests/ui/bootstrap/rustc_bootstrap.force_stable.stderr (renamed from tests/ui/bootstrap/rustc_bootstap.force_stable.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/bootstrap/rustc_bootstrap.rs (renamed from tests/ui/bootstrap/rustc_bootstap.rs) | 4 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index 887055798e0..06ed076a864 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -25,6 +25,8 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> { let host_triple = env.host_tuple(); let version = find_dist_version(&dist_dir)?; + let channel = version_to_channel(&version); + // Extract rustc, libstd, cargo and src archives to create the optimized sysroot let rustc_dir = extract_dist_dir(&format!("rustc-{version}-{host_triple}"))?.join("rustc"); let libstd_dir = extract_dist_dir(&format!("rust-std-{version}-{host_triple}"))? @@ -61,9 +63,13 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> { assert!(llvm_config.is_file()); let config_content = format!( - r#"profile = "user" + r#" +profile = "user" change-id = 115898 +[rust] +channel = "{channel}" + [build] rustc = "{rustc}" cargo = "{cargo}" @@ -116,3 +122,13 @@ fn find_dist_version(directory: &Utf8Path) -> anyhow::Result<String> { archive.strip_prefix("reproducible-artifacts-").unwrap().split_once('-').unwrap(); Ok(version.to_string()) } + +/// Roughly convert a version string (`nightly`, `beta`, or `1.XY.Z`) to channel string (`nightly`, +/// `beta` or `stable`). +fn version_to_channel(version_str: &str) -> &'static str { + match version_str { + "nightly" => "nightly", + "beta" => "beta", + _ => "stable", + } +} diff --git a/tests/ui/bootstrap/rustc_bootstap.force_stable.stderr b/tests/ui/bootstrap/rustc_bootstrap.force_stable.stderr index f378f3c70dd..f378f3c70dd 100644 --- a/tests/ui/bootstrap/rustc_bootstap.force_stable.stderr +++ b/tests/ui/bootstrap/rustc_bootstrap.force_stable.stderr diff --git a/tests/ui/bootstrap/rustc_bootstap.rs b/tests/ui/bootstrap/rustc_bootstrap.rs index 3d792ef4be4..daa28e0cdf2 100644 --- a/tests/ui/bootstrap/rustc_bootstap.rs +++ b/tests/ui/bootstrap/rustc_bootstrap.rs @@ -1,5 +1,5 @@ -//! Check `RUSTC_BOOTSTRAP`'s behavior in relation to feature stability and what rustc considers -//! itself to be (stable vs non-stable ). +//! Check the compiler's behavior when the perma-unstable env var `RUSTC_BOOTSTRAP` is set in the +//! environment in relation to feature stability and which channel rustc considers itself to be. //! //! `RUSTC_BOOTSTRAP` accepts: //! |
