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

tests_outside_test_module can be triggered in integration tests #11024

Open
CobaltCause opened this issue Jun 25, 2023 · 0 comments · May be fixed by #13038
Open

tests_outside_test_module can be triggered in integration tests #11024

CobaltCause opened this issue Jun 25, 2023 · 0 comments · May be fixed by #13038
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@CobaltCause
Copy link

Summary

tests_outside_test_module can be triggered in integration tests.

This actually came up because I was trying out RFC 3389 manifest-lint which helpfully applies lint configuration to all integration tests. manifest-lint isn't required to trigger the issue, though.

Applying the suggestion given by the lint does work (i.e. still runs the test and silences the warning), but is redundant since it's already in an integration test.

Lint Name

tests_outside_test_module

Reproducer

I tried this code in tests/integrations/main.rs:

#![warn(clippy::tests_outside_test_module)]

#[test]
fn it_works() {
    assert_eq!(2 + 2, 4);
}

I saw this happen when running cargo clippy --tests:

warning: this function marked with #[test] is outside a #[cfg(test)] module
 --> tests/integrations/main.rs:4:1
  |
4 | / fn it_works() {
5 | |     assert_eq!(2 + 2, 4);
6 | | }
  | |_^
  |
  = note: move it to a testing module marked with #[cfg(test)]
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#tests_outside_test_module
note: the lint level is defined here
 --> tests/integrations/main.rs:1:9
  |
1 | #![warn(clippy::tests_outside_test_module)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I expected to see no warnings generated.

Version

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

Additional Labels

No response

@CobaltCause CobaltCause added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jun 25, 2023
epage added a commit to epage/_rust that referenced this issue Mar 28, 2024
berkus added a commit to berkus/rust-clippy that referenced this issue Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant