From f4cde4eddc04733da478ae1030ebc1ddeec04d80 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Sat, 5 Apr 2014 03:53:28 +0200 Subject: [PATCH] Rough regression test for #13266. All it checks, unfortunately, is that you actually printed at least two lines for crateA paths and at least one line for crateB paths. But that's enough to capture the spirit of the bug, I think. I did not bother trying to verify that the paths themselves reflected where the crates end up. --- .../many-crates-but-no-match/Makefile | 34 +++++++++++++++++++ .../many-crates-but-no-match/crateA1.rs | 14 ++++++++ .../many-crates-but-no-match/crateA2.rs | 14 ++++++++ .../many-crates-but-no-match/crateA3.rs | 14 ++++++++ .../many-crates-but-no-match/crateB.rs | 11 ++++++ .../many-crates-but-no-match/crateC.rs | 13 +++++++ 6 files changed, 100 insertions(+) create mode 100644 src/test/run-make/many-crates-but-no-match/Makefile create mode 100644 src/test/run-make/many-crates-but-no-match/crateA1.rs create mode 100644 src/test/run-make/many-crates-but-no-match/crateA2.rs create mode 100644 src/test/run-make/many-crates-but-no-match/crateA3.rs create mode 100644 src/test/run-make/many-crates-but-no-match/crateB.rs create mode 100644 src/test/run-make/many-crates-but-no-match/crateC.rs diff --git a/src/test/run-make/many-crates-but-no-match/Makefile b/src/test/run-make/many-crates-but-no-match/Makefile new file mode 100644 index 00000000000..4d80c09c26b --- /dev/null +++ b/src/test/run-make/many-crates-but-no-match/Makefile @@ -0,0 +1,34 @@ +-include ../tools.mk + +# Modelled after compile-fail/changing-crates test, but this one puts +# more than one (mismatching) candidate crate into the search path, +# which did not appear directly expressible in compile-fail/aux-build +# infrastructure. +# +# Note that we move the built libraries into target direcrtories rather than +# use the `--out-dir` option because the `../tools.mk` file already bakes a +# use of `--out-dir` into the definition of $(RUSTC). + +A1=$(TMPDIR)/a1 +A2=$(TMPDIR)/a2 +A3=$(TMPDIR)/a3 + +# A hack to match distinct lines of output from a single run. +LOG=$(TMPDIR)/log.txt + +all: + mkdir -p $(A1) $(A2) $(A3) + $(RUSTC) --crate-type=rlib crateA1.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1) + $(RUSTC) --crate-type=rlib -L$(A1) crateB.rs + $(RUSTC) --crate-type=rlib crateA2.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2) + $(RUSTC) --crate-type=rlib crateA3.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3) + # Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match + $(RUSTC) -L$(A2) -L$(A3) crateC.rs >$(LOG) 2>&1 || true + grep "error: found possibly newer version of crate \`crateA\` which \`crateB\` depends on" $(LOG) + grep "note: perhaps this crate needs to be recompiled?" $(LOG) + grep "note: crate \`crateA\` path #1:" $(LOG) + grep "note: crate \`crateA\` path #2:" $(LOG) + grep "note: crate \`crateB\` path #1:" $(LOG) diff --git a/src/test/run-make/many-crates-but-no-match/crateA1.rs b/src/test/run-make/many-crates-but-no-match/crateA1.rs new file mode 100644 index 00000000000..0c88cf4745a --- /dev/null +++ b/src/test/run-make/many-crates-but-no-match/crateA1.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_id="crateA"] + +// Base crate +pub fn func() {} diff --git a/src/test/run-make/many-crates-but-no-match/crateA2.rs b/src/test/run-make/many-crates-but-no-match/crateA2.rs new file mode 100644 index 00000000000..e3fb50e13d0 --- /dev/null +++ b/src/test/run-make/many-crates-but-no-match/crateA2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_id="crateA"] + +// Base crate +pub fn func() { println!("hello"); } diff --git a/src/test/run-make/many-crates-but-no-match/crateA3.rs b/src/test/run-make/many-crates-but-no-match/crateA3.rs new file mode 100644 index 00000000000..ad9d458be24 --- /dev/null +++ b/src/test/run-make/many-crates-but-no-match/crateA3.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_id="crateA"] + +// Base crate +pub fn foo() { println!("world!"); } diff --git a/src/test/run-make/many-crates-but-no-match/crateB.rs b/src/test/run-make/many-crates-but-no-match/crateB.rs new file mode 100644 index 00000000000..bf55017c646 --- /dev/null +++ b/src/test/run-make/many-crates-but-no-match/crateB.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateA; diff --git a/src/test/run-make/many-crates-but-no-match/crateC.rs b/src/test/run-make/many-crates-but-no-match/crateC.rs new file mode 100644 index 00000000000..174d9382b76 --- /dev/null +++ b/src/test/run-make/many-crates-but-no-match/crateC.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateB; + +fn main() {}