问题
Is there any way to build Rust examples without running them? Specifically to test examples build successfully using Travis CI.
回答1:
cargo test
automatically builds examples (but doesn't run them). I believe it does this first, before the main test runners, but you can verify with cargo test -v
.
回答2:
I use the following code to run with Travis
language: rust
rust:
- stable
- beta
script:
- cargo build --verbose --all
- cargo test --verbose --all
回答3:
cargo test
runs examples.
To build them it I do this:
for i in examples/*; do cargo build --target=x86_64-pc-windows-gnu --verbose --example $(basename $i .rs); done
Cargo issue #192 covers a feature request for something similar.
来源:https://stackoverflow.com/questions/29969208/how-to-build-rust-examples-without-running