rust-skeptic: multiple matching crates when deps are duplicated
I get a weird error when I use the combination of:
rust-skepticcargo checkcargo test- on a
proc_macrocrate
This looks like a skeptic (or cargo check) bug and it is dependent on the order of cargo check and cargo test.
error[E0464]: multiple matching crates for `cargo_check_bug`
--> /tmp/rust-skeptic.U89a9gBDNE36/test.rs:1:1
|
1 | extern crate cargo_check_bug;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: candidates:
= note: path: /home/colin/projects/rust/cargo_check_bug/target/debug/deps/libcargo_check_bug-0b76af5b42a4f158.so
= note: crate name: cargo_check_bug
= note: crate name: cargo_check_bug
Steps to reprodroduce
git clone https://github.com/colin-kiegel/cargo_check_bug.gitcd cargo_check_bugrustup override set nightly-2017-03-03cargo clean && cargo test && cargo checkcargo clean && cargo check && cargo test
Result of Step 4
Everything OK!
Compiling getopts v0.2.14
Compiling libc v0.2.21
Compiling bitflags v0.5.0
Compiling rand v0.3.15
Compiling pulldown-cmark v0.0.8
Compiling tempdir v0.3.5
Compiling skeptic v0.7.1
Compiling cargo_check_bug v0.1.0 (file:///home/colin/projects/rust/cargo_check_bug)
Finished dev [unoptimized + debuginfo] target(s) in 5.40 secs
Running target/debug/deps/cargo_check_bug-bc124838e21e68e1
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
Running target/debug/deps/skeptic-c3b458a20ebee641
running 1 test
warning: proc macro crates and #[no_link] crates have no effect without #[macro_use]
–> /tmp/rust-skeptic.9IqFqNCvwCPZ/test.rs:1:1
|
1 | extern crate cargo_check_bug;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test readme_0 … ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
Doc-tests cargo_check_bug
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
Compiling cargo_check_bug v0.1.0 (file:///home/colin/projects/rust/cargo_check_bug)
Finished dev [unoptimized + debuginfo] target(s) in 0.12 secs
Result of Step 5
error[E0464]: multiple matching crates for `cargo_check_bug`
Compiling bitflags v0.5.0
Compiling getopts v0.2.14
Compiling libc v0.2.21
Compiling rand v0.3.15
Compiling pulldown-cmark v0.0.8
Compiling tempdir v0.3.5
Compiling skeptic v0.7.1
Compiling cargo_check_bug v0.1.0 (file:///home/colin/projects/rust/cargo_check_bug)
Finished dev [unoptimized + debuginfo] target(s) in 4.54 secs
Compiling cargo_check_bug v0.1.0 (file:///home/colin/projects/rust/cargo_check_bug)
Finished dev [unoptimized + debuginfo] target(s) in 0.97 secs
Running target/debug/deps/cargo_check_bug-bc124838e21e68e1
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
Running target/debug/deps/skeptic-c3b458a20ebee641
running 1 test
error[E0464]: multiple matching crates for cargo_check_bug
–> /tmp/rust-skeptic.U89a9gBDNE36/test.rs:1:1
|
1 | extern crate cargo_check_bug;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: candidates:
= note: path: /home/colin/projects/rust/cargo_check_bug/target/debug/deps/libcargo_check_bug-0b76af5b42a4f158.so
= note: crate name: cargo_check_bug
= note: crate name: cargo_check_bug
error[E0463]: can’t find crate for cargo_check_bug
–> /tmp/rust-skeptic.U89a9gBDNE36/test.rs:1:1
|
1 | extern crate cargo_check_bug;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can’t find crate
error: aborting due to 2 previous errors
test readme_0 … FAILED
failures:
---- readme_0 stdout ----
thread ‘readme_0’ panicked at ‘Command failed:
“rustc” “/tmp/rust-skeptic.U89a9gBDNE36/test.rs” “–verbose” “-o” “/tmp/rust-skeptic.U89a9gBDNE36/out.exe” “–crate-type=bin” “-L” “/home/colin/projects/rust/cargo_check_bug/target/debug” “-L” “/home/colin/projects/rust/cargo_check_bug/target/debug/deps” “–extern” “pulldown_cmark=/home/colin/projects/rust/cargo_check_bug/target/debug/deps/libpulldown_cmark-ecfb67e72dcb6fb2.rlib” “–extern” “skeptic=/home/colin/projects/rust/cargo_check_bug/target/debug/deps/libskeptic-74b6fcba1ef2d3dc.rlib” “–extern” “getopts=/home/colin/projects/rust/cargo_check_bug/target/debug/deps/libgetopts-3facdbd0235704b0.rlib” “–extern” “tempdir=/home/colin/projects/rust/cargo_check_bug/target/debug/deps/libtempdir-0ee757a585f719dd.rlib” “–extern” “libc=/home/colin/projects/rust/cargo_check_bug/target/debug/deps/liblibc-5dc7b85e748840b4.rlib” “–extern” “bitflags=/home/colin/projects/rust/cargo_check_bug/target/debug/deps/libbitflags-8510a47beebe00a6.rlib” “–extern” “rand=/home/colin/projects/rust/cargo_check_bug/target/debug/deps/librand-c9d9fbdab2355ee4.rlib”’, /home/colin/.cargo/registry/src/github.com-1ecc6299db9ec823/skeptic-0.7.1/lib.rs:391
note: Run with RUST_BACKTRACE=1 for a backtrace.
failures:
readme_0
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
error: test failed
Cargo.toml
[package]
name = "cargo_check_bug"
version = "0.1.0"
build = "build.rs"
[lib]
proc-macro = true
[dependencies]
[build-dependencies]
skeptic = "0.7"
[dev-dependencies]
skeptic = "0.7"
build.rs
extern crate skeptic;
fn main() {
skeptic::generate_doc_tests(&["README.md"]);
}
README.md
```rust
extern crate cargo_check_bug;
fn main() {
}
```
tests/skeptic.rs
include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));
src/lib.rs
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_derive(Foo)]
pub fn derive(_input: TokenStream) -> TokenStream {
unimplemented!()
}
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 27 (13 by maintainers)
Commits related to this issue
- Run "cargo clean" before "cargo test" Possible work-around for https://github.com/budziq/rust-skeptic/issues/18 — committed to aerospike/aerospike-client-rust by jhecking 6 years ago
- feat: Put the test code inline into the test module This fixes two major issues with skeptic's current implementation at the cost of losing compile-fail tests. For many crates I expect this to be a w... — committed to Marwes/little-skeptic by Marwes 6 years ago
Thanks for the feedback @budziq! I’m pretty far down this rabbit hole now, so I’ll see for myself the problems you encountered.
I do have an idea I mentioned in #8 for combining every test case into a single binary such that
cargo buildonly needs to be executed once for the entire test set. That would hopefully be much faster than runningcargo buildfor every test.I’ve started hacking on a fix for this that emits every test case as an individual cargo project, sharing the target directory with the “master” project.
Oops, forgot to past back here about docmatic, my lite version based on people’s hacks here https://github.com/assert-rs/docmatic
One plausible way to fix this would be to have skeptic synthesize an entire cargo project from the original cargo project, for every test it generates, sharing target directories. Then run cargo instead of rustc, and have cargo figure out the deps.