Closed eliovir closed 10 years ago
Oh, neat. I didn't realize Cargo automatically checked examples for me. (I've still been using make test
.)
I don't really know how to use cargo test
. Specifically, the examples require that docopt_macros
is built. So there needs to be a way to specify a dependency on docopt_macros
in root/Cargo.toml
for testing?
@alexcrichton Any ideas? Is this possible yet?
This is little unfortunate, there's not necessarily a great way to express this as you'll end up with in theory some circular dependencies.
That being said, if you add this to your top-level Cargo.toml
the examples will build:
[dev-dependencies.docopt_macros]
path = "docopt_macros"
This in theory induces a circular dependency of docopt with itself, but it turns out that your Cargo.toml
for docopt_macros
depends on the git version of docopt, not the local version. This means that when you run cargo test
you'll build two versions of the docopt library, then the tests will pass.
Another alternative would be to have /examples
and /docopt_macros/examples
. If you split it like that then everything will "just work" because the examples that use the docopt_macros
crate will have it available and the other examples won't. Does that make sense?
Ah ha! Splitting the examples makes a lot of sense. I'll probably go that route. Seems simplest.
So when I do that, a new problem arises. When I cd
into docopt_macros
and run cargo test
, it tries to compile docopt_macros
with the git version of docopt
. But really, I'd like to test it against my local copy before pushing to the world. I could modify my config to use path
, but is there any other way? (I tried adding dev-dependencies.docopt
to docopt_macro
's Cargo.toml
, but it ends up compiling both versions of docopt
when running cargo test
(understanable) and that leads to trouble.)
Hmm, I can't seem to get any kind of cargo test
to work in ./docopt_macros
. I've tried using path
instead of git
to point to the docopt
dependency, but cargo tells me:
[andrew@Liger docopt_macros] cargo test
Compiling docopt v0.6.0 (file:/home/andrew/data/projects/docopt.rs/docopt_macros)
Compiling docopt_macros v0.6.0 (file:/home/andrew/data/projects/docopt.rs/docopt_macros)
/home/andrew/data/projects/docopt.rs/docopt_macros/target/test/docopt_macros-754b83a3bcc7f2df: error while loading shared libraries: libdocopt-bea495e631e19a4e.so: cannot open shared object file: No such file or directory
Could not execute process `/home/andrew/data/projects/docopt.rs/docopt_macros/target/test/docopt_macros-754b83a3bcc7f2df` (status=127)
Cargo.toml:
[package]
name = "docopt_macros"
version = "0.6.0"
authors = ["Andrew Gallant <jamslam@gmail.com>"]
[[lib]]
name = "docopt_macros"
path = "src/macro.rs"
plugin = true
[dependencies.docopt]
# git = "https://github.com/BurntSushi/docopt.rs"
path = "/home/andrew/data/projects/docopt.rs"
Hm, I think that's a bug in rustdoc, I'll look into it!
cargo*
Should be fixed in master now!
Great, that seems to fix the docopt_macros
problem. Thanks! Although, now in docopt
, cargo test
runs rustdoc
, but that fails because the doc tests require docopt_macros
. I'll try to file a proper bug report.
After cloning the repository, I tried to run
cargo test
, but it fails withThe same problem occurs while running directly rustc:
rustc -L ./build examples/add.rs