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