-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: Do not warn tests outside a module for integration tests #13038
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Alexendoo (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
I am asking for some guidance on how to test the lint on the unit tests though - the test suite I see in clippy is actually integration tests. |
Being in Similarly an integration test can live outside the |
in this case I believe it should work, as the test file path will not start with tests. I can try and add a test for it, again if I understand how to do unit testing in clippy source.
For such custom paths there should be some Cargo manifest parsing, I guess. Again, any guidelines to an accepted approach are appreciated. |
Ah I missed that it checked the first path component, that can be a problem in workspaces as the working directory would be the workspace root rather than the package root. Tests inside an integration test can also live in submodules
Sorry to say I don't have a good answer here, we generally try to avoid parsing Cargo things |
Looks like libtest does store this information, it's approximated by checking the last path component of the directory the crate entry point is located in We could copy that or update https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.with_test_item_names.html to check the description for the |
Hi, yes, i will get back on it next week. |
d7ef35e
to
0a9eb84
Compare
0a9eb84
to
67a50c9
Compare
I've applied this, but need to update tests; short on time recently, will get back to it soon. |
Got here from #11119 which is also about false positive in integration tests. Seems your |
Yeah that should be possible, I will find some time to fix the remaining tests and move the fn - this week! |
☔ The latest upstream changes (presumably #13440) made this pull request unmergeable. Please resolve the merge conflicts. |
Ok @bors will do. Still finding time to mess with the tests setup. |
Fixes a false positive that triggers tests_outside_test_module in integration tests. As per The Rust Book the integration tests do not need neither
#[cfg(test)]
nor a separate module because they are separate binary crates.changelog: [
tests_outside_test_module
] Do not lint for integration testsfixes #11024