Skip to content

Commit 1f778f0

Browse files
committed
move cookiecutter away from tempdir
1 parent 931ff96 commit 1f778f0

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

crates/ruff/tests/format.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,12 @@ fn cookiecutter_globbing() -> Result<()> {
21432143
// The absolute path of the glob contains the glob metacharacters `{{` and `}}` even though the
21442144
// user's glob does not.
21452145
let tempdir = TempDir::new()?;
2146-
let cookiecutter = tempdir.path().join("{{cookiecutter.repo_name}}");
2146+
// add an extra layer here to prevent the regex escapes on `{` from conflicting with the tempdir
2147+
// filter for insta
2148+
let cookiecutter = tempdir
2149+
.path()
2150+
.join("tmp")
2151+
.join("{{cookiecutter.repo_name}}");
21472152
let cookiecutter_toml = cookiecutter.join("pyproject.toml");
21482153
let tests = cookiecutter.join("tests");
21492154
fs::create_dir_all(&tests)?;
@@ -2167,8 +2172,8 @@ fn cookiecutter_globbing() -> Result<()> {
21672172
success: false
21682173
exit_code: 1
21692174
----- stdout -----
2170-
--- {{cookiecutter.repo_name}}/tests/maintest.py
2171-
+++ {{cookiecutter.repo_name}}/tests/maintest.py
2175+
--- tmp/{{cookiecutter.repo_name}}/tests/maintest.py
2176+
+++ tmp/{{cookiecutter.repo_name}}/tests/maintest.py
21722177
@@ -1,3 +1,3 @@
21732178
import foo
21742179
import bar
@@ -2178,7 +2183,7 @@ fn cookiecutter_globbing() -> Result<()> {
21782183
21792184
21802185
----- stderr -----
2181-
warning: Error parsing original glob: `"[TMP]/{{cookiecutter.repo_name}}/tests/*"`, trying with escaped braces: `"[TMP]/[{][{]cookiecutter.repo_name[}][}]/tests/*"`
2186+
warning: Error parsing original glob: `"[TMP]/tmp/{{cookiecutter.repo_name}}/tests/*"`, trying with escaped braces: `"[TMP]/tmp/[{][{]cookiecutter.repo_name[}][}]/tests/*"`
21822187
1 file would be reformatted
21832188
"#);
21842189
});

crates/ruff/tests/lint.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -2711,7 +2711,12 @@ fn cookiecutter_globbing() -> Result<()> {
27112711
// The absolute path of the glob contains the glob metacharacters `{{` and `}}` even though the
27122712
// user's glob does not.
27132713
let tempdir = TempDir::new()?;
2714-
let cookiecutter = tempdir.path().join("{{cookiecutter.repo_name}}");
2714+
// add an extra layer here to prevent the regex escapes on `{` from conflicting with the tempdir
2715+
// filter for insta
2716+
let cookiecutter = tempdir
2717+
.path()
2718+
.join("tmp")
2719+
.join("{{cookiecutter.repo_name}}");
27152720
let cookiecutter_toml = cookiecutter.join("pyproject.toml");
27162721
let tests = cookiecutter.join("tests");
27172722
fs::create_dir_all(&tests)?;
@@ -2740,7 +2745,7 @@ fn cookiecutter_globbing() -> Result<()> {
27402745
All checks passed!
27412746
27422747
----- stderr -----
2743-
warning: Error parsing original glob: `"[TMP]/{{cookiecutter.repo_name}}/tests/*"`, trying with escaped braces: `"[TMP]/[{][{]cookiecutter.repo_name[}][}]/tests/*"`
2748+
warning: Error parsing original glob: `"[TMP]/tmp/{{cookiecutter.repo_name}}/tests/*"`, trying with escaped braces: `"[TMP]/tmp/[{][{]cookiecutter.repo_name[}][}]/tests/*"`
27442749
"#);
27452750
});
27462751

@@ -2752,15 +2757,15 @@ fn cookiecutter_globbing() -> Result<()> {
27522757
.args(STDIN_BASE_OPTIONS)
27532758
.arg("--select=F811")
27542759
.current_dir(tempdir.path()), @r"
2755-
success: false
2756-
exit_code: 1
2757-
----- stdout -----
2758-
{{cookiecutter.repo_name}}/tests/maintest.py:3:8: F811 [*] Redefinition of unused `foo` from line 1
2759-
Found 1 error.
2760-
[*] 1 fixable with the `--fix` option.
2761-
2762-
----- stderr -----
2763-
");
2760+
success: false
2761+
exit_code: 1
2762+
----- stdout -----
2763+
tmp/{{cookiecutter.repo_name}}/tests/maintest.py:3:8: F811 [*] Redefinition of unused `foo` from line 1
2764+
Found 1 error.
2765+
[*] 1 fixable with the `--fix` option.
2766+
2767+
----- stderr -----
2768+
");
27642769
});
27652770

27662771
Ok(())

0 commit comments

Comments
 (0)