Why does kcov calculate incorrect code coverage statistics for Rust programs?

后端 未结 2 1915
名媛妹妹
名媛妹妹 2020-12-17 17:34

I\'ve tried to use kcov to get code coverage for a Rust library. I\'ve followed this tutorial to build and use kcov. The coverage seems to work, however I\'m facing a strang

相关标签:
2条回答
  • 2020-12-17 17:54

    There is a workaround: the RUSTFLAGS='-C link-dead-code' environment variable. Use it while building and the Rust compiler will link dead code as well:

    RUSTFLAGS='-C link-dead-code' cargo test
    
    0 讨论(0)
  • 2020-12-17 18:10

    You're correct: totally unused functions are stripped at the moment, so coverage tools like kcov are only good for branch coverage within used functions (at least, the summary functionality of such tools). There is some discussion about making this not happen by default for test/debug builds.

    0 讨论(0)
提交回复
热议问题