Skip to content

Commit 931ff96

Browse files
committed
1 parent 11917c4 commit 931ff96

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

crates/ruff/tests/format.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -2153,9 +2153,14 @@ fn cookiecutter_globbing() -> Result<()> {
21532153
)?;
21542154
let maintest = tests.join("maintest.py");
21552155
fs::write(maintest, "import foo\nimport bar\nimport foo")?;
2156-
insta::with_settings!({
2157-
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/"), (r"\\", "/")]
2158-
}, {
2156+
2157+
let tmp_filter = tempdir_filter(&tempdir);
2158+
let filters = vec![
2159+
(tmp_filter.as_str(), "[TMP]/"),
2160+
(r#"\\(\w\w|\s|\.|")"#, "/$1"),
2161+
];
2162+
2163+
insta::with_settings!({filters => filters}, {
21592164
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
21602165
.args(["format", "--no-cache", "--diff"])
21612166
.current_dir(tempdir.path()), @r#"

crates/ruff/tests/lint.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -2722,9 +2722,14 @@ fn cookiecutter_globbing() -> Result<()> {
27222722
// F811 example from the docs to ensure the glob still works
27232723
let maintest = tests.join("maintest.py");
27242724
fs::write(maintest, "import foo\nimport bar\nimport foo")?;
2725-
insta::with_settings!({
2726-
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/"), (r"\\", "/")]
2727-
}, {
2725+
2726+
let tmp_filter = tempdir_filter(&tempdir);
2727+
let filters = vec![
2728+
(tmp_filter.as_str(), "[TMP]/"),
2729+
(r#"\\(\w\w|\s|\.|")"#, "/$1"),
2730+
];
2731+
2732+
insta::with_settings!({filters => filters.clone()}, {
27282733
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
27292734
.args(STDIN_BASE_OPTIONS)
27302735
.arg("--select=F811")
@@ -2742,9 +2747,7 @@ fn cookiecutter_globbing() -> Result<()> {
27422747
// after removing the config file with the ignore, F811 applies, so the glob worked above
27432748
fs::remove_file(cookiecutter_toml)?;
27442749

2745-
insta::with_settings!({
2746-
filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/"), (r"\\", "/")]
2747-
}, {
2750+
insta::with_settings!({filters => filters}, {
27482751
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
27492752
.args(STDIN_BASE_OPTIONS)
27502753
.arg("--select=F811")

0 commit comments

Comments
 (0)