Skip to content

Commit 37df490

Browse files
committed
update README and add COMPILETEST_VERBOSE_CRASHES env var which when set print stdout, stderr and exit code of "crashes" tests, useful for debugging or adding new tests
1 parent 6d9175f commit 37df490

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/tools/compiletest/src/runtest.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,21 @@ impl<'test> TestCx<'test> {
364364
fn run_crash_test(&self) {
365365
let pm = self.pass_mode();
366366
let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm));
367-
/*
368-
eprintln!("{}", proc_res.status);
369-
eprintln!("{}", proc_res.stdout);
370-
eprintln!("{}", proc_res.stderr);
371-
eprintln!("{}", proc_res.cmdline);
372-
*/
367+
368+
if std::env::var("COMPILETEST_VERBOSE_CRASHES").is_ok() {
369+
eprintln!("{}", proc_res.status);
370+
eprintln!("{}", proc_res.stdout);
371+
eprintln!("{}", proc_res.stderr);
372+
eprintln!("{}", proc_res.cmdline);
373+
}
373374

374375
// if a test does not crash, consider it an error
375376
if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) {
376-
self.fatal(&format!("test no longer crashes/triggers ICE! Please annotate it and add it as test to tests/ui or wherever you see fit"));
377+
self.fatal(&format!(
378+
"test no longer crashes/triggers ICE! Please give it a mearningful name, \
379+
add a doc-comment to the start of the test explaining why it exists and \
380+
move it to tests/ui or wherever you see fit."
381+
));
377382
}
378383
}
379384

tests/crashes/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ When adding crashes from https://github.com/rust-lang/rust/issues, the
1010
issue number should be noted in the file name (12345.rs should suffice)
1111
and perhaps also inside the file via `//@ known-bug #4321`
1212

13-
If you happen to fix one of the crashes, please move it to `tests/ui`! :)
13+
If you happen to fix one of the crashes, please move it to a fitting
14+
subdirectory in `tests/ui` and give it a meaningful name.
15+
Also please add a doc comment at the top of the file explaining why
16+
this test exists. :)

0 commit comments

Comments
 (0)