How to build Rust examples without running

旧城冷巷雨未停 提交于 2019-12-10 15:47:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!