1+ use std:: path:: PathBuf ;
2+ use std:: process:: Command ;
3+
4+ mod cargo;
5+
6+ fn clippy_path ( ) -> PathBuf {
7+ let build_info = cargo:: BuildInfo :: new ( ) ;
8+ build_info. target_lib . join ( "cargo-clippy" )
9+ }
10+
111#[ test]
212fn dogfood_clippy ( ) {
313 // run clippy on itself and fail the test if lint warnings are reported
414 if option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( ) || cfg ! ( windows) {
515 return ;
616 }
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" ) ;
17+ let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
18+ let clippy_binary = clippy_path ( ) ;
1219
13- let output = std :: process :: Command :: new ( clippy_binary)
20+ let output = Command :: new ( clippy_binary)
1421 . current_dir ( root_dir)
1522 . env ( "CLIPPY_DOGFOOD" , "1" )
1623 . env ( "CARGO_INCREMENTAL" , "0" )
@@ -37,11 +44,8 @@ fn dogfood_subprojects() {
3744 if option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( ) || cfg ! ( windows) {
3845 return ;
3946 }
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" ) ;
47+ let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
48+ let clippy_binary = clippy_path ( ) ;
4549
4650 for d in & [
4751 "clippy_workspace_tests" ,
@@ -51,7 +55,7 @@ fn dogfood_subprojects() {
5155 "clippy_dev" ,
5256 "rustc_tools_util" ,
5357 ] {
54- let output = std :: process :: Command :: new ( & clippy_binary)
58+ let output = Command :: new ( & clippy_binary)
5559 . current_dir ( root_dir. join ( d) )
5660 . env ( "CLIPPY_DOGFOOD" , "1" )
5761 . env ( "CARGO_INCREMENTAL" , "0" )
0 commit comments