Skip to content

Commit 5d17f71

Browse files
committed
Changing default fixed test suffix from fixed to fixed.rs
1 parent 1c0adbd commit 5d17f71

24 files changed

+56
-49
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Changed
1717

18+
* Changed default fixed suffix from `fixed` to `fixed.rs` for IDE rendering.
19+
1820
### Removed
1921

2022
## [0.29.0] - 2025-02-25

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ pub fn error_on_output_conflict(
488488
errors: &mut Errors,
489489
config: &TestConfig,
490490
) {
491-
let normalized = config.normalize(output, &path.extension().unwrap().to_string_lossy());
491+
let normalized = config.normalize(output, path);
492492
let expected = std::fs::read(path).unwrap_or_default();
493493
if normalized != expected {
494494
errors.push(Error::OutputDiffers {
@@ -516,7 +516,7 @@ pub fn bless_output_files(path: &Path, output: &[u8], _errors: &mut Errors, conf
516516
if output.is_empty() {
517517
let _ = std::fs::remove_file(path);
518518
} else {
519-
let actual = config.normalize(output, &path.extension().unwrap().to_string_lossy());
519+
let actual = config.normalize(output, path);
520520
std::fs::write(path, actual).unwrap();
521521
}
522522
}

src/custom_flags/rustfix.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,20 @@ impl Flag for RustfixMode {
7070
let fixed_paths = match fixes.as_slice() {
7171
[] => Vec::new(),
7272
[single] => {
73-
vec![config.check_output(single.as_bytes(), &mut errors, "fixed")]
73+
vec![config.check_output(single.as_bytes(), &mut errors, "fixed.rs")]
7474
}
7575
_ => fixes
7676
.iter()
7777
.enumerate()
7878
.map(|(i, fix)| {
79-
config.check_output(fix.as_bytes(), &mut errors, &format!("{}.fixed", i + 1))
79+
config.check_output(fix.as_bytes(), &mut errors, &format!("{}.fixed.rs", i + 1))
8080
})
8181
.collect(),
8282
};
8383

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

8989
if !errors.is_empty() {

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ pub fn run_tests(mut config: Config) -> Result<()> {
102102
/// The filter used by `run_tests` to only run on `.rs` files that are
103103
/// specified by [`Config::filter_files`] and [`Config::skip_files`].
104104
///
105-
/// Returns `None` if there is no extension or the extension is not `.rs`.
105+
/// Returns `None` if there is no extension or the extension is not `.rs`
106+
/// or if the filename ends in `fixed.rs`.
106107
pub fn default_file_filter(path: &Path, config: &Config) -> Option<bool> {
107108
path.extension().filter(|&ext| ext == "rs")?;
109+
path.file_name()
110+
.filter(|f1| f1.to_str().filter(|f2| !f2.ends_with("fixed.rs")).is_some())?;
108111
Some(default_any_file_filter(path, config))
109112
}
110113

src/per_test_config.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use spanned::Spanned;
1717
use std::collections::btree_map::Entry;
1818
use std::collections::BTreeMap;
1919
use std::num::NonZeroUsize;
20-
use std::path::PathBuf;
20+
use std::path::{Path, PathBuf};
2121
use std::process::{Command, Output};
2222
use std::sync::Arc;
2323

@@ -164,11 +164,13 @@ impl TestConfig {
164164
self.status.path().with_extension(ext)
165165
}
166166

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

170172
for (from, to) in self.comments().flat_map(|r| match kind {
171-
_ if kind.ends_with("fixed") => &[] as &[_],
173+
_ if filename.ends_with("fixed.rs") => &[] as &[_],
172174
"stderr" => &r.normalize_stderr,
173175
"stdout" => &r.normalize_stdout,
174176
_ => unreachable!(),

tests/integrations/basic-fail/Cargo.stdout

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,10 @@ tests/actual_tests_bless/run_panic.rs (revision `run`) ... ok
647647
tests/actual_tests_bless/rustfix-fail-revisions.rs ... ok
648648
tests/actual_tests_bless/rustfix-fail-revisions.rs (revision `a`) ... ok
649649
tests/actual_tests_bless/rustfix-fail-revisions.rs (revision `b`) ... ok
650-
tests/actual_tests_bless/rustfix-fail-revisions.a.fixed ... FAILED
651-
tests/actual_tests_bless/rustfix-fail-revisions.b.fixed ... FAILED
650+
tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs ... FAILED
651+
tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs ... FAILED
652652
tests/actual_tests_bless/rustfix-fail.rs ... ok
653-
tests/actual_tests_bless/rustfix-fail.fixed ... FAILED
653+
tests/actual_tests_bless/rustfix-fail.fixed.rs ... FAILED
654654
tests/actual_tests_bless/unicode.rs ... FAILED
655655
tests/actual_tests_bless/unknown_revision.rs ... FAILED
656656
tests/actual_tests_bless/unknown_revision2.rs ... FAILED
@@ -993,25 +993,25 @@ full stdout:
993993

994994

995995

996-
FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.a.fixed
997-
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"
996+
FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs
997+
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"
998998

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

10061006
full stderr:
10071007
error: path statement drops value
1008-
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:11:5
1008+
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs:11:5
10091009
|
10101010
11 | x;
10111011
| ^^ help: use `drop` to clarify the intent: `drop(x);`
10121012
|
10131013
note: the lint level is defined here
1014-
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:2:9
1014+
--> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs:2:9
10151015
|
10161016
2 | #![deny(warnings)]
10171017
| ^^^^^^^^
@@ -1024,25 +1024,25 @@ full stdout:
10241024

10251025

10261026

1027-
FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.b.fixed
1028-
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"
1027+
FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs
1028+
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"
10291029

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

10371037
full stderr:
10381038
error: path statement drops value
1039-
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:11:5
1039+
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs:11:5
10401040
|
10411041
11 | x;
10421042
| ^^ help: use `drop` to clarify the intent: `drop(x);`
10431043
|
10441044
note: the lint level is defined here
1045-
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:2:9
1045+
--> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs:2:9
10461046
|
10471047
2 | #![deny(warnings)]
10481048
| ^^^^^^^^
@@ -1055,25 +1055,25 @@ full stdout:
10551055

10561056

10571057

1058-
FAILED TEST: tests/actual_tests_bless/rustfix-fail.fixed
1059-
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"
1058+
FAILED TEST: tests/actual_tests_bless/rustfix-fail.fixed.rs
1059+
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"
10601060

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

10681068
full stderr:
10691069
error: path statement drops value
1070-
--> tests/actual_tests_bless/rustfix-fail.fixed:10:5
1070+
--> tests/actual_tests_bless/rustfix-fail.fixed.rs:10:5
10711071
|
10721072
10 | x;
10731073
| ^^ help: use `drop` to clarify the intent: `drop(x);`
10741074
|
10751075
note: the lint level is defined here
1076-
--> tests/actual_tests_bless/rustfix-fail.fixed:1:9
1076+
--> tests/actual_tests_bless/rustfix-fail.fixed.rs:1:9
10771077
|
10781078
1 | #![deny(warnings)]
10791079
| ^^^^^^^^
@@ -1217,9 +1217,9 @@ FAILURES:
12171217
tests/actual_tests_bless/revisioned_executable.rs (revision panic.run)
12181218
tests/actual_tests_bless/revisioned_executable_panic.rs (revision run.run)
12191219
tests/actual_tests_bless/revisions_bad.rs (revision bar)
1220-
tests/actual_tests_bless/rustfix-fail-revisions.a.fixed
1221-
tests/actual_tests_bless/rustfix-fail-revisions.b.fixed
1222-
tests/actual_tests_bless/rustfix-fail.fixed
1220+
tests/actual_tests_bless/rustfix-fail-revisions.a.fixed.rs
1221+
tests/actual_tests_bless/rustfix-fail-revisions.b.fixed.rs
1222+
tests/actual_tests_bless/rustfix-fail.fixed.rs
12231223
tests/actual_tests_bless/unicode.rs
12241224
tests/actual_tests_bless/unknown_revision.rs
12251225
tests/actual_tests_bless/unknown_revision2.rs
@@ -1232,33 +1232,33 @@ tests/actual_tests_bless_yolo/revisions_bad.rs ... ok
12321232
tests/actual_tests_bless_yolo/revisions_bad.rs (revision `foo`) ... ok
12331233
tests/actual_tests_bless_yolo/revisions_bad.rs (revision `bar`) ... ok
12341234
tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.rs ... ok
1235-
tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.fixed ... ok
1235+
tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.fixed.rs ... ok
12361236
tests/actual_tests_bless_yolo/rustfix-multiple-fail.rs ... ok
1237-
tests/actual_tests_bless_yolo/rustfix-multiple-fail.1.fixed ... ok
1238-
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed ... FAILED
1239-
tests/actual_tests_bless_yolo/rustfix-multiple-fail.3.fixed ... ok
1237+
tests/actual_tests_bless_yolo/rustfix-multiple-fail.1.fixed.rs ... ok
1238+
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs ... FAILED
1239+
tests/actual_tests_bless_yolo/rustfix-multiple-fail.3.fixed.rs ... ok
12401240

1241-
FAILED TEST: tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed
1242-
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"
1241+
FAILED TEST: tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs
1242+
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"
12431243

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

12511251
full stderr:
12521252
error[E0308]: mismatched types
1253-
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed:7:7
1253+
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs:7:7
12541254
|
12551255
7 | f(1);
12561256
| - ^ expected `&i32`, found integer
12571257
| |
12581258
| arguments to this function are incorrect
12591259
|
12601260
note: function defined here
1261-
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed:1:8
1261+
--> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs:1:8
12621262
|
12631263
1 | pub fn f(_: &i32) -> &i32 {
12641264
| ^ -------
@@ -1275,7 +1275,7 @@ full stdout:
12751275

12761276

12771277
FAILURES:
1278-
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed
1278+
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed.rs
12791279

12801280
test result: FAIL. 1 failed; 7 passed
12811281

tests/integrations/basic/Cargo.stdout

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Building aux file tests/actual_tests/auxiliary/proc_macro_attr.rs ... ok
1212
tests/actual_tests/aux_attr_proc_macro.rs ... ok
1313
Building aux file tests/actual_tests/auxiliary/derive_proc_macro.rs ... ok
1414
tests/actual_tests/aux_derive.rs ... ok
15-
tests/actual_tests/aux_derive.fixed ... ok
15+
tests/actual_tests/aux_derive.fixed.rs ... ok
1616
Building aux file tests/actual_tests/auxiliary/the_proc_macro.rs ... ok
1717
tests/actual_tests/aux_proc_macro.rs ... ok
1818
tests/actual_tests/dep_derive.rs ... ok
@@ -21,22 +21,22 @@ tests/actual_tests/error_above.rs ... ok
2121
tests/actual_tests/executable.rs ... ok
2222
tests/actual_tests/executable.rs (revision `run`) ... ok
2323
tests/actual_tests/foomp-rustfix.rs ... ok
24-
tests/actual_tests/foomp-rustfix.fixed ... ok
24+
tests/actual_tests/foomp-rustfix.fixed.rs ... ok
2525
tests/actual_tests/foomp.rs ... ok
2626
tests/actual_tests/joined_above.rs ... ok
27-
tests/actual_tests/joined_above.fixed ... ok
27+
tests/actual_tests/joined_above.fixed.rs ... ok
2828
tests/actual_tests/joined_below.rs ... ok
29-
tests/actual_tests/joined_below.fixed ... ok
29+
tests/actual_tests/joined_below.fixed.rs ... ok
3030
tests/actual_tests/joined_mixed.rs ... ok
31-
tests/actual_tests/joined_mixed.fixed ... ok
31+
tests/actual_tests/joined_mixed.fixed.rs ... ok
3232
tests/actual_tests/mac_span.rs ... ok
33-
tests/actual_tests/mac_span.fixed ... ok
33+
tests/actual_tests/mac_span.fixed.rs ... ok
3434
tests/actual_tests/match_diagnostic_code.rs ... ok
35-
tests/actual_tests/match_diagnostic_code.fixed ... ok
35+
tests/actual_tests/match_diagnostic_code.fixed.rs ... ok
3636
tests/actual_tests/no_rustfix.rs ... ok
3737
tests/actual_tests/rustfix-multiple.rs ... ok
38-
tests/actual_tests/rustfix-multiple.1.fixed ... ok
39-
tests/actual_tests/rustfix-multiple.2.fixed ... ok
38+
tests/actual_tests/rustfix-multiple.1.fixed.rs ... ok
39+
tests/actual_tests/rustfix-multiple.2.fixed.rs ... ok
4040
tests/actual_tests/stdin.rs ... ok
4141
tests/actual_tests/stdin.rs (revision `run`) ... ok
4242
tests/actual_tests/unicode.rs ... ok

0 commit comments

Comments
 (0)