Skip to content

Commit 4fa99d6

Browse files
committed
Normalize rust version string in UI test mode
As `$RUST_VERSION`.
1 parent fe07c87 commit 4fa99d6

File tree

4 files changed

+147
-147
lines changed

4 files changed

+147
-147
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,8 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
16391639

16401640
let mut cmd = builder.tool_cmd(Tool::Compiletest);
16411641

1642+
cmd.arg("--rust-version").arg(builder.rust_version());
1643+
16421644
if suite == "mir-opt" {
16431645
builder.ensure(compile::Std::new(compiler, target).is_for_mir_opt_tests(true));
16441646
} else {

src/tools/compiletest/src/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ pub struct Config {
181181
/// May run a few more tests before stopping, due to threading.
182182
pub fail_fast: bool,
183183

184+
/// E.g. `1.89.0-beta.1 (88b80702e 2025-06-23)`, used for UI normalizations.
185+
pub rust_version: String,
186+
184187
/// The library paths required for running the compiler.
185188
pub compile_lib_path: Utf8PathBuf,
186189

src/tools/compiletest/src/lib.rs

Lines changed: 138 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -58,157 +58,144 @@ pub fn parse_config(args: Vec<String>) -> Config {
5858
}
5959

6060
let mut opts = Options::new();
61-
opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
62-
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
63-
.reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH")
64-
.optopt("", "cargo-path", "path to cargo to use for compiling", "PATH")
65-
.optopt(
66-
"",
67-
"stage0-rustc-path",
68-
"path to rustc to use for compiling run-make recipes",
69-
"PATH",
70-
)
71-
.optopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH")
72-
.optopt("", "coverage-dump-path", "path to coverage-dump to use in tests", "PATH")
73-
.reqopt("", "python", "path to python to use for doc tests", "PATH")
74-
.optopt("", "jsondocck-path", "path to jsondocck to use for doc tests", "PATH")
75-
.optopt("", "jsondoclint-path", "path to jsondoclint to use for doc tests", "PATH")
76-
.optopt("", "run-clang-based-tests-with", "path to Clang executable", "PATH")
77-
.optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR")
78-
.reqopt("", "src-root", "directory containing sources", "PATH")
79-
.reqopt("", "src-test-suite-root", "directory containing test suite sources", "PATH")
80-
.reqopt("", "build-root", "path to root build directory", "PATH")
81-
.reqopt("", "build-test-suite-root", "path to test suite specific build directory", "PATH")
82-
.reqopt("", "sysroot-base", "directory containing the compiler sysroot", "PATH")
83-
.reqopt("", "stage", "stage number under test", "N")
84-
.reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET")
85-
.reqopt(
86-
"",
87-
"mode",
88-
"which sort of compile tests to run",
89-
"pretty | debug-info | codegen | rustdoc \
61+
opts.reqopt(
62+
"",
63+
"rust-version",
64+
"rust version info (e.g. `1.89.0-beta.1 (88b80702e 2025-06-23)`)",
65+
"VERSION STRING",
66+
)
67+
.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
68+
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
69+
.reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH")
70+
.optopt("", "cargo-path", "path to cargo to use for compiling", "PATH")
71+
.optopt("", "stage0-rustc-path", "path to rustc to use for compiling run-make recipes", "PATH")
72+
.optopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH")
73+
.optopt("", "coverage-dump-path", "path to coverage-dump to use in tests", "PATH")
74+
.reqopt("", "python", "path to python to use for doc tests", "PATH")
75+
.optopt("", "jsondocck-path", "path to jsondocck to use for doc tests", "PATH")
76+
.optopt("", "jsondoclint-path", "path to jsondoclint to use for doc tests", "PATH")
77+
.optopt("", "run-clang-based-tests-with", "path to Clang executable", "PATH")
78+
.optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR")
79+
.reqopt("", "src-root", "directory containing sources", "PATH")
80+
.reqopt("", "src-test-suite-root", "directory containing test suite sources", "PATH")
81+
.reqopt("", "build-root", "path to root build directory", "PATH")
82+
.reqopt("", "build-test-suite-root", "path to test suite specific build directory", "PATH")
83+
.reqopt("", "sysroot-base", "directory containing the compiler sysroot", "PATH")
84+
.reqopt("", "stage", "stage number under test", "N")
85+
.reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET")
86+
.reqopt(
87+
"",
88+
"mode",
89+
"which sort of compile tests to run",
90+
"pretty | debug-info | codegen | rustdoc \
9091
| rustdoc-json | codegen-units | incremental | run-make | ui \
9192
| rustdoc-js | mir-opt | assembly | crashes",
92-
)
93-
.reqopt(
94-
"",
95-
"suite",
96-
"which suite of compile tests to run. used for nicer error reporting.",
97-
"SUITE",
98-
)
99-
.optopt(
100-
"",
101-
"pass",
102-
"force {check,build,run}-pass tests to this mode.",
103-
"check | build | run",
104-
)
105-
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
106-
.optflag("", "ignored", "run tests marked as ignored")
107-
.optflag("", "has-enzyme", "run tests that require enzyme")
108-
.optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
109-
.optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
110-
.optmulti(
111-
"",
112-
"skip",
113-
"skip tests matching SUBSTRING. Can be passed multiple times",
114-
"SUBSTRING",
115-
)
116-
.optflag("", "exact", "filters match exactly")
117-
.optopt(
118-
"",
119-
"runner",
120-
"supervisor program to run tests under \
93+
)
94+
.reqopt(
95+
"",
96+
"suite",
97+
"which suite of compile tests to run. used for nicer error reporting.",
98+
"SUITE",
99+
)
100+
.optopt("", "pass", "force {check,build,run}-pass tests to this mode.", "check | build | run")
101+
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
102+
.optflag("", "ignored", "run tests marked as ignored")
103+
.optflag("", "has-enzyme", "run tests that require enzyme")
104+
.optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
105+
.optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
106+
.optmulti(
107+
"",
108+
"skip",
109+
"skip tests matching SUBSTRING. Can be passed multiple times",
110+
"SUBSTRING",
111+
)
112+
.optflag("", "exact", "filters match exactly")
113+
.optopt(
114+
"",
115+
"runner",
116+
"supervisor program to run tests under \
121117
(eg. emulator, valgrind)",
122-
"PROGRAM",
123-
)
124-
.optmulti("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS")
125-
.optmulti("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS")
126-
.optflag(
127-
"",
128-
"rust-randomized-layout",
129-
"set this when rustc/stdlib were compiled with randomized layouts",
130-
)
131-
.optflag("", "optimize-tests", "run tests with optimizations enabled")
132-
.optflag("", "verbose", "run tests verbosely, showing all output")
133-
.optflag(
134-
"",
135-
"bless",
136-
"overwrite stderr/stdout files instead of complaining about a mismatch",
137-
)
138-
.optflag("", "fail-fast", "stop as soon as possible after any test fails")
139-
.optflag("", "quiet", "print one character per test instead of one line")
140-
.optopt("", "color", "coloring: auto, always, never", "WHEN")
141-
.optflag("", "json", "emit json output instead of plaintext output")
142-
.optopt("", "target", "the target to build for", "TARGET")
143-
.optopt("", "host", "the host to build for", "HOST")
144-
.optopt("", "cdb", "path to CDB to use for CDB debuginfo tests", "PATH")
145-
.optopt("", "gdb", "path to GDB to use for GDB debuginfo tests", "PATH")
146-
.optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING")
147-
.optopt("", "llvm-version", "the version of LLVM used", "VERSION STRING")
148-
.optflag("", "system-llvm", "is LLVM the system LLVM")
149-
.optopt("", "android-cross-path", "Android NDK standalone path", "PATH")
150-
.optopt("", "adb-path", "path to the android debugger", "PATH")
151-
.optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH")
152-
.optopt("", "lldb-python-dir", "directory containing LLDB's python module", "PATH")
153-
.reqopt("", "cc", "path to a C compiler", "PATH")
154-
.reqopt("", "cxx", "path to a C++ compiler", "PATH")
155-
.reqopt("", "cflags", "flags for the C compiler", "FLAGS")
156-
.reqopt("", "cxxflags", "flags for the CXX compiler", "FLAGS")
157-
.optopt("", "ar", "path to an archiver", "PATH")
158-
.optopt("", "target-linker", "path to a linker for the target", "PATH")
159-
.optopt("", "host-linker", "path to a linker for the host", "PATH")
160-
.reqopt("", "llvm-components", "list of LLVM components built in", "LIST")
161-
.optopt("", "llvm-bin-dir", "Path to LLVM's `bin` directory", "PATH")
162-
.optopt("", "nodejs", "the name of nodejs", "PATH")
163-
.optopt("", "npm", "the name of npm", "PATH")
164-
.optopt("", "remote-test-client", "path to the remote test client", "PATH")
165-
.optopt(
166-
"",
167-
"compare-mode",
168-
"mode describing what file the actual ui output will be compared to",
169-
"COMPARE MODE",
170-
)
171-
.optflag(
172-
"",
173-
"rustfix-coverage",
174-
"enable this to generate a Rustfix coverage file, which is saved in \
118+
"PROGRAM",
119+
)
120+
.optmulti("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS")
121+
.optmulti("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS")
122+
.optflag(
123+
"",
124+
"rust-randomized-layout",
125+
"set this when rustc/stdlib were compiled with randomized layouts",
126+
)
127+
.optflag("", "optimize-tests", "run tests with optimizations enabled")
128+
.optflag("", "verbose", "run tests verbosely, showing all output")
129+
.optflag("", "bless", "overwrite stderr/stdout files instead of complaining about a mismatch")
130+
.optflag("", "fail-fast", "stop as soon as possible after any test fails")
131+
.optflag("", "quiet", "print one character per test instead of one line")
132+
.optopt("", "color", "coloring: auto, always, never", "WHEN")
133+
.optflag("", "json", "emit json output instead of plaintext output")
134+
.optopt("", "target", "the target to build for", "TARGET")
135+
.optopt("", "host", "the host to build for", "HOST")
136+
.optopt("", "cdb", "path to CDB to use for CDB debuginfo tests", "PATH")
137+
.optopt("", "gdb", "path to GDB to use for GDB debuginfo tests", "PATH")
138+
.optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING")
139+
.optopt("", "llvm-version", "the version of LLVM used", "VERSION STRING")
140+
.optflag("", "system-llvm", "is LLVM the system LLVM")
141+
.optopt("", "android-cross-path", "Android NDK standalone path", "PATH")
142+
.optopt("", "adb-path", "path to the android debugger", "PATH")
143+
.optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH")
144+
.optopt("", "lldb-python-dir", "directory containing LLDB's python module", "PATH")
145+
.reqopt("", "cc", "path to a C compiler", "PATH")
146+
.reqopt("", "cxx", "path to a C++ compiler", "PATH")
147+
.reqopt("", "cflags", "flags for the C compiler", "FLAGS")
148+
.reqopt("", "cxxflags", "flags for the CXX compiler", "FLAGS")
149+
.optopt("", "ar", "path to an archiver", "PATH")
150+
.optopt("", "target-linker", "path to a linker for the target", "PATH")
151+
.optopt("", "host-linker", "path to a linker for the host", "PATH")
152+
.reqopt("", "llvm-components", "list of LLVM components built in", "LIST")
153+
.optopt("", "llvm-bin-dir", "Path to LLVM's `bin` directory", "PATH")
154+
.optopt("", "nodejs", "the name of nodejs", "PATH")
155+
.optopt("", "npm", "the name of npm", "PATH")
156+
.optopt("", "remote-test-client", "path to the remote test client", "PATH")
157+
.optopt(
158+
"",
159+
"compare-mode",
160+
"mode describing what file the actual ui output will be compared to",
161+
"COMPARE MODE",
162+
)
163+
.optflag(
164+
"",
165+
"rustfix-coverage",
166+
"enable this to generate a Rustfix coverage file, which is saved in \
175167
`./<build_test_suite_root>/rustfix_missing_coverage.txt`",
176-
)
177-
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
178-
.optflag("", "only-modified", "only run tests that result been modified")
179-
// FIXME: Temporarily retained so we can point users to `--no-capture`
180-
.optflag("", "nocapture", "")
181-
.optflag("", "no-capture", "don't capture stdout/stderr of tests")
182-
.optflag("", "profiler-runtime", "is the profiler runtime enabled for this target")
183-
.optflag("h", "help", "show this message")
184-
.reqopt("", "channel", "current Rust channel", "CHANNEL")
185-
.optflag(
186-
"",
187-
"git-hash",
188-
"run tests which rely on commit version being compiled into the binaries",
189-
)
190-
.optopt("", "edition", "default Rust edition", "EDITION")
191-
.reqopt("", "nightly-branch", "name of the git branch for nightly", "BRANCH")
192-
.reqopt(
193-
"",
194-
"git-merge-commit-email",
195-
"email address used for finding merge commits",
196-
"EMAIL",
197-
)
198-
.optopt(
199-
"",
200-
"compiletest-diff-tool",
201-
"What custom diff tool to use for displaying compiletest tests.",
202-
"COMMAND",
203-
)
204-
.reqopt("", "minicore-path", "path to minicore aux library", "PATH")
205-
.optflag("N", "no-new-executor", "disables the new test executor, and uses libtest instead")
206-
.optopt(
207-
"",
208-
"debugger",
209-
"only test a specific debugger in debuginfo tests",
210-
"gdb | lldb | cdb",
211-
);
168+
)
169+
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
170+
.optflag("", "only-modified", "only run tests that result been modified")
171+
// FIXME: Temporarily retained so we can point users to `--no-capture`
172+
.optflag("", "nocapture", "")
173+
.optflag("", "no-capture", "don't capture stdout/stderr of tests")
174+
.optflag("", "profiler-runtime", "is the profiler runtime enabled for this target")
175+
.optflag("h", "help", "show this message")
176+
.reqopt("", "channel", "current Rust channel", "CHANNEL")
177+
.optflag(
178+
"",
179+
"git-hash",
180+
"run tests which rely on commit version being compiled into the binaries",
181+
)
182+
.optopt("", "edition", "default Rust edition", "EDITION")
183+
.reqopt("", "nightly-branch", "name of the git branch for nightly", "BRANCH")
184+
.reqopt("", "git-merge-commit-email", "email address used for finding merge commits", "EMAIL")
185+
.optopt(
186+
"",
187+
"compiletest-diff-tool",
188+
"What custom diff tool to use for displaying compiletest tests.",
189+
"COMMAND",
190+
)
191+
.reqopt("", "minicore-path", "path to minicore aux library", "PATH")
192+
.optflag("N", "no-new-executor", "disables the new test executor, and uses libtest instead")
193+
.optopt(
194+
"",
195+
"debugger",
196+
"only test a specific debugger in debuginfo tests",
197+
"gdb | lldb | cdb",
198+
);
212199

213200
let (argv0, args_) = args.split_first().unwrap();
214201
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
@@ -245,6 +232,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
245232
}
246233
}
247234

