Use relative exe paths
This commit is contained in:
parent
2e15c8054d
commit
e3b171dcf0
@ -1,7 +1,6 @@
|
||||
//! `bless` updates the reference files in the repo with changed output files
|
||||
//! from the last test run.
|
||||
|
||||
use std::env;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::lazy::SyncLazy;
|
||||
@ -10,17 +9,9 @@
|
||||
|
||||
use crate::clippy_project_root;
|
||||
|
||||
// NOTE: this is duplicated with tests/cargo/mod.rs What to do?
|
||||
pub static CARGO_TARGET_DIR: SyncLazy<PathBuf> = SyncLazy::new(|| match env::var_os("CARGO_TARGET_DIR") {
|
||||
Some(v) => v.into(),
|
||||
None => env::current_dir().unwrap().join("target"),
|
||||
});
|
||||
|
||||
static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> = SyncLazy::new(|| {
|
||||
let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());
|
||||
let mut path = PathBuf::from(&**CARGO_TARGET_DIR);
|
||||
path.push(profile);
|
||||
path.push("cargo-clippy");
|
||||
let mut path = std::env::current_exe().unwrap();
|
||||
path.set_file_name("cargo-clippy");
|
||||
fs::metadata(path).ok()?.modified().ok()
|
||||
});
|
||||
|
||||
|
@ -7,19 +7,6 @@
|
||||
None => env::current_dir().unwrap().join("target"),
|
||||
});
|
||||
|
||||
pub static TARGET_LIB: SyncLazy<PathBuf> = SyncLazy::new(|| {
|
||||
if let Some(path) = option_env!("TARGET_LIBS") {
|
||||
path.into()
|
||||
} else {
|
||||
let mut dir = CARGO_TARGET_DIR.clone();
|
||||
if let Some(target) = env::var_os("CARGO_BUILD_TARGET") {
|
||||
dir.push(target);
|
||||
}
|
||||
dir.push(env!("PROFILE"));
|
||||
dir
|
||||
}
|
||||
});
|
||||
|
||||
#[must_use]
|
||||
pub fn is_rustc_test_suite() -> bool {
|
||||
option_env!("RUSTC_TEST_SUITE").is_some()
|
||||
|
@ -50,10 +50,6 @@ fn host_lib() -> PathBuf {
|
||||
option_env!("HOST_LIBS").map_or(cargo::CARGO_TARGET_DIR.join(env!("PROFILE")), PathBuf::from)
|
||||
}
|
||||
|
||||
fn clippy_driver_path() -> PathBuf {
|
||||
option_env!("CLIPPY_DRIVER_PATH").map_or(cargo::TARGET_LIB.join("clippy-driver"), PathBuf::from)
|
||||
}
|
||||
|
||||
/// Produces a string with an `--extern` flag for all UI test crate
|
||||
/// dependencies.
|
||||
///
|
||||
@ -122,6 +118,7 @@ fn default_config() -> compiletest::Config {
|
||||
}
|
||||
let current_exe_path = std::env::current_exe().unwrap();
|
||||
let deps_path = current_exe_path.parent().unwrap();
|
||||
let profile_path = deps_path.parent().unwrap();
|
||||
|
||||
// Using `-L dependency={}` enforces that external dependencies are added with `--extern`.
|
||||
// This is valuable because a) it allows us to monitor what external dependencies are used
|
||||
@ -137,7 +134,11 @@ fn default_config() -> compiletest::Config {
|
||||
));
|
||||
|
||||
config.build_base = host_lib().join("test_build_base");
|
||||
config.rustc_path = clippy_driver_path();
|
||||
config.rustc_path = profile_path.join(if cfg!(windows) {
|
||||
"clippy-driver.exe"
|
||||
} else {
|
||||
"clippy-driver"
|
||||
});
|
||||
config
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,12 @@
|
||||
|
||||
mod cargo;
|
||||
|
||||
static CLIPPY_PATH: SyncLazy<PathBuf> = SyncLazy::new(|| cargo::TARGET_LIB.join("cargo-clippy"));
|
||||
static CLIPPY_PATH: SyncLazy<PathBuf> = SyncLazy::new(|| {
|
||||
let mut path = std::env::current_exe().unwrap();
|
||||
assert!(path.pop()); // deps
|
||||
path.set_file_name("cargo-clippy");
|
||||
path
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn dogfood_clippy() {
|
||||
|
Loading…
Reference in New Issue
Block a user