X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=tests%2Fcompile-test.rs;h=43139e95666e3fc4ec3c21cd225c4eec6ba5ec50;hb=f6a5b608ef81311030f9852e074bca3d290651cd;hp=663e55d8ea2ba8160843c5f5efa1d36c05b49fdf;hpb=a7fe3b2ebb35e6bca78bc103a75966105981abc4;p=rust.git diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 663e55d8ea2..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() } @@ -38,8 +47,7 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { let cfg_mode = mode.parse().expect("Invalid mode"); if let Ok(name) = var::<&str>("TESTNAME") { - let s: String = name.to_owned(); - config.filter = Some(s) + config.filter = Some(name) } if rustc_test_suite().is_some() { @@ -52,9 +60,9 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { // as we'll get a duplicate matching versions. Instead, disambiguate with // `--extern dep=path`. // See https://github.com/rust-lang/rust-clippy/issues/4015. - let needs_disambiguation = ["serde"]; + 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(); @@ -62,7 +70,7 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { // NOTE: This only handles a single dep // https://github.com/laumann/compiletest-rs/issues/101 needs_disambiguation.iter().find_map(|dep| { - if name.starts_with(&format!("lib{}-", dep)) { + if name.starts_with(&format!("lib{}-", dep)) && name.ends_with(".rlib") { Some(format!("--extern {}={}", dep, path.display())) } else { None @@ -72,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(" ") )); @@ -95,8 +104,6 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { fn run_mode(mode: &str, dir: PathBuf) { let cfg = config(mode, dir); - // clean rmeta data, otherwise "cargo check; cargo test" fails (#2896) - cfg.clean_rmeta(); compiletest::run_tests(&cfg); }