1
+ use lazy_static:: lazy_static;
1
2
use std:: path:: PathBuf ;
2
3
use std:: process:: Command ;
3
4
4
5
#[ allow( dead_code) ]
5
6
mod cargo;
6
7
7
- fn clippy_path ( ) -> PathBuf {
8
- let build_info = cargo:: BuildInfo :: new ( ) ;
9
- build_info. target_lib ( ) . join ( "cargo-clippy" )
8
+ lazy_static ! {
9
+ static ref CLIPPY_PATH : PathBuf = {
10
+ let build_info = cargo:: BuildInfo :: new( ) ;
11
+ build_info. target_lib( ) . join( "cargo-clippy" )
12
+ } ;
10
13
}
11
14
12
15
#[ test]
@@ -16,9 +19,8 @@ fn dogfood_clippy() {
16
19
return ;
17
20
}
18
21
let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
19
- let clippy_binary = clippy_path ( ) ;
20
22
21
- let output = Command :: new ( clippy_binary )
23
+ let output = Command :: new ( & * CLIPPY_PATH )
22
24
. current_dir ( root_dir)
23
25
. env ( "CLIPPY_DOGFOOD" , "1" )
24
26
. env ( "CARGO_INCREMENTAL" , "0" )
@@ -46,7 +48,6 @@ fn dogfood_subprojects() {
46
48
return ;
47
49
}
48
50
let root_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
49
- let clippy_binary = clippy_path ( ) ;
50
51
51
52
for d in & [
52
53
"clippy_workspace_tests" ,
@@ -56,7 +57,7 @@ fn dogfood_subprojects() {
56
57
"clippy_dev" ,
57
58
"rustc_tools_util" ,
58
59
] {
59
- let output = Command :: new ( & clippy_binary )
60
+ let output = Command :: new ( & * CLIPPY_PATH )
60
61
. current_dir ( root_dir. join ( d) )
61
62
. env ( "CLIPPY_DOGFOOD" , "1" )
62
63
. env ( "CARGO_INCREMENTAL" , "0" )
0 commit comments