0

EDIT: I've replaced this question with this one. I will delete this question soon. Thanks for the feedback.

I've setup code coverage in my Rust project, by using travis ci and coveralls. To do this I've used travis-cargo following its documentation. This is my .travis.yml file:

language: rust
sudo: required

before_script:
  - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH

rust:
  - stable
  - beta
  - nightly

script:
  - cargo test

after_success:
  - travis-cargo coveralls

However I'm facing a strange high coverage. Some files in the project gets a 100% coverage, even if they are actually not covered at all! Consider for example this file; the only test it contains is a dummy one:

#[cfg(test)]
mod test {
    #[test]
    fn it_works() {
    }
}

And the reported coverage is 100%. As you can see by coverage highlights in the coveralls page, all the source code lines are ignored, except the dummy test function.

What is the problem here? Maybe test binaries strip down unused functions and kcov cannot see them?

Community
  • 1
  • 1
mbrt
  • 1,958
  • 1
  • 17
  • 33
  • [*Include just enough code to allow others to reproduce the problem <...> include the code in your question itself*](http://stackoverflow.com/help/how-to-ask). Please produce an [MCVE](/help/mcve), preferably one that doesn't require an answerer to create a project that runs in Travis CI. – Shepmaster Sep 10 '15 at 13:29
  • @Shepmaster I thought it was simpler to use my project, since travis-ci is configured and the results are visible in the web page. However it is not MCVE. In case of a minimal example, I'd have to link to a tutorial on how to setup `kcov` locally, I suppose. What do you think? – mbrt Sep 10 '15 at 14:42
  • Please add the Cargo.toml at least. Without knowing if you have debug-symbols on, we cannot outrule this as possible problem source. – llogiq Sep 11 '15 at 05:45
  • @llogiq I've reproduced the problem locally. I'll post a new question as soon as I get a minimal reproducible example. – mbrt Sep 11 '15 at 07:30
  • Why not just [edit] this question? – Shepmaster Sep 11 '15 at 11:04
  • @Shepmaster I thought a complete rewrite implies a new question. Doesn't it? – mbrt Sep 11 '15 at 11:36
  • @brt only if it invalidates existing answers. Otherwise it's just a step along the journey to a really good question. Besides, the main question is the same, you just have a much better way of asking it now. ^_^ – Shepmaster Sep 11 '15 at 12:02
  • @brt: well, the new question is much better; however I advise you to avoid deleting your own questions too often, as it could trigger a question-ban. One is fine of course, just avoid doing it for some time now :) – Matthieu M. Sep 11 '15 at 13:38
  • @MatthieuM. Ok, I'll simply mark this question as duplicate. – mbrt Sep 11 '15 at 14:51

0 Answers0