Tutorial: How to collect test coverages for Rust project

Here's how to tell Travis to do that automatically and upload the result to Coveralls.io.

Put this in your .travis.yml:

language: rust
after_success: |
  sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev &&
  wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
  tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make &&
  sudo make install && cd ../.. &&
  kcov --coveralls-id=$TRAVIS_JOB_ID --exclude-pattern=/.cargo target/kcov target/debug/<<<MY_PROJECT_NAME>>>-*

Remember to replace <<<MY_PROJECT_NAME>>> with the name of your crate (leave the -* in place, these will match the hash appended to the binary).

11 Likes