Skip to content

Commit

Permalink
Rollup merge of rust-lang#124704 - Urgau:fix-ignored-tests-fmt, r=Gui…
Browse files Browse the repository at this point in the history
…llaumeGomez

Fix ignored tests for formatting

This PR fixes the ignored rules in `rustfmt.toml` that were changed in rust-lang#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 rust-lang#124613 (comment)
cc `@GuillaumeGomez`
r? `@onur-ozkan`
  • Loading branch information
matthiaskrgr authored May 4, 2024
2 parents f226a67 + f43e3e2 commit 2ab5f46
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ ignore = [

# tests for now are not formatted, as they are sometimes pretty-printing constrained
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
"/tests/*",

# but we still want to format rmake.rs files in tests/run-make/ so we need to do this
# dance to avoid the parent directory from being excluded
"!/tests/run-make/",
"/tests/run-make/*/*.rs",
"!/tests/run-make/*/rmake.rs",

# do not format submodules
Expand Down

0 comments on commit 2ab5f46

Please sign in to comment.