1+ use std:: path:: PathBuf ;
2+ use std:: process:: Command ;
3+
4+ #[ allow( dead_code) ]
5+ mod cargo;
6+
7+ fn clippy_path ( ) -> PathBuf {
8+ let build_info = cargo:: BuildInfo :: new ( ) ;
9+ build_info. target_lib ( ) . join ( "cargo-clippy" )
10+ }
11+
112#[ test]
213fn dogfood_clippy ( ) {
314 // run clippy on itself and fail the test if lint warnings are reported
415 if option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( ) || cfg ! ( windows) {
516 return ;
617 }
7- let root_dir = std:: path:: PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
8- let clippy_binary = std:: path:: Path :: new ( & root_dir)
9- . join ( "target" )
10- . join ( env ! ( "PROFILE" ) )
11- . join ( "cargo-clippy" ) ;
18+ let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
19+ let clippy_binary = clippy_path ( ) ;
1220
13- let output = std :: process :: Command :: new ( clippy_binary)
21+ let output = Command :: new ( clippy_binary)
1422 . current_dir ( root_dir)
1523 . env ( "CLIPPY_DOGFOOD" , "1" )
1624 . env ( "CARGO_INCREMENTAL" , "0" )
@@ -37,11 +45,8 @@ fn dogfood_subprojects() {
3745 if option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( ) || cfg ! ( windows) {
3846 return ;
3947 }
40- let root_dir = std:: path:: PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
41- let clippy_binary = std:: path:: Path :: new ( & root_dir)
42- . join ( "target" )
43- . join ( env ! ( "PROFILE" ) )
44- . join ( "cargo-clippy" ) ;
48+ let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
49+ let clippy_binary = clippy_path ( ) ;
4550
4651 for d in & [
4752 "clippy_workspace_tests" ,
@@ -51,7 +56,7 @@ fn dogfood_subprojects() {
5156 "clippy_dev" ,
5257 "rustc_tools_util" ,
5358 ] {
54- let output = std :: process :: Command :: new ( & clippy_binary)
59+ let output = Command :: new ( & clippy_binary)
5560 . current_dir ( root_dir. join ( d) )
5661 . env ( "CLIPPY_DOGFOOD" , "1" )
5762 . env ( "CARGO_INCREMENTAL" , "0" )
0 commit comments