Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build Rust examples without running

Is there any way to build Rust examples without running them? Specifically to test examples build successfully using Travis CI.

like image 578
Ross Muir Avatar asked Apr 30 '15 13:04

Ross Muir


People also ask

What cargo build does?

Cargo is Rust's build system and package manager. Most Rustaceans use this tool to manage their Rust projects because Cargo handles a lot of tasks for you, such as building your code, downloading the libraries your code depends on, and building those libraries.

How do you run a cargo test?

Cargo can run your tests with the cargo test command. Cargo looks for tests to run in two places: in each of your src files and any tests in tests/ . Tests in your src files should be unit tests and documentation tests. Tests in tests/ should be integration-style tests.

What is cargo build -- release?

The Rust Programming Language Cargo has two main profiles: the dev profile Cargo uses when you run cargo build and the release profile Cargo uses when you run cargo build --release . The dev profile is defined with good defaults for development, and the release profile has good defaults for release builds.

What is cargo for rust?

What is Cargo in Rust? Cargo is Rust's build system and package manager. With this tool, you'll get a repeatable build because it allows Rust packages to declare their dependencies in the manifest, Cargo. toml .


2 Answers

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.

like image 141
huon Avatar answered Oct 11 '22 01:10

huon


I use the following code to run with Travis

language: rust
rust:
  - stable
  - beta
script:
  - cargo build --verbose --all
  - cargo test --verbose --all
like image 30
Kevin Martins Avatar answered Oct 11 '22 02:10

Kevin Martins