Skip to content

Commit eb39382

Browse files
committed
refactor: redundant_test_prefix configuration tests
1 parent 3249d9a commit eb39382

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

clippy_lints/src/redundant_test_prefix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::{is_in_cfg_test, is_in_test_function};
44
use rustc_hir::intravisit::FnKind;
55
use rustc_hir::{Body, FnDecl};
66
use rustc_lint::{LateContext, LateLintPass};
7-
use rustc_session::{ impl_lint_pass};
7+
use rustc_session::impl_lint_pass;
88
use rustc_span::Span;
99
use rustc_span::def_id::LocalDefId;
1010

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
redundant-test-prefix-in-integration-tests = false
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
redundant-test-prefix-in-integration-tests = true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error: redundant `test_` prefix in test function name
2+
--> tests/ui-toml/redundant_test_prefix/redundant_test_prefix.rs:14:5
3+
|
4+
LL | / fn test_has_annotation() {
5+
LL | |
6+
LL | | }
7+
| |_____^
8+
|
9+
= help: consider removing the `test_` prefix
10+
= note: `-D clippy::redundant-test-prefix` implied by `-D warnings`
11+
= help: to override `-D warnings` add `#[allow(clippy::redundant_test_prefix)]`
12+
13+
error: redundant `test_` prefix in test function name
14+
--> tests/ui-toml/redundant_test_prefix/redundant_test_prefix.rs:22:1
15+
|
16+
LL | / fn test_main_module_has_annotation() {
17+
LL | |
18+
LL | | }
19+
| |_^
20+
|
21+
= help: consider removing the `test_` prefix
22+
23+
error: aborting due to 2 previous errors
24+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@revisions: default integ_tests
2+
//@[default] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/redundant_test_prefix/default
3+
//@[integ_tests] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/redundant_test_prefix/in_integration_tests
4+
//@compile-flags: --test
5+
#![allow(dead_code)]
6+
#![warn(clippy::redundant_test_prefix)]
7+
8+
fn main() {}
9+
10+
mod tests_no_annotations {
11+
use super::*;
12+
13+
#[test]
14+
fn test_has_annotation() {
15+
//~[integ_tests]^ redundant_test_prefix
16+
}
17+
18+
fn no_annotation() {}
19+
}
20+
21+
#[test]
22+
fn test_main_module_has_annotation() {
23+
//~[integ_tests]^ redundant_test_prefix
24+
}
25+
26+
fn test_main_module_no_annotation() {}
27+
28+
#[cfg(test)]
29+
mod tests {}

0 commit comments

Comments
 (0)