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

New lint: redundant_test_prefix #13710

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

farazdagi
Copy link

@farazdagi farazdagi commented Nov 19, 2024

This PR has started as an effort to proceed from the feedback in #12861.

  • Checks test functions for redundant "test_" prefix.
  • Auto-fix is supported (and handles collisions gracefully, see below).
  • If removing "test_" prefix from, say, test_foo() results in a collision (either because function foo() is defined within the current scope, or because the foo() call exists within function thus creating an unwanted recursion), lint suggests replacing prefix with suffix, i.e. test_foo() becomes foo_works(). The _works suffix is configurable.
  • Integration tests do not have #[cfg(test)] defined for them, so by default they are not checked. There exists an option to make sure that any functions with #[test] annotation (including those outside of nodes marked with cfg(test)) are linted.

fixes #8931

changelog: new lint: [redundant_test_prefix]

@rustbot
Copy link
Collaborator

rustbot commented Nov 19, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dswij (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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 19, 2024
@farazdagi farazdagi marked this pull request as ready for review November 19, 2024 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test function name starts with test_
3 participants