Skip to content

Commit 74d823a

Browse files
committed
tests: update version-verbose-commit-hash
- No longer gate by `//@ needs-git-hash`. Instead, check for `COMPILETEST_HAS_GIT_HASH=1` env var being set. - Document the env var and reason for bypassing bootstrap.
1 parent 5afd2d9 commit 74d823a

File tree

1 file changed

+19
-6
lines changed
  • tests/run-make/version-verbose-commit-hash

1 file changed

+19
-6
lines changed
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
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`.
712
813
use run_make_support::{bare_rustc, bare_rustdoc, regex};
914

1015
fn main() {
16+
if !std::env::var("COMPILETEST_HAS_GIT_HASH").is_ok_and(|v| v == "1") {
17+
return;
18+
}
19+
1120
let out_rustc =
1221
bare_rustc().arg("--version").arg("--verbose").run().stdout_utf8().to_lowercase();
1322
let out_rustdoc =
1423
bare_rustdoc().arg("--version").arg("--verbose").run().stdout_utf8().to_lowercase();
1524
let re =
1625
regex::Regex::new(r#"commit-hash: [0-9a-f]{40}\ncommit-date: [0-9]{4}-[0-9]{2}-[0-9]{2}"#)
1726
.unwrap();
27+
28+
println!("rustc:\n{}", out_rustc);
29+
println!("rustdoc:\n{}", out_rustdoc);
30+
1831
assert!(re.is_match(&out_rustc));
1932
assert!(re.is_match(&out_rustdoc));
2033
}

0 commit comments

Comments
 (0)