Skip to content

Commit 65a81f9

Browse files
committed
update compiletest to support testing if rustfix didnt crash
1 parent 81ccf14 commit 65a81f9

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(crate) 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";
@@ -303,6 +306,7 @@ impl TestProps {
303306
dont_check_failure_status: false,
304307
run_rustfix: false,
305308
rustfix_only_machine_applicable: false,
309+
rustfix_dont_test_fixed: false,
306310
assembly_output: None,
307311
should_ice: false,
308312
stderr_per_bitwidth: false,
@@ -543,6 +547,11 @@ impl TestProps {
543547
RUSTFIX_ONLY_MACHINE_APPLICABLE,
544548
&mut self.rustfix_only_machine_applicable,
545549
);
550+
config.set_name_directive(
551+
ln,
552+
RUSTFIX_DONT_TEST_FIXED,
553+
&mut self.rustfix_dont_test_fixed,
554+
);
546555
config.set_name_value_directive(
547556
ln,
548557
ASSEMBLY_OUTPUT,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
260260
"run-pass",
261261
"run-rustfix",
262262
"rustc-env",
263+
"rustfix-dont-test-fixed",
263264
"rustfix-only-machine-applicable",
264265
"should-fail",
265266
"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)