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
+
1
11
#[ test]
2
12
fn dogfood_clippy ( ) {
3
13
// run clippy on itself and fail the test if lint warnings are reported
4
14
if option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( ) || cfg ! ( windows) {
5
15
return ;
6
16
}
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 ( ) ;
12
19
13
- let output = std :: process :: Command :: new ( clippy_binary)
20
+ let output = Command :: new ( clippy_binary)
14
21
. current_dir ( root_dir)
15
22
. env ( "CLIPPY_DOGFOOD" , "1" )
16
23
. env ( "CARGO_INCREMENTAL" , "0" )
@@ -37,11 +44,8 @@ fn dogfood_subprojects() {
37
44
if option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( ) || cfg ! ( windows) {
38
45
return ;
39
46
}
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 ( ) ;
45
49
46
50
for d in & [
47
51
"clippy_workspace_tests" ,
@@ -51,7 +55,7 @@ fn dogfood_subprojects() {
51
55
"clippy_dev" ,
52
56
"rustc_tools_util" ,
53
57
] {
54
- let output = std :: process :: Command :: new ( & clippy_binary)
58
+ let output = Command :: new ( & clippy_binary)
55
59
. current_dir ( root_dir. join ( d) )
56
60
. env ( "CLIPPY_DOGFOOD" , "1" )
57
61
. env ( "CARGO_INCREMENTAL" , "0" )
0 commit comments