Skip to content

Commit 1a851da

Browse files
committed
Auto merge of #124704 - Urgau:fix-ignored-tests-fmt, r=GuillaumeGomez
Fix ignored tests for formatting This PR fixes the ignored rules in `rustfmt.toml` that were changed in #124613 to allow formatting `rmake.rs` but ended up allowing formatting every Rust files in `tests/`. The fix is a bit involved since we need to workaround a [`.gitignore` pattern limitation](https://git-scm.com/docs/gitignore#_pattern_format): > An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Workaround using https://stackoverflow.com/a/5534865 I tested the fix by changing the formatting in an `rmake.rs` and UI test, and verifying that only the `rmake.rs` files were formatted. Fixes #124613 (comment) cc `@GuillaumeGomez` r? `@onur-ozkan`
2 parents d7ea278 + f43e3e2 commit 1a851da

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rustfmt.toml

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ ignore = [
1313

1414
# tests for now are not formatted, as they are sometimes pretty-printing constrained
1515
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
16+
"/tests/*",
17+
18+
# but we still want to format rmake.rs files in tests/run-make/ so we need to do this
19+
# dance to avoid the parent directory from being excluded
20+
"!/tests/run-make/",
21+
"/tests/run-make/*/*.rs",
1622
"!/tests/run-make/*/rmake.rs",
1723

1824
# do not format submodules

0 commit comments

Comments
 (0)