|
1 | | -// `--version --verbose` should display the git-commit hashes of rustc and rustdoc, but this |
2 | | -// functionality was lost due to #104184. After this feature was returned by #109981, this |
3 | | -// test ensures it will not be broken again. |
4 | | -// See https://github.com/rust-lang/rust/issues/107094 |
5 | | - |
6 | | -//@ needs-git-hash |
| 1 | +//! `--version --verbose` should display the git-commit hashes of rustc and rustdoc, but this |
| 2 | +//! functionality was lost due to #104184. After this feature was returned by #109981, this |
| 3 | +//! test ensures it will not be broken again. |
| 4 | +//! See <https://github.com/rust-lang/rust/issues/107094>. |
| 5 | +//! |
| 6 | +//! # Important note |
| 7 | +//! |
| 8 | +//! This test is **not** gated by compiletest, and **cannot** trust bootstrap's git-hash logic e.g. |
| 9 | +//! if bootstrap reports git-hash is available yet the built rustc doesn't actually have a hash. It |
| 10 | +//! must directly communicate with CI, and gate it being run on an env var expected to be set in CI |
| 11 | +//! (or that env var being set locally), `COMPILETEST_HAS_GIT_HASH=1`. |
7 | 12 |
|
8 | 13 | use run_make_support::{bare_rustc, bare_rustdoc, regex}; |
9 | 14 |
|
10 | 15 | fn main() { |
| 16 | + if !std::env::var("COMPILETEST_HAS_GIT_HASH").is_ok_and(|v| v == "1") { |
| 17 | + return; |
| 18 | + } |
| 19 | + |
11 | 20 | let out_rustc = |
12 | 21 | bare_rustc().arg("--version").arg("--verbose").run().stdout_utf8().to_lowercase(); |
13 | 22 | let out_rustdoc = |
14 | 23 | bare_rustdoc().arg("--version").arg("--verbose").run().stdout_utf8().to_lowercase(); |
15 | 24 | let re = |
16 | 25 | regex::Regex::new(r#"commit-hash: [0-9a-f]{40}\ncommit-date: [0-9]{4}-[0-9]{2}-[0-9]{2}"#) |
17 | 26 | .unwrap(); |
| 27 | + |
| 28 | + println!("rustc:\n{}", out_rustc); |
| 29 | + println!("rustdoc:\n{}", out_rustdoc); |
| 30 | + |
18 | 31 | assert!(re.is_match(&out_rustc)); |
19 | 32 | assert!(re.is_match(&out_rustdoc)); |
20 | 33 | } |
0 commit comments