diff --git a/src/config.rs b/src/config.rs index 73e78f33..67598f99 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,7 +2,7 @@ use crate::{ aux_builds::AuxBuilder, custom_flags::edition::Edition, custom_flags::revision_args::RustcRevisionArgs, custom_flags::run::Run, - custom_flags::rustfix::RustfixMode, custom_flags::Flag, filter::Match, + custom_flags::rustfix_mode::RustfixMode, custom_flags::Flag, filter::Match, }; use crate::{ diagnostics::{self, Diagnostics}, @@ -155,7 +155,7 @@ impl Config { .add_custom("edition", Edition("2021".into())); comment_defaults .base() - .add_custom("rustfix", RustfixMode::MachineApplicable); + .add_custom("rustfix-mode", RustfixMode::MachineApplicable); let filters = vec![ (Match::PathBackslash, b"/".to_vec()), #[cfg(windows)] @@ -197,7 +197,20 @@ impl Config { .custom_comments .insert("no-rustfix", |parser, _args, span| { // args are ignored (can be used as comment) - parser.set_custom_once("no-rustfix", (), span); + parser.set_custom_once("rustfix-mode", RustfixMode::Disabled, span); + }); + + config + .custom_comments + .insert("rustfix-mode", |parser, args, span| { + match args.content.parse::() { + Ok(mode) => { + parser.set_custom_once("rustfix-mode", mode, span); + } + Err(error) => { + parser.error(args.span(), error.to_string()); + } + } }); config diff --git a/src/custom_flags.rs b/src/custom_flags.rs index 51a3ce74..39e8e368 100644 --- a/src/custom_flags.rs +++ b/src/custom_flags.rs @@ -14,7 +14,7 @@ pub mod edition; pub mod revision_args; #[cfg(feature = "rustc")] pub mod run; -pub mod rustfix; +pub mod rustfix_mode; /// Tester-specific flag that gets parsed from `//@` comments. pub trait Flag: Send + Sync + UnwindSafe + RefUnwindSafe + std::fmt::Debug { diff --git a/src/custom_flags/rustfix.rs b/src/custom_flags/rustfix_mode.rs similarity index 95% rename from src/custom_flags/rustfix.rs rename to src/custom_flags/rustfix_mode.rs index 5d72b495..a819f5d0 100644 --- a/src/custom_flags/rustfix.rs +++ b/src/custom_flags/rustfix_mode.rs @@ -8,12 +8,14 @@ use crate::{ per_test_config::{Comments, Revisioned, TestConfig}, Error, Errored, TestOk, }; +use anyhow::bail; use rustfix::{CodeFix, Filter, Suggestion}; use spanned::{Span, Spanned}; use std::{ collections::HashSet, path::{Path, PathBuf}, process::Output, + str::FromStr, sync::Arc, }; @@ -99,6 +101,18 @@ impl Flag for RustfixMode { } } +impl FromStr for RustfixMode { + type Err = anyhow::Error; + fn from_str(s: &str) -> Result { + match s { + "disabled" => Ok(RustfixMode::Disabled), + "everything" => Ok(RustfixMode::Everything), + "machine-applicable" => Ok(RustfixMode::MachineApplicable), + _ => bail!("unknown `RustfixMode`: {s}"), + } + } +} + fn fix(stderr: &[u8], path: &Path, mode: RustfixMode) -> anyhow::Result> { let suggestions = std::str::from_utf8(stderr) .unwrap() diff --git a/tests/integration.rs b/tests/integration.rs index bb3b82da..37916d3d 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -61,7 +61,9 @@ fn main() -> Result<()> { config.filter("RUSTC_ICE=\"0\" ", ""); // The order of the `/deps` directory flag is flaky config.stdout_filter("/deps", ""); + config.stdout_filter("[0-9a-f]+\\.rlib", "$$HASH.rlib"); config.stdout_filter("[0-9a-f]+\\.rmeta", "$$HASH.rmeta"); + config.stdout_filter("[0-9a-f]+\\.so", "$$HASH.so"); // Windows backslashes are sometimes escaped. // Insert the replacement filter at the start to make sure the filter for single backslashes // runs afterwards. diff --git a/tests/integrations/basic-fail/tests/actual_tests_bless/edition_override.rs b/tests/integrations/basic-fail/tests/actual_tests_bless/edition_override.rs index e9ca7af1..55bd7a87 100644 --- a/tests/integrations/basic-fail/tests/actual_tests_bless/edition_override.rs +++ b/tests/integrations/basic-fail/tests/actual_tests_bless/edition_override.rs @@ -1,9 +1,9 @@ -//@edition: 2018 -//@check-pass - -fn main() { - match 42 { - 0...1 => {} - _ => {} - } -} +//@edition: 2018 +//@check-pass + +fn main() { + match 42 { + 0...1 => {} + _ => {} + } +} diff --git a/tests/integrations/basic-fail/tests/actual_tests_bless/normalization_override.rs b/tests/integrations/basic-fail/tests/actual_tests_bless/normalization_override.rs index f8db9550..5f97ef36 100644 --- a/tests/integrations/basic-fail/tests/actual_tests_bless/normalization_override.rs +++ b/tests/integrations/basic-fail/tests/actual_tests_bless/normalization_override.rs @@ -1,7 +1,7 @@ -//@normalize-stderr-test: "NORMALIZATION_OVERRIDE" -> "SUCCESS" - -// Test that the above normalization will be run after the default normalization set in ui_tests_bless.rs - -fn main() { - asdf //~ ERROR: cannot find -} +//@normalize-stderr-test: "NORMALIZATION_OVERRIDE" -> "SUCCESS" + +// Test that the above normalization will be run after the default normalization set in ui_tests_bless.rs + +fn main() { + asdf //~ ERROR: cannot find +} diff --git a/tests/integrations/basic-fail/tests/ui_tests_bless.rs b/tests/integrations/basic-fail/tests/ui_tests_bless.rs index 2fb5e96f..e23bd1e4 100644 --- a/tests/integrations/basic-fail/tests/ui_tests_bless.rs +++ b/tests/integrations/basic-fail/tests/ui_tests_bless.rs @@ -1,5 +1,5 @@ use ui_test::{ - custom_flags::rustfix::RustfixMode, dependencies::DependencyBuilder, spanned::Spanned, *, + custom_flags::rustfix_mode::RustfixMode, dependencies::DependencyBuilder, spanned::Spanned, *, }; fn main() -> ui_test::color_eyre::Result<()> { @@ -29,7 +29,7 @@ fn main() -> ui_test::color_eyre::Result<()> { config .comment_defaults .base() - .set_custom("rustfix", rustfix); + .set_custom("rustfix-mode", rustfix); config .comment_defaults diff --git a/tests/integrations/basic/Cargo.stderr b/tests/integrations/basic/Cargo.stderr new file mode 100644 index 00000000..46ea0e7e --- /dev/null +++ b/tests/integrations/basic/Cargo.stderr @@ -0,0 +1,19 @@ +Error: tests failed + +Location: + $DIR/src/lib.rs:LL:CC +error: test failed, to rerun pass `--test json` + +Caused by: + process didn't exit successfully: `$DIR/target/ui/0/tests/integrations/basic/debug/deps/json-HASH` (exit status: 1) +Error: tests failed + +Location: + $DIR/src/lib.rs:LL:CC +error: test failed, to rerun pass `--test ui_tests` + +Caused by: + process didn't exit successfully: `$DIR/target/ui/0/tests/integrations/basic/debug/deps/ui_tests-HASH` (exit status: 1) +error: 2 targets failed: + `--test json` + `--test ui_tests` diff --git a/tests/integrations/basic/Cargo.stdout b/tests/integrations/basic/Cargo.stdout index b9513e5e..94c608bd 100644 --- a/tests/integrations/basic/Cargo.stdout +++ b/tests/integrations/basic/Cargo.stdout @@ -19,6 +19,10 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini { "type": "test", "event": "started", "name": "tests/actual_tests/mac_span.rs () - tests/actual_tests/mac_span.rs" } { "type": "test", "event": "started", "name": "tests/actual_tests/match_diagnostic_code.rs () - tests/actual_tests/match_diagnostic_code.rs" } { "type": "test", "event": "started", "name": "tests/actual_tests/no_rustfix.rs () - tests/actual_tests/no_rustfix.rs" } +{ "type": "test", "event": "started", "name": "tests/actual_tests/rustfix-mode_disabled.rs () - tests/actual_tests/rustfix-mode_disabled.rs" } +{ "type": "test", "event": "started", "name": "tests/actual_tests/rustfix-mode_everything.rs () - tests/actual_tests/rustfix-mode_everything.rs" } +{ "type": "test", "event": "started", "name": "tests/actual_tests/rustfix-mode_invalid.rs () - tests/actual_tests/rustfix-mode_invalid.rs" } +{ "type": "test", "event": "started", "name": "tests/actual_tests/rustfix-mode_machine-applicable.rs () - tests/actual_tests/rustfix-mode_machine-applicable.rs" } { "type": "test", "event": "started", "name": "tests/actual_tests/rustfix-multiple.rs () - tests/actual_tests/rustfix-multiple.rs" } { "type": "test", "event": "started", "name": "tests/actual_tests/stdin.rs () - tests/actual_tests/stdin.rs" } { "type": "test", "event": "started", "name": "tests/actual_tests/unicode.rs () - tests/actual_tests/unicode.rs" } @@ -53,6 +57,10 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini { "type": "test", "event": "ok", "name": "tests/actual_tests/match_diagnostic_code.rs () - tests/actual_tests/match_diagnostic_code.rs" } { "type": "test", "event": "ok", "name": "tests/actual_tests/match_diagnostic_code.rs () - tests/actual_tests/match_diagnostic_code.fixed" } { "type": "test", "event": "ok", "name": "tests/actual_tests/no_rustfix.rs () - tests/actual_tests/no_rustfix.rs" } +{ "type": "test", "event": "failed", "name": "tests/actual_tests/rustfix-mode_disabled.rs () - tests/actual_tests/rustfix-mode_disabled.rs", "stdout": "command: <\"rustc\" \"--error-format=json\" \"--out-dir\" \"$DIR/tests/integrations/basic/../../../target/$TMP/0/tests/actual_tests\" \"tests/actual_tests/rustfix-mode_disabled.rs\" \"--extern\" \"quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rlib\" \"--extern\" \"quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rmeta\" \"--extern\" \"serde_derive=$DIR/tests/integrations/basic/../../../target/$TMP/0/debug/libserde_derive-$HASH.so\" \"--extern\" \"basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasic.a\" \"--extern\" \"basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasi$HASH.rlib\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/0/debug\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug\" \"--edition\" \"2021\"> stdout: tests/actual_tests/rustfix-mode_disabled.rs:4:12\n |\n4 | pub static x: u32 = 0;\n | ^ help: convert the identifier to upper case (notice the capitalization): `X`\n |\n = note: `#[warn(non_upper_case_globals)]` on by default\n\nwarning: static variable `y` should have an upper case name\n --> tests/actual_tests/rustfix-mode_disabled.rs:7:16\n |\n7 | pub static y: u32 = 0;\n | ^ help: convert the identifier to upper case (notice the capitalization): `Y`\n\nwarning: 2 warnings emitted\n\n> stderr: <>" } +{ "type": "test", "event": "failed", "name": "tests/actual_tests/rustfix-mode_everything.rs () - tests/actual_tests/rustfix-mode_everything.rs", "stdout": "command: <\"rustc\" \"--error-format=json\" \"--out-dir\" \"$DIR/tests/integrations/basic/../../../target/$TMP/0/tests/actual_tests\" \"tests/actual_tests/rustfix-mode_everything.rs\" \"--extern\" \"quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rlib\" \"--extern\" \"quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rmeta\" \"--extern\" \"serde_derive=$DIR/tests/integrations/basic/../../../target/$TMP/0/debug/libserde_derive-$HASH.so\" \"--extern\" \"basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasic.a\" \"--extern\" \"basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasi$HASH.rlib\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/0/debug\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug\" \"--edition\" \"2021\"> stdout: tests/actual_tests/rustfix-mode_everything.rs:4:12\n |\n4 | pub static x: u32 = 0;\n | ^ help: convert the identifier to upper case (notice the capitalization): `X`\n |\n = note: `#[warn(non_upper_case_globals)]` on by default\n\nwarning: static variable `y` should have an upper case name\n --> tests/actual_tests/rustfix-mode_everything.rs:7:16\n |\n7 | pub static y: u32 = 0;\n | ^ help: convert the identifier to upper case (notice the capitalization): `Y`\n\nwarning: 2 warnings emitted\n\n> stderr: <>" } +{ "type": "test", "event": "failed", "name": "tests/actual_tests/rustfix-mode_invalid.rs () - tests/actual_tests/rustfix-mode_invalid.rs", "stdout": "command: stdout: <> stderr: <>" } +{ "type": "test", "event": "failed", "name": "tests/actual_tests/rustfix-mode_machine-applicable.rs () - tests/actual_tests/rustfix-mode_machine-applicable.rs", "stdout": "command: <\"rustc\" \"--error-format=json\" \"--out-dir\" \"$DIR/tests/integrations/basic/../../../target/$TMP/0/tests/actual_tests\" \"tests/actual_tests/rustfix-mode_machine-applicable.rs\" \"--extern\" \"quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rlib\" \"--extern\" \"quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rmeta\" \"--extern\" \"serde_derive=$DIR/tests/integrations/basic/../../../target/$TMP/0/debug/libserde_derive-$HASH.so\" \"--extern\" \"basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasic.a\" \"--extern\" \"basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasi$HASH.rlib\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/0/debug\" \"-L\" \"$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug\" \"--edition\" \"2021\"> stdout: tests/actual_tests/rustfix-mode_machine-applicable.rs:4:12\n |\n4 | pub static x: u32 = 0;\n | ^ help: convert the identifier to upper case (notice the capitalization): `X`\n |\n = note: `#[warn(non_upper_case_globals)]` on by default\n\nwarning: static variable `y` should have an upper case name\n --> tests/actual_tests/rustfix-mode_machine-applicable.rs:7:16\n |\n7 | pub static y: u32 = 0;\n | ^ help: convert the identifier to upper case (notice the capitalization): `Y`\n\nwarning: 2 warnings emitted\n\n> stderr: <>" } { "type": "test", "event": "ok", "name": "tests/actual_tests/rustfix-multiple.rs () - tests/actual_tests/rustfix-multiple.rs" } { "type": "test", "event": "ok", "name": "tests/actual_tests/rustfix-multiple.rs () - tests/actual_tests/rustfix-multiple.1.fixed" } { "type": "test", "event": "ok", "name": "tests/actual_tests/rustfix-multiple.rs () - tests/actual_tests/rustfix-multiple.2.fixed" } @@ -61,7 +69,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini { "type": "test", "event": "ok", "name": "tests/actual_tests/unicode.rs () - tests/actual_tests/unicode.rs" } { "type": "test", "event": "ok", "name": "tests/actual_tests/windows_paths.rs () - tests/actual_tests/windows_paths.rs" } { "type": "test", "event": "ok", "name": "tests/actual_tests/subdir/aux_proc_macro.rs () - tests/actual_tests/subdir/aux_proc_macro.rs" } -{ "type": "suite", "event": "ok", "passed": 33, "failed": 0, "ignored": 0, "measured": 0, "filtered_out": 0 } +{ "type": "suite", "event": "failed", "passed": 33, "failed": 4, "ignored": 0, "measured": 0, "filtered_out": 0 } running 3 tests ... @@ -96,6 +104,10 @@ tests/actual_tests/mac_span.fixed ... ok tests/actual_tests/match_diagnostic_code.rs ... ok tests/actual_tests/match_diagnostic_code.fixed ... ok tests/actual_tests/no_rustfix.rs ... ok +tests/actual_tests/rustfix-mode_disabled.rs ... FAILED +tests/actual_tests/rustfix-mode_everything.rs ... FAILED +tests/actual_tests/rustfix-mode_invalid.rs ... FAILED +tests/actual_tests/rustfix-mode_machine-applicable.rs ... FAILED tests/actual_tests/rustfix-multiple.rs ... ok tests/actual_tests/rustfix-multiple.1.fixed ... ok tests/actual_tests/rustfix-multiple.2.fixed ... ok @@ -105,7 +117,118 @@ tests/actual_tests/unicode.rs ... ok tests/actual_tests/windows_paths.rs ... ok tests/actual_tests/subdir/aux_proc_macro.rs ... ok -test result: ok. 33 passed +FAILED TEST: tests/actual_tests/rustfix-mode_disabled.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/rustfix-mode_disabled.rs" "--extern" "quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rlib" "--extern" "quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rmeta" "--extern" "serde_derive=$DIR/tests/integrations/basic/../../../target/$TMP/0/debug/libserde_derive-$HASH.so" "--extern" "basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasic.a" "--extern" "basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasi$HASH.rlib" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/0/debug" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" + +error: test got exit status: 0, but expected 1 + = note: compilation succeeded, but was expected to fail + +error: expected error patterns, but found none + +full stderr: +warning: static variable `x` should have an upper case name + --> tests/actual_tests/rustfix-mode_disabled.rs:4:12 + | +4 | pub static x: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `X` + | + = note: `#[warn(non_upper_case_globals)]` on by default + +warning: static variable `y` should have an upper case name + --> tests/actual_tests/rustfix-mode_disabled.rs:7:16 + | +7 | pub static y: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `Y` + +warning: 2 warnings emitted + + +full stdout: + + + +FAILED TEST: tests/actual_tests/rustfix-mode_everything.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/rustfix-mode_everything.rs" "--extern" "quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rlib" "--extern" "quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rmeta" "--extern" "serde_derive=$DIR/tests/integrations/basic/../../../target/$TMP/0/debug/libserde_derive-$HASH.so" "--extern" "basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasic.a" "--extern" "basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasi$HASH.rlib" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/0/debug" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" + +error: test got exit status: 0, but expected 1 + = note: compilation succeeded, but was expected to fail + +error: expected error patterns, but found none + +full stderr: +warning: static variable `x` should have an upper case name + --> tests/actual_tests/rustfix-mode_everything.rs:4:12 + | +4 | pub static x: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `X` + | + = note: `#[warn(non_upper_case_globals)]` on by default + +warning: static variable `y` should have an upper case name + --> tests/actual_tests/rustfix-mode_everything.rs:7:16 + | +7 | pub static y: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `Y` + +warning: 2 warnings emitted + + +full stdout: + + + +FAILED TEST: tests/actual_tests/rustfix-mode_invalid.rs +command: parse comments + +error: unknown `RustfixMode`: invalid + --> tests/actual_tests/rustfix-mode_invalid.rs:1:18 + | +1 | //@rustfix-mode: invalid + | ^^^^^^^ + | + +full stderr: + +full stdout: + + + +FAILED TEST: tests/actual_tests/rustfix-mode_machine-applicable.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/rustfix-mode_machine-applicable.rs" "--extern" "quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rlib" "--extern" "quote=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libquote-$HASH.rmeta" "--extern" "serde_derive=$DIR/tests/integrations/basic/../../../target/$TMP/0/debug/libserde_derive-$HASH.so" "--extern" "basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasic.a" "--extern" "basic=$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug/libbasi$HASH.rlib" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/0/debug" "-L" "$DIR/tests/integrations/basic/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" + +error: test got exit status: 0, but expected 1 + = note: compilation succeeded, but was expected to fail + +error: expected error patterns, but found none + +full stderr: +warning: static variable `x` should have an upper case name + --> tests/actual_tests/rustfix-mode_machine-applicable.rs:4:12 + | +4 | pub static x: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `X` + | + = note: `#[warn(non_upper_case_globals)]` on by default + +warning: static variable `y` should have an upper case name + --> tests/actual_tests/rustfix-mode_machine-applicable.rs:7:16 + | +7 | pub static y: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `Y` + +warning: 2 warnings emitted + + +full stdout: + + +FAILURES: + tests/actual_tests/rustfix-mode_disabled.rs + tests/actual_tests/rustfix-mode_everything.rs + tests/actual_tests/rustfix-mode_invalid.rs + tests/actual_tests/rustfix-mode_machine-applicable.rs + +test result: FAIL. 4 failed; 33 passed running 0 tests diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.fixed b/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.fixed new file mode 100644 index 00000000..e86a897b --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.fixed @@ -0,0 +1,10 @@ +//@rustfix-mode: disabled +#![allow(dead_code)] + +pub static x: u32 = 0; + +mod internal { + pub static y: u32 = 0; +} + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.rs b/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.rs new file mode 100644 index 00000000..e86a897b --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.rs @@ -0,0 +1,10 @@ +//@rustfix-mode: disabled +#![allow(dead_code)] + +pub static x: u32 = 0; + +mod internal { + pub static y: u32 = 0; +} + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.stderr b/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.stderr new file mode 100644 index 00000000..032fe020 --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_disabled.stderr @@ -0,0 +1,16 @@ +warning: static variable `x` should have an upper case name + --> tests/actual_tests/rustfix-mode_disabled.rs:4:12 + | +4 | pub static x: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `X` + | + = note: `#[warn(non_upper_case_globals)]` on by default + +warning: static variable `y` should have an upper case name + --> tests/actual_tests/rustfix-mode_disabled.rs:7:16 + | +7 | pub static y: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `Y` + +warning: 2 warnings emitted + diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.fixed b/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.fixed new file mode 100644 index 00000000..2b4715b9 --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.fixed @@ -0,0 +1,10 @@ +//@rustfix-mode: everything +#![allow(dead_code)] + +pub static X: u32 = 0; + +mod internal { + pub static Y: u32 = 0; +} + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.rs b/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.rs new file mode 100644 index 00000000..36c1b6d0 --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.rs @@ -0,0 +1,10 @@ +//@rustfix-mode: everything +#![allow(dead_code)] + +pub static x: u32 = 0; + +mod internal { + pub static y: u32 = 0; +} + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.stderr b/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.stderr new file mode 100644 index 00000000..16d80f18 --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_everything.stderr @@ -0,0 +1,16 @@ +warning: static variable `x` should have an upper case name + --> tests/actual_tests/rustfix-mode_everything.rs:4:12 + | +4 | pub static x: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `X` + | + = note: `#[warn(non_upper_case_globals)]` on by default + +warning: static variable `y` should have an upper case name + --> tests/actual_tests/rustfix-mode_everything.rs:7:16 + | +7 | pub static y: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `Y` + +warning: 2 warnings emitted + diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_invalid.fixed b/tests/integrations/basic/tests/actual_tests/rustfix-mode_invalid.fixed new file mode 100644 index 00000000..241e5b3d --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_invalid.fixed @@ -0,0 +1,10 @@ +//@rustfix-mode: invalid +#![allow(dead_code)] + +pub static x: u32 = 0; + +mod internal { + pub static y: u32 = 0; +} + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_invalid.rs b/tests/integrations/basic/tests/actual_tests/rustfix-mode_invalid.rs new file mode 100644 index 00000000..241e5b3d --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_invalid.rs @@ -0,0 +1,10 @@ +//@rustfix-mode: invalid +#![allow(dead_code)] + +pub static x: u32 = 0; + +mod internal { + pub static y: u32 = 0; +} + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.fixed b/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.fixed new file mode 100644 index 00000000..e48d2b51 --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.fixed @@ -0,0 +1,10 @@ +//@rustfix-mode: machine-applicable +#![allow(dead_code)] + +pub static x: u32 = 0; + +mod internal { + pub static Y: u32 = 0; +} + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.rs b/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.rs new file mode 100644 index 00000000..984b8e61 --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.rs @@ -0,0 +1,10 @@ +//@rustfix-mode: machine-applicable +#![allow(dead_code)] + +pub static x: u32 = 0; + +mod internal { + pub static y: u32 = 0; +} + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.stderr b/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.stderr new file mode 100644 index 00000000..4a618d94 --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/rustfix-mode_machine-applicable.stderr @@ -0,0 +1,16 @@ +warning: static variable `x` should have an upper case name + --> tests/actual_tests/rustfix-mode_machine-applicable.rs:4:12 + | +4 | pub static x: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `X` + | + = note: `#[warn(non_upper_case_globals)]` on by default + +warning: static variable `y` should have an upper case name + --> tests/actual_tests/rustfix-mode_machine-applicable.rs:7:16 + | +7 | pub static y: u32 = 0; + | ^ help: convert the identifier to upper case (notice the capitalization): `Y` + +warning: 2 warnings emitted + diff --git a/tests/integrations/basic/tests/json.rs b/tests/integrations/basic/tests/json.rs index 5096ffb3..f745d310 100644 --- a/tests/integrations/basic/tests/json.rs +++ b/tests/integrations/basic/tests/json.rs @@ -1,4 +1,4 @@ -use ui_test::{custom_flags::rustfix::RustfixMode, dependencies::DependencyBuilder, *}; +use ui_test::{custom_flags::rustfix_mode::RustfixMode, dependencies::DependencyBuilder, *}; fn main() -> ui_test::color_eyre::Result<()> { let path = "../../../target"; @@ -22,7 +22,7 @@ fn main() -> ui_test::color_eyre::Result<()> { config .comment_defaults .base() - .set_custom("rustfix", RustfixMode::Everything); + .set_custom("rustfix-mode", RustfixMode::Everything); if let Ok(target) = std::env::var("UITEST_TEST_TARGET") { config.target = Some(target); diff --git a/tests/integrations/basic/tests/ui_tests.rs b/tests/integrations/basic/tests/ui_tests.rs index 9d51f43e..1e185337 100644 --- a/tests/integrations/basic/tests/ui_tests.rs +++ b/tests/integrations/basic/tests/ui_tests.rs @@ -1,4 +1,4 @@ -use ui_test::{custom_flags::rustfix::RustfixMode, dependencies::DependencyBuilder, *}; +use ui_test::{custom_flags::rustfix_mode::RustfixMode, dependencies::DependencyBuilder, *}; fn main() -> ui_test::color_eyre::Result<()> { let path = "../../../target"; @@ -22,7 +22,7 @@ fn main() -> ui_test::color_eyre::Result<()> { config .comment_defaults .base() - .set_custom("rustfix", RustfixMode::Everything); + .set_custom("rustfix-mode", RustfixMode::Everything); if let Ok(target) = std::env::var("UITEST_TEST_TARGET") { config.target = Some(target);