235+
let rust_version = opt_str2(matches.opt_str("rust-version"));
248236
let target = opt_str2(matches.opt_str("target"));
249237
let android_cross_path = opt_path(matches, "android-cross-path");
250238
let (cdb, cdb_version) = debuggers::analyze_cdb(matches.opt_str("cdb"), &target);
@@ -333,6 +321,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
333321
fail_fast: matches.opt_present("fail-fast")
334322
|| env::var_os("RUSTC_TEST_FAIL_FAST").is_some(),
335323

324+
rust_version,
336325
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
337326
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
338327
rustc_path: opt_path(matches, "rustc-path"),
@@ -453,6 +442,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
453442
pub fn log_config(config: &Config) {
454443
let c = config;
455444
logv(c, "configuration:".to_string());
445+
446+
logv(c, format!("rust_version: {}", config.rust_version));
456447
logv(c, format!("compile_lib_path: {}", config.compile_lib_path));
457448
logv(c, format!("run_lib_path: {}", config.run_lib_path));
458449
logv(c, format!("rustc_path: {}", config.rustc_path));

src/tools/compiletest/src/runtest.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,6 +2485,10 @@ impl<'test> TestCx<'test> {
24852485
.into_owned();
24862486
}
24872487

2488+
// Normalize out rustc version info strings that may be present in the output (usually for
2489+
// deprecated since diagnostics).
2490+
normalized = normalized.replace(&self.config.rust_version, "$RUST_VERSION");
2491+
24882492
// Custom normalization rules
24892493
for rule in custom_rules {
24902494
let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule");

0 commit comments

Comments
 (0)