Skip to content

Commit

Permalink
Use target dir that does not overlap with parent crate's
Browse files Browse the repository at this point in the history
When reusing the original crate's target directory, crates compiled
during trybuild's invocation of Cargo are incompatible from the ones
compiled for the original test run but have colliding hashes on
compilers newer than nightly-2019-10-03, causing failures to find the
right crate during doc tests.

Examples of such failures:

```
   Doc-tests serde_json
error[E0463]: can't find crate for `serde_derive` which `serde` depends on
   --> /home/travis/build/serde-rs/json/src/lib.rs:325:1
    |
325 | extern crate serde;
    | ^^^^^^^^^^^^^^^^^^^ can't find crate
```

```
---- src/ext.rs - ext::TokenStreamExt::append_all (line 20) stdout ----
error[E0460]: found possibly newer version of crate `proc_macro2` which `quote` depends on
 --> src/ext.rs:19:1
  |
2 | extern crate quote;
  | ^^^^^^^^^^^^^^^^^^^
  |
  = note: perhaps that crate needs to be recompiled?
  = note: the following crate versions were found:
          crate `proc_macro2`: /home/travis/build/dtolnay/quote/target/debug/deps/libproc_macro2-e61df99964fc712a.rlib
          crate `proc_macro2`: /home/travis/build/dtolnay/quote/target/debug/deps/libproc_macro2-e61df99964fc712a.rmeta
          crate `proc_macro2`: /home/travis/build/dtolnay/quote/target/debug/deps/libproc_macro2-37a3c8079ede86c5.rmeta
          crate `quote`: /home/travis/build/dtolnay/quote/target/debug/deps/libquote-9e0852a9faf16dfb.rlib
```
  • Loading branch information
dtolnay committed Oct 3, 2019
1 parent e012346 commit 70cf5f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn raw_cargo() -> Command {
fn cargo(project: &Project) -> Command {
let mut cmd = raw_cargo();
cmd.current_dir(&project.dir);
cmd.env("CARGO_TARGET_DIR", &project.target_dir);
cmd.env("CARGO_TARGET_DIR", path!(project.target_dir / "tests" / "target"));
rustflags::set_env(&mut cmd);
cmd
}
Expand Down

0 comments on commit 70cf5f5

Please sign in to comment.