Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the TARGET_LIBS environment variable for rustc CI testing #4786

Merged
merged 2 commits into from
Nov 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ fn host_libs() -> PathBuf {
}
}

#[must_use]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the must_use isn't necessary

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)
Expand Down Expand Up @@ -57,8 +62,14 @@ 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(host_libs().join("deps")).unwrap();
let deps: Vec<_> = if let Some(target_libs) = target_libs() {
deps.chain(fs::read_dir(target_libs.join("deps")).unwrap()).collect()
} else {
deps.collect()
};
let disambiguated = deps
.into_iter()
.filter_map(|dep| {
let path = dep.ok()?.path();
let name = path.file_name()?.to_string_lossy();
Expand All @@ -75,8 +86,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(" ")
));

Expand Down