Use relative path for test builds

This commit is contained in:
Cameron Steffen 2021-09-08 10:58:18 -05:00
parent e3b171dcf0
commit ecaf7acd4f
3 changed files with 3 additions and 20 deletions

View file

@ -85,10 +85,7 @@ fn updated_since_clippy_build(path: &Path) -> Option<bool> {
}
fn build_dir() -> PathBuf {
let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());
let mut path = PathBuf::new();
path.push(CARGO_TARGET_DIR.clone());
path.push(profile);
path.push("test_build_base");
let mut path = std::env::current_exe().unwrap();
path.set_file_name("test_build_base");
path
}

View file

@ -1,12 +1,3 @@
use std::env;
use std::lazy::SyncLazy;
use std::path::PathBuf;
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"),
});
#[must_use]
pub fn is_rustc_test_suite() -> bool {
option_env!("RUSTC_TEST_SUITE").is_some()

View file

@ -1,5 +1,4 @@
#![feature(test)] // compiletest_rs requires this attribute
#![feature(once_cell)]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![warn(rust_2018_idioms, unused_lifetimes)]
@ -46,10 +45,6 @@ extern crate quote;
#[allow(unused_extern_crates)]
extern crate syn;
fn host_lib() -> PathBuf {
option_env!("HOST_LIBS").map_or(cargo::CARGO_TARGET_DIR.join(env!("PROFILE")), PathBuf::from)
}
/// Produces a string with an `--extern` flag for all UI test crate
/// dependencies.
///
@ -133,7 +128,7 @@ fn default_config() -> compiletest::Config {
extern_flags(),
));
config.build_base = host_lib().join("test_build_base");
config.build_base = profile_path.join("test_build_base");
config.rustc_path = profile_path.join(if cfg!(windows) {
"clippy-driver.exe"
} else {