Running coverage with rust is not a simple task.
Basically in linux you have to install kcov, run the tests with it using some crazy pattern based for loop and for specific hashes (which changes in every build), and only include your sources in the kcov coverage checks.
At the end, you might also want to upload the results to codecov for example.
With cargo-make this is now a single line command.
For debian based distros you can install kcov with a single command:
cargo make kcov-install-debian
cargo make coverage-flow
This basically runs kcov for you against all your unit and integration tests and generate a report under target/coverage.
Travis - Installing, Running and Uploading coverage report to codecov
cargo make ci-flow
This will run the following:
- cargo build
- cargo test
- install kcov
- run coverage
- upload to codecov
The last 3 parts for the coverage are only enabled if you define the CARGO_MAKE_RUN_CODECOV=“true” env var.
A simple .travis.yml
language: rust sudo: true dist: trusty group: edge rust: - stable - beta - nightly env: global: - RUST_BACKTRACE=1 - RUSTFLAGS="-C link-dead-code" - CARGO_MAKE_RUN_CODECOV="true" script: - cargo install --debug cargo-make - cargo make ci-flow
Could this be any simpler?