Skip to content

Commit a2622ef

Browse files
authored
Rollup merge of #155712 - Zalathar:crashes, r=jieyouxu
Forbid `*-pass` and `*-fail` directives in tests/crashes Crash tests are always expected to crash during compilation, so there is no sensible meaning for specifying a pass expectation or a run-fail expectation in a crash test. It could conceivably be useful to use failure expectations to specify whether a crash test requires codegen in order to crash, but currently none of the crash tests try to do that. If that functionality is desired in the future, we can always look into re-adding it after the internals of pass/fail expectations have been cleaned up a bit. --- After this change, pass/fail directives are only allowed in UI tests, which should make it easier to overhaul and simplify their implementation. r? jieyouxu
2 parents 87c27a9 + bcb1af0 commit a2622ef

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/doc/rustc-dev-guide/src/tests/directives.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ See [Controlling pass/fail expectations](ui.md#controlling-passfail-expectations
7070

7171
| Directive | Explanation | Supported test suites | Possible values |
7272
|-----------------------------|---------------------------------------------|-------------------------------------------|-----------------|
73-
| `check-pass` | Building (no codegen) should pass | `ui`, `crashes` | N/A |
74-
| `check-fail` | Building (no codegen) should fail | `ui`, `crashes` | N/A |
75-
| `build-pass` | Building should pass | `ui`, `crashes`, `codegen` | N/A |
76-
| `build-fail` | Building should fail | `ui`, `crashes` | N/A |
77-
| `run-pass` | Program must exit with code `0` | `ui`, `crashes` | N/A |
78-
| `run-fail` | Program must exit with code `1..=127` | `ui`, `crashes` | N/A |
73+
| `check-pass` | Building (no codegen) should pass | `ui` | N/A |
74+
| `check-fail` | Building (no codegen) should fail | `ui` | N/A |
75+
| `build-pass` | Building should pass | `ui` | N/A |
76+
| `build-fail` | Building should fail | `ui` | N/A |
77+
| `run-pass` | Program must exit with code `0` | `ui` | N/A |
78+
| `run-fail` | Program must exit with code `1..=127` | `ui` | N/A |
7979
| `run-crash` | Program must crash | `ui` | N/A |
8080
| `run-fail-or-crash` | Program must `run-fail` or `run-crash` | `ui` | N/A |
81-
| `ignore-pass` | Ignore `--pass` flag | `ui`, `crashes`, `codegen`, `incremental` | N/A |
81+
| `ignore-pass` | Ignore `--pass` flag | `ui` | N/A |
8282
| `dont-check-failure-status` | Don't check exact failure status (i.e. `1`) | `ui`, `incremental` | N/A |
83-
| `failure-status` | On failure, the compiler must exit with this status code. To expect an ICE, use `//@ failure-status: 101`. | `ui`, `crashes`, `incremental` | Any `u16` |
83+
| `failure-status` | On failure, the compiler must exit with this status code. To expect an ICE, use `//@ failure-status: 101`. | `ui`, `incremental` | Any `u16` |
8484
| `should-fail` | Compiletest self-test | All | N/A |
8585

8686
### Controlling output snapshots and normalizations

src/tools/compiletest/src/directives.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ impl TestProps {
408408

409409
fn update_fail_mode(&mut self, ln: &DirectiveLine<'_>, config: &Config) {
410410
let check_ui = |mode: &str| {
411-
// Mode::Crashes may need build-fail in order to trigger llvm errors or stack overflows
412-
if config.mode != TestMode::Ui && config.mode != TestMode::Crashes {
411+
if config.mode != TestMode::Ui {
413412
panic!("`{}-fail` directive is only supported in UI tests", mode);
414413
}
415414
};
@@ -441,7 +440,6 @@ impl TestProps {
441440
fn update_pass_mode(&mut self, ln: &DirectiveLine<'_>, config: &Config) {
442441
let check_no_run = |s| match (config.mode, s) {
443442
(TestMode::Ui, _) => (),
444-
(TestMode::Crashes, _) => (),
445443
(mode, _) => panic!("`{s}` directive is not supported in `{mode}` tests"),
446444
};
447445
let pass_mode = if config.parse_name_directive(ln, "check-pass") {

src/tools/compiletest/src/runtest/crashes.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use super::{TestCx, WillExecute};
1+
use super::{Emit, TestCx, WillExecute};
22

33
impl TestCx<'_> {
44
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));
5+
let proc_res = self.compile_test(WillExecute::No, Emit::None);
76

87
if std::env::var("COMPILETEST_VERBOSE_CRASHES").is_ok() {
98
writeln!(self.stderr, "{}", proc_res.status);

0 commit comments

Comments
 (0)