compiletest/runtest/
crashes.rs

1use super::{TestCx, WillExecute};
2
3impl TestCx<'_> {
4    pub(super) fn run_crash_test(&self) {
5        let pm = self.pass_mode();
6        let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm));
7
8        if std::env::var("COMPILETEST_VERBOSE_CRASHES").is_ok() {
9            eprintln!("{}", proc_res.status);
10            eprintln!("{}", proc_res.stdout);
11            eprintln!("{}", proc_res.stderr);
12            eprintln!("{}", proc_res.cmdline);
13        }
14
15        // if a test does not crash, consider it an error
16        if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) {
17            self.fatal(&format!(
18                "crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful \
19                name, add a doc-comment to the start of the test explaining why it exists and \
20                move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR \
21                description ensures that the corresponding ticket is auto-closed upon merge. \
22                If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`."
23            ));
24        }
25    }
26}