]> git.lizzy.rs Git - rust.git/blobdiff - tests/compile-test.rs
Rustup to rust-lang/rust#66931
[rust.git] / tests / compile-test.rs
index e65a4a9a40ac901c6e7c2381a10ddebeb6f22899..43139e95666e3fc4ec3c21cd225c4eec6ba5ec50 100644 (file)
@@ -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<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()
 }
@@ -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::<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(" ")
     ));