X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=tests%2Fcompile-test.rs;h=43139e95666e3fc4ec3c21cd225c4eec6ba5ec50;hb=f6a5b608ef81311030f9852e074bca3d290651cd;hp=e65a4a9a40ac901c6e7c2381a10ddebeb6f22899;hpb=e2393b09ac234aa19a2ffa368ef8d25ce645eaa3;p=rust.git diff --git a/tests/compile-test.rs b/tests/compile-test.rs index e65a4a9a40a..43139e95666 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -1,7 +1,7 @@ #![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; @@ -9,6 +9,7 @@ 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) @@ -17,6 +18,7 @@ fn clippy_driver_path() -> PathBuf { } } +#[must_use] fn host_libs() -> PathBuf { if let Some(path) = option_env!("HOST_LIBS") { PathBuf::from(path) @@ -25,10 +27,17 @@ fn host_libs() -> PathBuf { } } +#[must_use] +fn target_libs() -> Option { + option_env!("TARGET_LIBS").map(PathBuf::from) +} + +#[must_use] fn rustc_test_suite() -> Option { option_env!("RUSTC_TEST_SUITE").map(PathBuf::from) } +#[must_use] fn rustc_lib_path() -> PathBuf { option_env!("RUSTC_LIB_PATH").unwrap().into() } @@ -53,7 +62,7 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { // 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(); @@ -71,8 +80,9 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { .collect::>(); 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(" ") ));