Skip to content

Commit 7d26571

Browse files
committed
update compiletest to support testing if rustfix didnt crash
1 parent 407ae0a commit 7d26571

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

src/tools/compiletest/src/directives.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ pub struct TestProps {
181181
pub run_rustfix: bool,
182182
// If true, `rustfix` will only apply `MachineApplicable` suggestions.
183183
pub rustfix_only_machine_applicable: bool,
184+
// If true, don't test the fixed program. It's still broken in some way.
185+
pub rustfix_dont_test_fixed: bool,
184186
pub assembly_output: Option<String>,
185187
// If true, the test is expected to ICE
186188
pub should_ice: bool,
@@ -245,6 +247,7 @@ mod directives {
245247
pub const DONT_CHECK_FAILURE_STATUS: &'static str = "dont-check-failure-status";
246248
pub const RUN_RUSTFIX: &'static str = "run-rustfix";
247249
pub const RUSTFIX_ONLY_MACHINE_APPLICABLE: &'static str = "rustfix-only-machine-applicable";
250+
pub const RUSTFIX_DONT_TEST_FIXED: &'static str = "rustfix-dont-test-fixed";
248251
pub const ASSEMBLY_OUTPUT: &'static str = "assembly-output";
249252
pub const STDERR_PER_BITWIDTH: &'static str = "stderr-per-bitwidth";
250253
pub const INCREMENTAL: &'static str = "incremental";
@@ -304,6 +307,7 @@ impl TestProps {
304307
dont_check_failure_status: false,
305308
run_rustfix: false,
306309
rustfix_only_machine_applicable: false,
310+
rustfix_dont_test_fixed: false,
307311
assembly_output: None,
308312
should_ice: false,
309313
stderr_per_bitwidth: false,
@@ -573,6 +577,11 @@ impl TestProps {
573577
RUSTFIX_ONLY_MACHINE_APPLICABLE,
574578
&mut self.rustfix_only_machine_applicable,
575579
);
580+
config.set_name_directive(
581+
ln,
582+
RUSTFIX_DONT_TEST_FIXED,
583+
&mut self.rustfix_dont_test_fixed,
584+
);
576585
config.set_name_value_directive(
577586
ln,
578587
ASSEMBLY_OUTPUT,

src/tools/compiletest/src/directives/directive_names.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
259259
"run-pass",
260260
"run-rustfix",
261261
"rustc-env",
262+
"rustfix-dont-test-fixed",
262263
"rustfix-only-machine-applicable",
263264
"should-fail",
264265
"should-ice",

src/tools/compiletest/src/runtest/ui.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ impl TestCx<'_> {
220220
self.check_all_error_patterns(&output_to_check, pattern_proc_res);
221221
self.check_forbid_output(&output_to_check, pattern_proc_res);
222222

223-
if self.props.run_rustfix && self.config.compare_mode.is_none() {
223+
if self.props.run_rustfix
224+
&& self.config.compare_mode.is_none()
225+
&& !self.props.rustfix_dont_test_fixed
226+
{
224227
// And finally, compile the fixed code and make sure it both
225228
// succeeds and has no diagnostics.
226229
let mut rustc = self.make_compile_args(

tests/ui/parser/attribute/invalid-delimeter-ice-146808.fixed

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// regression test for #146808
22
//@ proc-macro: all_spans_same.rs
33
//@ run-rustfix
4-
//@ rustfix-only-machine-applicable
4+
// the fixed program is still broken, but rustfix didn't crash!
5+
// that's what we want to test here.
6+
//@ rustfix-dont-test-fixed
57

68
extern crate all_spans_same;
79

tests/ui/parser/attribute/invalid-delimeter-ice-146808.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// regression test for #146808
22
//@ proc-macro: all_spans_same.rs
33
//@ run-rustfix
4-
//@ rustfix-only-machine-applicable
4+
// the fixed program is still broken, but rustfix didn't crash!
5+
// that's what we want to test here.
6+
//@ rustfix-dont-test-fixed
57

68
extern crate all_spans_same;
79

tests/ui/parser/attribute/invalid-delimeter-ice-146808.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: wrong meta list delimiters
2-
--> $DIR/invalid-delimeter-ice-146808.rs:8:1
2+
--> $DIR/invalid-delimeter-ice-146808.rs:10:1
33
|
44
LL | #[all_spans_same::all_spans_same]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)