Skip to content

Commit 3f5723c

Browse files
authoredNov 6, 2020
Rollup merge of #78705 - Mark-Simulacrum:nicer-failure-compiletest, r=jyn514
Print a summary of which test suite failed Especially on CI, where cross-compiling is common and single builder may end up with multiple hosts and multiple targets, it can be annoying to scroll back to the nearest start of test marker. This prints out a summary of the test suite being run directly in compiletest. For example, on a mir-opt failure, this would show something like this: ``` failures: [mir-opt] mir-opt/while-storage.rs test result: FAILED. 140 passed; 1 failed; 2 ignored; 0 measured; 0 filtered out Some tests failed in compiletest suite=mir-opt mode=mir-opt host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu ``` Fixes #78517
2 parents 7931b24 + f289a87 commit 3f5723c

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed
 

‎src/bootstrap/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
10401040
cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite));
10411041
cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
10421042
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
1043+
cmd.arg("--suite").arg(suite);
10431044
cmd.arg("--mode").arg(mode);
10441045
cmd.arg("--target").arg(target.rustc_target_arg());
10451046
cmd.arg("--host").arg(&*compiler.host.triple);

‎src/tools/compiletest/src/common.rs

+4
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ pub struct Config {
224224
/// The test mode, compile-fail, run-fail, ui
225225
pub mode: Mode,
226226

227+
/// The test suite (essentially which directory is running, but without the
228+
/// directory prefix such as src/test)
229+
pub suite: String,
230+
227231
/// The debugger to use in debuginfo mode. Unset otherwise.
228232
pub debugger: Option<Debugger>,
229233

‎src/tools/compiletest/src/header/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fn config() -> Config {
3939
let args = &[
4040
"compiletest",
4141
"--mode=ui",
42+
"--suite=ui",
4243
"--compile-lib-path=",
4344
"--run-lib-path=",
4445
"--rustc-path=",

‎src/tools/compiletest/src/main.rs

+30-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
7070
"compile-fail | run-fail | run-pass-valgrind | pretty | debug-info | codegen | rustdoc \
7171
codegen-units | incremental | run-make | ui | js-doc-test | mir-opt | assembly",
7272
)
73+
.reqopt(
74+
"",
75+
"suite",
76+
"which suite of compile tests to run. used for nicer error reporting.",
77+
"SUITE",
78+
)
7379
.optopt(
7480
"",
7581
"pass",
@@ -201,6 +207,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
201207
build_base: opt_path(matches, "build-base"),
202208
stage_id: matches.opt_str("stage-id").unwrap(),
203209
mode: matches.opt_str("mode").unwrap().parse().expect("invalid mode"),
210+
suite: matches.opt_str("suite").unwrap(),
204211
debugger: None,
205212
run_ignored,
206213
filter: matches.free.first().cloned(),
@@ -340,7 +347,7 @@ pub fn run_tests(config: Config) {
340347
configs.extend(configure_lldb(&config));
341348
}
342349
} else {
343-
configs.push(config);
350+
configs.push(config.clone());
344351
};
345352

346353
let mut tests = Vec::new();
@@ -351,11 +358,32 @@ pub fn run_tests(config: Config) {
351358
let res = test::run_tests_console(&opts, tests);
352359
match res {
353360
Ok(true) => {}
354-
Ok(false) => panic!("Some tests failed"),
361+
Ok(false) => {
362+
// We want to report that the tests failed, but we also want to give
363+
// some indication of just what tests we were running. Especially on
364+
// CI, where there can be cross-compiled tests for a lot of
365+
// architectures, without this critical information it can be quite
366+
// easy to miss which tests failed, and as such fail to reproduce
367+
// the failure locally.
368+
369+
eprintln!(
370+
"Some tests failed in compiletest suite={}{} mode={} host={} target={}",
371+
config.suite,
372+
config.compare_mode.map(|c| format!(" compare_mode={:?}", c)).unwrap_or_default(),
373+
config.mode,
374+
config.host,
375+
config.target
376+
);
377+
378+
std::process::exit(1);
379+
}
355380
Err(e) => {
356381
// We don't know if tests passed or not, but if there was an error
357382
// during testing we don't want to just suceeed (we may not have
358383
// tested something), so fail.
384+
//
385+
// This should realistically "never" happen, so don't try to make
386+
// this a pretty error message.
359387
panic!("I/O failure during tests: {:?}", e);
360388
}
361389
}

0 commit comments

Comments
 (0)
Please sign in to comment.