#![feature(test)]
use compiletest_rs as compiletest;
-extern crate test;
+extern crate tester as test;
use std::env::{set_var, var};
use std::ffi::OsStr;
use std::io;
use std::path::{Path, PathBuf};
+#[must_use]
fn clippy_driver_path() -> PathBuf {
if let Some(path) = option_env!("CLIPPY_DRIVER_PATH") {
PathBuf::from(path)
}
}
+#[must_use]
fn host_libs() -> PathBuf {
if let Some(path) = option_env!("HOST_LIBS") {
PathBuf::from(path)
}
}
+#[must_use]
+fn target_libs() -> Option<PathBuf> {
+ option_env!("TARGET_LIBS").map(PathBuf::from)
+}
+
+#[must_use]
fn rustc_test_suite() -> Option<PathBuf> {
option_env!("RUSTC_TEST_SUITE").map(PathBuf::from)
}
+#[must_use]
fn rustc_lib_path() -> PathBuf {
option_env!("RUSTC_LIB_PATH").unwrap().into()
}
// See https://github.com/rust-lang/rust-clippy/issues/4015.
let needs_disambiguation = ["serde", "regex", "clippy_lints"];
// This assumes that deps are compiled (they are for Cargo integration tests).
- let deps = std::fs::read_dir(host_libs().join("deps")).unwrap();
+ let deps = fs::read_dir(target_libs().unwrap_or_else(host_libs).join("deps")).unwrap();
let disambiguated = deps
.filter_map(|dep| {
let path = dep.ok()?.path();
.collect::<Vec<_>>();
config.target_rustcflags = Some(format!(
- "-L {0} -L {0}/deps -Dwarnings -Zui-testing {1}",
+ "-L {0} -L {0}/deps {1} -Dwarnings -Zui-testing {2}",
host_libs().display(),
+ target_libs().map_or_else(String::new, |path| format!("-L {0} -L {0}/deps", path.display())),
disambiguated.join(" ")
));