Skip to content

Commit c4b4dd2

Browse files
committed
Use lazy_static
1 parent 3485d22 commit c4b4dd2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/dogfood.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
use lazy_static::lazy_static;
12
use std::path::PathBuf;
23
use std::process::Command;
34

45
#[allow(dead_code)]
56
mod cargo;
67

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+
};
1013
}
1114

1215
#[test]
@@ -16,9 +19,8 @@ fn dogfood_clippy() {
1619
return;
1720
}
1821
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
19-
let clippy_binary = clippy_path();
2022

21-
let output = Command::new(clippy_binary)
23+
let output = Command::new(&*CLIPPY_PATH)
2224
.current_dir(root_dir)
2325
.env("CLIPPY_DOGFOOD", "1")
2426
.env("CARGO_INCREMENTAL", "0")
@@ -46,7 +48,6 @@ fn dogfood_subprojects() {
4648
return;
4749
}
4850
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
49-
let clippy_binary = clippy_path();
5051

5152
for d in &[
5253
"clippy_workspace_tests",
@@ -56,7 +57,7 @@ fn dogfood_subprojects() {
5657
"clippy_dev",
5758
"rustc_tools_util",
5859
] {
59-
let output = Command::new(&clippy_binary)
60+
let output = Command::new(&*CLIPPY_PATH)
6061
.current_dir(root_dir.join(d))
6162
.env("CLIPPY_DOGFOOD", "1")
6263
.env("CARGO_INCREMENTAL", "0")

0 commit comments

Comments
 (0)