Auto merge of #10543 - blyxyas:tests_outside_test_module, r=flip1995
Add `tests_outside_test_module` lint Adds `tests_outside_test_module` from #10506. This PR **doesn't** close the issue, just resolves task 1. changelog: [`tests_outside_test_module`]: The lint has been added
This commit is contained in:
commit
5d149c5dac
6 changed files with 104 additions and 0 deletions
18
tests/ui/tests_outside_test_module.rs
Normal file
18
tests/ui/tests_outside_test_module.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// compile-flags: --test
|
||||
#![allow(unused)]
|
||||
#![warn(clippy::tests_outside_test_module)]
|
||||
|
||||
fn main() {
|
||||
// test code goes here
|
||||
}
|
||||
|
||||
// Should lint
|
||||
#[test]
|
||||
fn my_test() {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// Should not lint
|
||||
#[test]
|
||||
fn my_test() {}
|
||||
}
|
||||
11
tests/ui/tests_outside_test_module.stderr
Normal file
11
tests/ui/tests_outside_test_module.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error: this function marked with #[test] is outside a #[cfg(test)] module
|
||||
--> $DIR/tests_outside_test_module.rs:11:1
|
||||
|
|
||||
LL | fn my_test() {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: move it to a testing module marked with #[cfg(test)]
|
||||
= note: `-D clippy::tests-outside-test-module` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue