-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: wildcard_imports
ignore test.rs
files
#10584
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
Conversation
r? @flip1995 (rustbot has picked a reviewer for you, use r? to override) |
04fb8b9
to
0aa9823
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have doubts, if checking the file name is actually necessary.
Oh god I finally got it The illuminance came before me when I realize that now, I could check if a crate is a test. It's so beautiful. I've been at this like 8 hours now, and now... It's fixed... 😌 Peace is within me. |
…errors Add little `is_test_crate` function Ok, this is quite a story. I'm mainly a Clippy contributor, so I was fixing [this Clippy issue](rust-lang/rust-clippy#10584) about a lint having to ignore test modules but that wasn't ignoring test files (integration test, `test/` dirs and such). As test **files** don't tend to have an inner `#[cfg(test)]` module inside them, I tried everything, looking for filenames, looking for item's parents in the HIR Map, doing black magic... I even asked [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20Checking.20if.20file.20is.20integration.20test), and jyn answered something about `--cfg test`. Aha! That's something that I might be looking for, so I started looking at `rustc_driver_impl` flag parsing and configuration and all that. Then, I stumbled on [this function right here](https://github.com/rust-lang/rust/blob/2e486be8d29d198d48bc26bfce5712a4822814f5/compiler/rustc_driver_impl/src/lib.rs#L174-L181), and noticed the argument `config: Config`. That's a hint. So [Config](https://doc.rust-lang.org/beta/nightly-rustc/rustc_interface/interface/struct.Config.html) has the field `opts: Options`, and [`Options`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_session/options/struct.Options.html) has the field `test`. This journey has been ~7 or 8 hours in 3 days, it's a very hard thing to find, so this PR adds a mini-function to check if the current crate is a testing one. So that no one has to travel through the same as me, and can just search for `is_test_crate` in the documentation.
Is there something left for merging this? |
Just me being slow. Sorry :| @bors r+ |
fix: `wildcard_imports` ignore `test.rs` files Adds a check to see if the building crate is a test one, if so, ignore it --- Closes #10580 changelog:[`wildcard_imports`]: Add a check to ignore files named `test.rs` and `tests.rs`
💔 Test failed - checks-action_test |
4a2c025
to
ba0e7e8
Compare
? |
@bors retry |
@blyxyas: 🔑 Insufficient privileges: not in try users |
Ah thanks for investigating, I planned to do that this evening. @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Adds a check to see if the building crate is a test one, if so, ignore it
Closes #10580
changelog:[
wildcard_imports
]: Add a check to ignore files namedtest.rs
andtests.rs