Skip to content

Commit

Permalink
Use lazy_static
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Feb 5, 2020
1 parent 3485d22 commit c4b4dd2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/dogfood.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use lazy_static::lazy_static;
use std::path::PathBuf;
use std::process::Command;

#[allow(dead_code)]
mod cargo;

fn clippy_path() -> PathBuf {
let build_info = cargo::BuildInfo::new();
build_info.target_lib().join("cargo-clippy")
lazy_static! {
static ref CLIPPY_PATH: PathBuf = {
let build_info = cargo::BuildInfo::new();
build_info.target_lib().join("cargo-clippy")
};
}

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

let output = Command::new(clippy_binary)
let output = Command::new(&*CLIPPY_PATH)
.current_dir(root_dir)
.env("CLIPPY_DOGFOOD", "1")
.env("CARGO_INCREMENTAL", "0")
Expand Down Expand Up @@ -46,7 +48,6 @@ fn dogfood_subprojects() {
return;
}
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let clippy_binary = clippy_path();

for d in &[
"clippy_workspace_tests",
Expand All @@ -56,7 +57,7 @@ fn dogfood_subprojects() {
"clippy_dev",
"rustc_tools_util",
] {
let output = Command::new(&clippy_binary)
let output = Command::new(&*CLIPPY_PATH)
.current_dir(root_dir.join(d))
.env("CLIPPY_DOGFOOD", "1")
.env("CARGO_INCREMENTAL", "0")
Expand Down

0 comments on commit c4b4dd2

Please sign in to comment.