Skip to content

Change default fixed suffix to fixed.rs #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* Changed default fixed suffix from `fixed` to `fixed.rs` for IDE rendering.

### Removed

## [0.29.0] - 2025-02-25
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ pub fn error_on_output_conflict(
errors: &mut Errors,
config: &TestConfig,
) {
let normalized = config.normalize(output, &path.extension().unwrap().to_string_lossy());
let normalized = config.normalize(output, path);
let expected = std::fs::read(path).unwrap_or_default();
if normalized != expected {
errors.push(Error::OutputDiffers {
Expand Down Expand Up @@ -516,7 +516,7 @@ pub fn bless_output_files(path: &Path, output: &[u8], _errors: &mut Errors, conf
if output.is_empty() {
let _ = std::fs::remove_file(path);
} else {
let actual = config.normalize(output, &path.extension().unwrap().to_string_lossy());
let actual = config.normalize(output, path);
std::fs::write(path, actual).unwrap();
}
}
6 changes: 3 additions & 3 deletions src/custom_flags/rustfix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ impl Flag for RustfixMode {
let fixed_paths = match fixes.as_slice() {
[] => Vec::new(),
[single] => {
vec![config.check_output(single.as_bytes(), &mut errors, "fixed")]
vec![config.check_output(single.as_bytes(), &mut errors, "fixed.rs")]
}
_ => fixes
.iter()
.enumerate()
.map(|(i, fix)| {
config.check_output(fix.as_bytes(), &mut errors, &format!("{}.fixed", i + 1))
config.check_output(fix.as_bytes(), &mut errors, &format!("{}.fixed.rs", i + 1))
})
.collect(),
};

if fixes.len() != 1 {
// Remove an unused .fixed file
config.check_output(&[], &mut errors, "fixed");
config.check_output(&[], &mut errors, "fixed.rs");
}

if !errors.is_empty() {
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ pub fn run_tests(mut config: Config) -> Result<()> {
/// The filter used by `run_tests` to only run on `.rs` files that are
/// specified by [`Config::filter_files`] and [`Config::skip_files`].
///
/// Returns `None` if there is no extension or the extension is not `.rs`.
/// Returns `None` if there is no extension or the extension is not `.rs`
/// or if the filename ends in `fixed.rs`.
pub fn default_file_filter(path: &Path, config: &Config) -> Option<bool> {
path.extension().filter(|&ext| ext == "rs")?;
path.file_name()
.filter(|f1| f1.to_str().filter(|f2| !f2.ends_with("fixed.rs")).is_some())?;
Some(default_any_file_filter(path, config))
}

Expand Down
8 changes: 5 additions & 3 deletions src/per_test_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use spanned::Spanned;
use std::collections::btree_map::Entry;
use std::collections::BTreeMap;
use std::num::NonZeroUsize;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::process::{Command, Output};
use std::sync::Arc;

Expand Down Expand Up @@ -164,11 +164,13 @@ impl TestConfig {
self.status.path().with_extension(ext)
}

pub(crate) fn normalize(&self, text: &[u8], kind: &str) -> Vec<u8> {
pub(crate) fn normalize(&self, text: &[u8], path: &Path) -> Vec<u8> {
let mut text = text.to_owned();
let kind: &str = &path.extension().unwrap().to_string_lossy();
let filename = path.file_name().unwrap().to_string_lossy().to_string();

for (from, to) in self.comments().flat_map(|r| match kind {
_ if kind.ends_with("fixed") => &[] as &[_],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh damn, I need to decouple this rust specific logic from the generic logic

_ if filename.ends_with("fixed.rs") => &[] as &[_],
"stderr" => &r.normalize_stderr,
"stdout" => &r.normalize_stdout,
_ => unreachable!(),
Expand Down
62 changes: 31 additions & 31 deletions tests/integrations/basic-fail/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,10 @@ tests/actual_tests_bless/run_panic.rs (revision `run`) ... ok
tests/actual_tests_bless/rustfix-fail-revisions.rs ... ok
tests/actual_tests_bless/rustfix-fail-revisions.rs (revision `a`) ... ok
tests/actual_tests_bless/rustfix-fail-revisions.rs (revision `b`) ... ok
tests/actual_tests_bless/rustfix-fail-revisions.a.fixed ... FAILED
tests/actual_tests_bless/rustfix-fail-revisions.b.fixed ... FAILED
tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs ... FAILED
tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs ... FAILED
tests/actual_tests_bless/rustfix-fail.rs ... ok
tests/actual_tests_bless/rustfix-fail.fixed ... FAILED
tests/actual_tests_bless/rustfix-fail.fixed.rs ... FAILED
tests/actual_tests_bless/unicode.rs ... FAILED
tests/actual_tests_bless/unknown_revision.rs ... FAILED
tests/actual_tests_bless/unknown_revision2.rs ... FAILED
Expand Down Expand Up @@ -993,25 +993,25 @@ full stdout:



FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.a.fixed
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.a.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1"
FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1"

error: test got exit status: 1, but expected 0
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:2:9
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs:2:9
|
2 | #![deny(warnings)]
| ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't
|

full stderr:
error: path statement drops value
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:11:5
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs:11:5
|
11 | x;
| ^^ help: use `drop` to clarify the intent: `drop(x);`
|
note: the lint level is defined here
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:2:9
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs:2:9
|
2 | #![deny(warnings)]
| ^^^^^^^^
Expand All @@ -1024,25 +1024,25 @@ full stdout:



FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.b.fixed
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.b.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1"
FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1"

error: test got exit status: 1, but expected 0
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:2:9
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs:2:9
|
2 | #![deny(warnings)]
| ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't
|

full stderr:
error: path statement drops value
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:11:5
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs:11:5
|
11 | x;
| ^^ help: use `drop` to clarify the intent: `drop(x);`
|
note: the lint level is defined here
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:2:9
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs:2:9
|
2 | #![deny(warnings)]
| ^^^^^^^^
Expand All @@ -1055,25 +1055,25 @@ full stdout:



FAILED TEST: tests/actual_tests_bless/rustfix-fail.fixed
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_1"
FAILED TEST: tests/actual_tests_bless/rustfix-fail.fixed.rs
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail.fixed.rs" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_1"

error: test got exit status: 1, but expected 0
--> tests/actual_tests_bless/rustfix-fail.fixed:1:9
--> tests/actual_tests_bless/rustfix-fail.fixed.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't
|

full stderr:
error: path statement drops value
--> tests/actual_tests_bless/rustfix-fail.fixed:10:5
--> tests/actual_tests_bless/rustfix-fail.fixed.rs:10:5
|
10 | x;
| ^^ help: use `drop` to clarify the intent: `drop(x);`
|
note: the lint level is defined here
--> tests/actual_tests_bless/rustfix-fail.fixed:1:9
--> tests/actual_tests_bless/rustfix-fail.fixed.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^
Expand Down Expand Up @@ -1217,9 +1217,9 @@ FAILURES:
tests/actual_tests_bless/revisioned_executable.rs (revision panic.run)
tests/actual_tests_bless/revisioned_executable_panic.rs (revision run.run)
tests/actual_tests_bless/revisions_bad.rs (revision bar)
tests/actual_tests_bless/rustfix-fail-revisions.a.fixed
tests/actual_tests_bless/rustfix-fail-revisions.b.fixed
tests/actual_tests_bless/rustfix-fail.fixed
tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs
tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs
tests/actual_tests_bless/rustfix-fail.fixed.rs
tests/actual_tests_bless/unicode.rs
tests/actual_tests_bless/unknown_revision.rs
tests/actual_tests_bless/unknown_revision2.rs
Expand All @@ -1232,33 +1232,33 @@ tests/actual_tests_bless_yolo/revisions_bad.rs ... ok
tests/actual_tests_bless_yolo/revisions_bad.rs (revision `foo`) ... ok
tests/actual_tests_bless_yolo/revisions_bad.rs (revision `bar`) ... ok
tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.rs ... ok
tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.fixed ... ok
tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.fixed.rs ... ok
tests/actual_tests_bless_yolo/rustfix-multiple-fail.rs ... ok
tests/actual_tests_bless_yolo/rustfix-multiple-fail.1.fixed ... ok
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed ... FAILED
tests/actual_tests_bless_yolo/rustfix-multiple-fail.3.fixed ... ok
tests/actual_tests_bless_yolo/rustfix-multiple-fail.1.fixed.rs ... ok
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs ... FAILED
tests/actual_tests_bless_yolo/rustfix-multiple-fail.3.fixed.rs ... ok

FAILED TEST: tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_multiple_fail_2"
FAILED TEST: tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs
command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_multiple_fail_2"

error: test got exit status: 1, but expected 0
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed:1:8
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs:1:8
|
1 | pub fn f(_: &i32) -> &i32 {
| ^ after rustfix is applied, all errors should be gone, but weren't
|

full stderr:
error[E0308]: mismatched types
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed:7:7
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs:7:7
|
7 | f(1);
| - ^ expected `&i32`, found integer
| |
| arguments to this function are incorrect
|
note: function defined here
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed:1:8
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs:1:8
|
1 | pub fn f(_: &i32) -> &i32 {
| ^ -------
Expand All @@ -1275,7 +1275,7 @@ full stdout:


FAILURES:
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs

test result: FAIL. 1 failed; 7 passed

Expand Down
18 changes: 9 additions & 9 deletions tests/integrations/basic/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Building aux file tests/actual_tests/auxiliary/proc_macro_attr.rs ... ok
tests/actual_tests/aux_attr_proc_macro.rs ... ok
Building aux file tests/actual_tests/auxiliary/derive_proc_macro.rs ... ok
tests/actual_tests/aux_derive.rs ... ok
tests/actual_tests/aux_derive.fixed ... ok
tests/actual_tests/aux_derive.fixed.rs ... ok
Building aux file tests/actual_tests/auxiliary/the_proc_macro.rs ... ok
tests/actual_tests/aux_proc_macro.rs ... ok
tests/actual_tests/dep_derive.rs ... ok
Expand All @@ -21,22 +21,22 @@ tests/actual_tests/error_above.rs ... ok
tests/actual_tests/executable.rs ... ok
tests/actual_tests/executable.rs (revision `run`) ... ok
tests/actual_tests/foomp-rustfix.rs ... ok
tests/actual_tests/foomp-rustfix.fixed ... ok
tests/actual_tests/foomp-rustfix.fixed.rs ... ok
tests/actual_tests/foomp.rs ... ok
tests/actual_tests/joined_above.rs ... ok
tests/actual_tests/joined_above.fixed ... ok
tests/actual_tests/joined_above.fixed.rs ... ok
tests/actual_tests/joined_below.rs ... ok
tests/actual_tests/joined_below.fixed ... ok
tests/actual_tests/joined_below.fixed.rs ... ok
tests/actual_tests/joined_mixed.rs ... ok
tests/actual_tests/joined_mixed.fixed ... ok
tests/actual_tests/joined_mixed.fixed.rs ... ok
tests/actual_tests/mac_span.rs ... ok
tests/actual_tests/mac_span.fixed ... ok
tests/actual_tests/mac_span.fixed.rs ... ok
tests/actual_tests/match_diagnostic_code.rs ... ok
tests/actual_tests/match_diagnostic_code.fixed ... ok
tests/actual_tests/match_diagnostic_code.fixed.rs ... ok
tests/actual_tests/no_rustfix.rs ... ok
tests/actual_tests/rustfix-multiple.rs ... ok
tests/actual_tests/rustfix-multiple.1.fixed ... ok
tests/actual_tests/rustfix-multiple.2.fixed ... ok
tests/actual_tests/rustfix-multiple.1.fixed.rs ... ok
tests/actual_tests/rustfix-multiple.2.fixed.rs ... ok
tests/actual_tests/stdin.rs ... ok
tests/actual_tests/stdin.rs (revision `run`) ... ok
tests/actual_tests/unicode.rs ... ok
Expand Down