Skip to main content

compiletest/runtest/
crashes.rs

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