7
7
#![ cfg_attr( feature = "deny-warnings" , deny( warnings) ) ]
8
8
#![ warn( rust_2018_idioms, unused_lifetimes) ]
9
9
10
- use std:: lazy:: SyncLazy ;
11
10
use std:: path:: PathBuf ;
12
11
use std:: process:: Command ;
12
+ use test_utils:: { CARGO_CLIPPY_PATH , IS_RUSTC_TEST_SUITE } ;
13
13
14
- mod cargo;
15
-
16
- static CLIPPY_PATH : SyncLazy < PathBuf > = SyncLazy :: new ( || {
17
- let mut path = std:: env:: current_exe ( ) . unwrap ( ) ;
18
- assert ! ( path. pop( ) ) ; // deps
19
- path. set_file_name ( "cargo-clippy" ) ;
20
- path
21
- } ) ;
14
+ mod test_utils;
22
15
23
16
#[ test]
24
17
fn dogfood_clippy ( ) {
25
18
// run clippy on itself and fail the test if lint warnings are reported
26
- if cargo :: is_rustc_test_suite ( ) {
19
+ if IS_RUSTC_TEST_SUITE {
27
20
return ;
28
21
}
29
22
let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
30
23
31
- let mut command = Command :: new ( & * CLIPPY_PATH ) ;
24
+ let mut command = Command :: new ( & * CARGO_CLIPPY_PATH ) ;
32
25
command
33
26
. current_dir ( root_dir)
34
27
. env ( "CARGO_INCREMENTAL" , "0" )
@@ -55,7 +48,7 @@ fn dogfood_clippy() {
55
48
}
56
49
57
50
fn test_no_deps_ignores_path_deps_in_workspaces ( ) {
58
- if cargo :: is_rustc_test_suite ( ) {
51
+ if IS_RUSTC_TEST_SUITE {
59
52
return ;
60
53
}
61
54
let root = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
@@ -74,7 +67,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
74
67
75
68
// `path_dep` is a path dependency of `subcrate` that would trigger a denied lint.
76
69
// Make sure that with the `--no-deps` argument Clippy does not run on `path_dep`.
77
- let output = Command :: new ( & * CLIPPY_PATH )
70
+ let output = Command :: new ( & * CARGO_CLIPPY_PATH )
78
71
. current_dir ( & cwd)
79
72
. env ( "CARGO_INCREMENTAL" , "0" )
80
73
. arg ( "clippy" )
@@ -93,7 +86,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
93
86
94
87
let lint_path_dep = || {
95
88
// Test that without the `--no-deps` argument, `path_dep` is linted.
96
- let output = Command :: new ( & * CLIPPY_PATH )
89
+ let output = Command :: new ( & * CARGO_CLIPPY_PATH )
97
90
. current_dir ( & cwd)
98
91
. env ( "CARGO_INCREMENTAL" , "0" )
99
92
. arg ( "clippy" )
@@ -119,7 +112,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
119
112
lint_path_dep ( ) ;
120
113
121
114
let successful_build = || {
122
- let output = Command :: new ( & * CLIPPY_PATH )
115
+ let output = Command :: new ( & * CARGO_CLIPPY_PATH )
123
116
. current_dir ( & cwd)
124
117
. env ( "CARGO_INCREMENTAL" , "0" )
125
118
. arg ( "clippy" )
@@ -153,7 +146,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
153
146
#[ test]
154
147
fn dogfood_subprojects ( ) {
155
148
// run clippy on remaining subprojects and fail the test if lint warnings are reported
156
- if cargo :: is_rustc_test_suite ( ) {
149
+ if IS_RUSTC_TEST_SUITE {
157
150
return ;
158
151
}
159
152
@@ -218,7 +211,7 @@ fn run_metadata_collection_lint() {
218
211
fn run_clippy_for_project ( project : & str ) {
219
212
let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
220
213
221
- let mut command = Command :: new ( & * CLIPPY_PATH ) ;
214
+ let mut command = Command :: new ( & * test_utils :: CARGO_CLIPPY_PATH ) ;
222
215
223
216
command
224
217
. current_dir ( root_dir. join ( project) )
0 commit comments