Skip to content

Commit

Permalink
Auto merge of #4115 - ehuss:fix-compiletest, r=Manishearth
Browse files Browse the repository at this point in the history
Fix compile-test from forcing a rebuild.

If the `compile-test` test was run, then running a cargo build command immediately after caused everything to be rebuilt. This is because the `compile-test` test was deleting all `.rmeta` files in the target directory. Cargo recently switched to always generating `.rmeta` files (rust-lang/cargo#6883), and when the files are deleted, it thinks it needs to be rebuilt.

I am not very familiar with compiletest or clippy, so please take a close look and test this out (with the most recent nightly). In particular, make sure it doesn't revert the fixes from #3380 (it seems to work for me). Also @oli-obk mentioned something related in rust-lang/rust#60190 (comment), and I want to make sure that is addressed as well.

Fixes #4114
  • Loading branch information
bors committed May 19, 2019
2 parents 0331b95 + a8bf501 commit cbae9ed
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ 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 disambiguated = deps
Expand All @@ -62,7 +62,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
Expand Down Expand Up @@ -95,8 +95,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);
}

Expand Down

0 comments on commit cbae9ed

Please sign in to comment.