Skip to content

Commit

Permalink
Rough regression test for #13266.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pnkfelix committed Apr 5, 2014
1 parent 4afd060 commit f4cde4e
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 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)
14 changes: 14 additions & 0 deletions 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>() {}
14 changes: 14 additions & 0 deletions 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>() { println!("hello"); }
14 changes: 14 additions & 0 deletions 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>() { println!("world!"); }
11 changes: 11 additions & 0 deletions 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate crateA;
13 changes: 13 additions & 0 deletions 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate crateB;

fn main() {}

5 comments on commit f4cde4e

@bors
Copy link
Contributor

@bors bors commented on f4cde4e Apr 5, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at pnkfelix@f4cde4e

@bors
Copy link
Contributor

@bors bors commented on f4cde4e Apr 5, 2014

Choose a reason for hiding this comment

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

merging pnkfelix/rust/more-fs-info-on-crate-mismatch = f4cde4e into auto

@bors
Copy link
Contributor

@bors bors commented on f4cde4e Apr 5, 2014

Choose a reason for hiding this comment

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

pnkfelix/rust/more-fs-info-on-crate-mismatch = f4cde4e merged ok, testing candidate = 339d400

@bors
Copy link
Contributor

@bors bors commented on f4cde4e Apr 5, 2014

Choose a reason for hiding this comment

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

@bors
Copy link
Contributor

@bors bors commented on f4cde4e Apr 5, 2014

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 339d400

Please sign in to comment.