77#![ cfg_attr( feature = "deny-warnings" , deny( warnings) ) ]
88#![ warn( rust_2018_idioms, unused_lifetimes) ]
99
10- use std:: lazy:: SyncLazy ;
1110use std:: path:: PathBuf ;
1211use std:: process:: Command ;
12+ use test_utils:: { CARGO_CLIPPY_PATH , IS_RUSTC_TEST_SUITE } ;
1313
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;
2215
2316#[ test]
2417fn dogfood_clippy ( ) {
2518 // 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 {
2720 return ;
2821 }
2922 let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
3023
31- let mut command = Command :: new ( & * CLIPPY_PATH ) ;
24+ let mut command = Command :: new ( & * CARGO_CLIPPY_PATH ) ;
3225 command
3326 . current_dir ( root_dir)
3427 . env ( "CARGO_INCREMENTAL" , "0" )
@@ -55,7 +48,7 @@ fn dogfood_clippy() {
5548}
5649
5750fn test_no_deps_ignores_path_deps_in_workspaces ( ) {
58- if cargo :: is_rustc_test_suite ( ) {
51+ if IS_RUSTC_TEST_SUITE {
5952 return ;
6053 }
6154 let root = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
@@ -74,7 +67,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
7467
7568 // `path_dep` is a path dependency of `subcrate` that would trigger a denied lint.
7669 // 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 )
7871 . current_dir ( & cwd)
7972 . env ( "CARGO_INCREMENTAL" , "0" )
8073 . arg ( "clippy" )
@@ -93,7 +86,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
9386
9487 let lint_path_dep = || {
9588 // 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 )
9790 . current_dir ( & cwd)
9891 . env ( "CARGO_INCREMENTAL" , "0" )
9992 . arg ( "clippy" )
@@ -119,7 +112,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
119112 lint_path_dep ( ) ;
120113
121114 let successful_build = || {
122- let output = Command :: new ( & * CLIPPY_PATH )
115+ let output = Command :: new ( & * CARGO_CLIPPY_PATH )
123116 . current_dir ( & cwd)
124117 . env ( "CARGO_INCREMENTAL" , "0" )
125118 . arg ( "clippy" )
@@ -153,7 +146,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
153146#[ test]
154147fn dogfood_subprojects ( ) {
155148 // 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 {
157150 return ;
158151 }
159152
@@ -218,7 +211,7 @@ fn run_metadata_collection_lint() {
218211fn run_clippy_for_project ( project : & str ) {
219212 let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
220213
221- let mut command = Command :: new ( & * CLIPPY_PATH ) ;
214+ let mut command = Command :: new ( & * test_utils :: CARGO_CLIPPY_PATH ) ;
222215
223216 command
224217 . current_dir ( root_dir. join ( project) )
0 commit comments