-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix mod_module_files false positive for tests in workspaces #16048
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
base: master
Are you sure you want to change the base?
Fix mod_module_files false positive for tests in workspaces #16048
Conversation
Workspaces don't have their integration tests in tests/ at the root, so this check missed them.
a1f9145 to
da7bde7
Compare
| .take_while(|&c| c != "src") | ||
| .any(|c| c == "tests") |
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.
Unless I'm misreading this, it seems like it will work for some-path/nested/crates/my-crate/src/tests/ but not for some-path/crates/my-crate/tests/. (I read this as "find the first src directory and then check that it doesn't have tests in any directory under it")
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 think that would be what it would be if I’d used skip_while. My intention here, with take_while, is to ‘find if there’s a tests directory, excluding if it’s under a src directory’.
I think just .any(|c| c == "tests"), without the take_while, would be good enough for almost all cases, but excluding the contents of src seemed like a good way to eliminate a few false positives (for the check, leading to false negatives for the lint).
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.
You are totally correct - I should have double-checked in the docs, it's been a while since I used take_while and skip_while so I got them mixed up 🤦 Sorry for the confusion!
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.
Great stuff!
Workspaces don't have their integration tests in tests/ at the root, so this check missed them.
This fixes #11775 for workspaces.
changelog: [
mod_module_files]: Fix false positive for integration tests in workspace crates.