Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow fmt to run on rmake.rs test files #124613

Merged
merged 2 commits into from
May 3, 2024

Conversation

GuillaumeGomez
Copy link
Member

As discussed with @jieyouxu, rmake.rs from the run-make testsuite would benefit from being formatted as well.

Only thing needed to be done for it to work: allow support for ! in our rustfmt.toml file parsing.

r? @onur-ozkan

@rustbot rustbot added A-meta Area: Issues about the rust-lang/rust repository. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 2, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 2, 2024

Some changes occurred in run-make tests.

cc @jieyouxu

@@ -13,7 +13,7 @@ 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/",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safe to remove this path since it's not whitelisted, nothing will be done on it apparently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by whitelisted? Where is that list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way we build the "walker" with the ignore crate is a bit strange. From what I understood, if something is not added to the list, it's ignored by default.

In this case for example, I removed the tests folder and added rmake.rs files and only the rmake.rs files have been formatted.

Comment on lines +118 to +122
if let Some(ignore) = ignore.strip_prefix('!') {
fmt_override.add(ignore).expect(ignore);
} else {
fmt_override.add(&format!("!{ignore}")).expect(&ignore);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an explanation comment (about why we remove "!" when it is present and add it when it is not present) for this block?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

fmease added a commit to fmease/rust that referenced this pull request May 2, 2024
…support, r=jieyouxu

Cleanup: Rid the `rmake` test runners of `extern crate run_make_support;`

`run_make_support` is part of the *extern prelude* of `rmake` test runners rendering `extern crate run_make_support` redundant:

https://github.com/rust-lang/rust/blob/80451a485b006bd32732c003a54ee7de457d8266/src/tools/compiletest/src/runtest.rs#L3826-L3827

~~Contains some fmt'ing changes because I've enabled format-on-save in my editor and because we don't run `x fmt` for `rmake` test runners yet (this gets addressed by rust-lang#124613). I can revert those if you'd like me to.~~ (reverted)

r? jieyouxu or testing-devex(?) or boostrap(?)
@GuillaumeGomez
Copy link
Member Author

Added a code comment to explain what's going on. :)

@onur-ozkan
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented May 2, 2024

📌 Commit 2134921 has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 2, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 2, 2024
…support, r=jieyouxu

Cleanup: Rid the `rmake` test runners of `extern crate run_make_support;`

`run_make_support` is part of the *extern prelude* of `rmake` test runners rendering `extern crate run_make_support` redundant:

https://github.com/rust-lang/rust/blob/80451a485b006bd32732c003a54ee7de457d8266/src/tools/compiletest/src/runtest.rs#L3826-L3827

~~Contains some fmt'ing changes because I've enabled format-on-save in my editor and because we don't run `x fmt` for `rmake` test runners yet (this gets addressed by rust-lang#124613). I can revert those if you'd like me to.~~ (reverted)

r? jieyouxu or testing-devex(?) or boostrap(?)
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2024
Rollup merge of rust-lang#124622 - fmease:yeet-extern-crate-run_make_support, r=jieyouxu

Cleanup: Rid the `rmake` test runners of `extern crate run_make_support;`

`run_make_support` is part of the *extern prelude* of `rmake` test runners rendering `extern crate run_make_support` redundant:

https://github.com/rust-lang/rust/blob/80451a485b006bd32732c003a54ee7de457d8266/src/tools/compiletest/src/runtest.rs#L3826-L3827

~~Contains some fmt'ing changes because I've enabled format-on-save in my editor and because we don't run `x fmt` for `rmake` test runners yet (this gets addressed by rust-lang#124613). I can revert those if you'd like me to.~~ (reverted)

r? jieyouxu or testing-devex(?) or boostrap(?)
bors added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#124345 (Enable `--check-cfg` by default in UI tests)
 - rust-lang#124412 (io safety: update Unix explanation to use `Arc`)
 - rust-lang#124441 (String.truncate comment microfix (greater or equal))
 - rust-lang#124604 (library/std: Remove unused `gimli-symbolize` feature)

Failed merges:

 - rust-lang#124607 (`rustc_expand` cleanups)
 - rust-lang#124613 (Allow fmt to run on rmake.rs test files)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#124345 (Enable `--check-cfg` by default in UI tests)
 - rust-lang#124412 (io safety: update Unix explanation to use `Arc`)
 - rust-lang#124441 (String.truncate comment microfix (greater or equal))
 - rust-lang#124604 (library/std: Remove unused `gimli-symbolize` feature)

Failed merges:

 - rust-lang#124607 (`rustc_expand` cleanups)
 - rust-lang#124613 (Allow fmt to run on rmake.rs test files)

r? `@ghost`
`@rustbot` modify labels: rollup
@fmease
Copy link
Member

fmease commented May 3, 2024

needs rebase
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 3, 2024
@GuillaumeGomez
Copy link
Member Author

@bors r=onur-ozkan rollup

@bors
Copy link
Contributor

bors commented May 3, 2024

📌 Commit 8f47f97 has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 3, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label May 3, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 3, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#124461 (handle the targets that are missing in stage0)
 - rust-lang#124492 (Generalize `adjust_from_tcx` for `Allocation`)
 - rust-lang#124588 (Use `ObligationCtxt` in favor of `TraitEngine` in many more places)
 - rust-lang#124612 (Add support for inputing via stdin with run-make-support)
 - rust-lang#124613 (Allow fmt to run on rmake.rs test files)
 - rust-lang#124649 (Fix HorizonOS build broken by rust-lang#124210)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 82030f2 into rust-lang:master May 3, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 3, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 3, 2024
Rollup merge of rust-lang#124613 - GuillaumeGomez:fmt-run-make, r=onur-ozkan

Allow fmt to run on rmake.rs test files

As discussed with `@jieyouxu,` `rmake.rs` from the `run-make` testsuite would benefit from being formatted as well.

Only thing needed to be done for it to work: allow support for `!` in our `rustfmt.toml` file parsing.

r? `@onur-ozkan`
@GuillaumeGomez GuillaumeGomez deleted the fmt-run-make branch May 3, 2024 18:50
@Urgau
Copy link
Member

Urgau commented May 4, 2024

I'm seeing errors when trying to run ./x.py fmt locally after a rebase; I looks like rustfmt is trying to format UI tests.

Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
formatting 68 modified files
error: expected identifier, found reserved keyword `try`
   --> /rust/tests/ui/macros/macro-comma-support-rpass.rs:269:4
    |
269 | fn try() {
    |    ^^^ expected identifier, found reserved keyword
    |
help: escape `try` to use it as an identifier
    |
269 | fn r#try() {
    |    ++

error: use of deprecated `try` macro
   --> /rust/tests/ui/macros/macro-comma-support-rpass.rs:271:9
    |
271 |         try!(Ok(()));
    |         ^^^^^^^^^^^^
    |
    = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated
help: you can use the `?` operator instead
    |
271 -         try!(Ok(()));
271 +         Ok(())?;
    |
help: alternatively, you can still access the deprecated `try!()` macro using the "raw identifier" syntax
    |
271 |         r#try!(Ok(()));
    |         ++

error: use of deprecated `try` macro
   --> /home/archie/Projects/RustProjects/rust/tests/ui/macros/macro-comma-support-rpass.rs:272:9
    |
272 |         try!(Ok(()),);
    |         ^^^^^^^^^^^^^
    |
    = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated
help: you can use the `?` operator instead
    |
272 -         try!(Ok(()),);
272 +         Ok(()),?;
    |
help: alternatively, you can still access the deprecated `try!()` macro using the "raw identifier" syntax
    |
272 |         r#try!(Ok(()),);
    |         ++

Running `"/rust/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/rust" "--edition" "2021" "--unstable-features" "--skip-children" "/rust/tests/ui/macros/macro-with-attrs1.rs" "//rust/tests/ui/macros/macro-meta-items.rs" "/rust/tests/ui/macros/macro-comma-support-rpass.rs" "/rust/tests/ui/macros/syntax-extension-cfg.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
Build completed unsuccessfully in 0:00:01

Re-adding /tests/ in the rustfmt.toml file, fixes the build error.

@Urgau
Copy link
Member

Urgau commented May 4, 2024

I posted #124704 to fix the issue.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 4, 2024
…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`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 4, 2024
…aumeGomez

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`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 4, 2024
…aumeGomez

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`
RalfJung pushed a commit to RalfJung/miri that referenced this pull request May 4, 2024
Fix ignored tests for formatting

This PR fixes the ignored rules in `rustfmt.toml` that were changed in rust-lang/rust#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/rust#124613 (comment)
cc `@GuillaumeGomez`
r? `@onur-ozkan`
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request May 18, 2024
Fix ignored tests for formatting

This PR fixes the ignored rules in `rustfmt.toml` that were changed in rust-lang/rust#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/rust#124613 (comment)
cc `@GuillaumeGomez`
r? `@onur-ozkan`
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request May 24, 2024
Fix ignored tests for formatting

This PR fixes the ignored rules in `rustfmt.toml` that were changed in rust-lang/rust#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/rust#124613 (comment)
cc `@GuillaumeGomez`
r? `@onur-ozkan`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues about the rust-lang/rust repository. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants