From 37df49059dd1ba8039f12058ef590df6519e1a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 13 Apr 2024 23:03:27 +0200 Subject: [PATCH] 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 --- src/tools/compiletest/src/runtest.rs | 19 ++++++++++++------- tests/crashes/README.md | 5 ++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 759b07abc6e..38d22fef113 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -364,16 +364,21 @@ impl<'test> TestCx<'test> { fn run_crash_test(&self) { let pm = self.pass_mode(); let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm)); - /* - eprintln!("{}", proc_res.status); - eprintln!("{}", proc_res.stdout); - eprintln!("{}", proc_res.stderr); - eprintln!("{}", proc_res.cmdline); - */ + + if std::env::var("COMPILETEST_VERBOSE_CRASHES").is_ok() { + eprintln!("{}", proc_res.status); + eprintln!("{}", proc_res.stdout); + eprintln!("{}", proc_res.stderr); + eprintln!("{}", proc_res.cmdline); + } // if a test does not crash, consider it an error if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) { - 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")); + self.fatal(&format!( + "test no longer crashes/triggers ICE! Please give it a mearningful name, \ + add a doc-comment to the start of the test explaining why it exists and \ + move it to tests/ui or wherever you see fit." + )); } } diff --git a/tests/crashes/README.md b/tests/crashes/README.md index de25c6c1340..dee11e2a3dd 100644 --- a/tests/crashes/README.md +++ b/tests/crashes/README.md @@ -10,4 +10,7 @@ When adding crashes from https://github.com/rust-lang/rust/issues, the issue number should be noted in the file name (12345.rs should suffice) and perhaps also inside the file via `//@ known-bug #4321` -If you happen to fix one of the crashes, please move it to `tests/ui`! :) +If you happen to fix one of the crashes, please move it to a fitting +subdirectory in `tests/ui` and give it a meaningful name. +Also please add a doc comment at the top of the file explaining why +this test exists. :)