What are the plans for coverage out of the box

Hi, I am a newbie in rust. There was an issue about "Coverage out of the box?" and it got closed in may 2019. Was coverage implemented? I can not find any docs ?

1 Like

State of the art is probably tarpaulin.

While it would definitely be nice for cargo to support coverage natively, there are a number of confounding factors:

  • Coverage techniques are highly platform dependent. Cargo is cross-platform; if the standard distribution provides a coverage tool (say, by distributing tarpaulin through rustup), it should probably support all tier-1 platforms.
    • On the other hand, coverage typically only needs to support x86_64 Linux, as it's typically primarily just run on CI.
  • There are a number of techniques for tracking coverage, none of which are clearly the best (nor any of which have been shown to actually be fully accurate on Rust code yet; with tarpaulin in my experience you can expect about 5% of inaccuracy in idiomatic code).
  • there are a number of ways of tracking coverage -- line, branch, and expression -- all of which require different techniques to do properly
  • there's the Go approach which just adds a racy static for every line as a compiler transform, but, being a deliberate race condition, goes very much against Rust's core principals

There's just a lot of design space still open. Progress is being made, but it's mostly in increasing the accuracy of debug information and tracking that with existing coverage tools (like grcov and others).

It'd be interesting to implement the "global flag" compiler transform, which would probably require compiler support.

1 Like

State of art I suppose is this recently merged https://github.com/rust-lang/rust/pull/73011 . To use already exists llvm stuff to deal with coverage calculation.

3 Likes

Thank you @CAD97 and @Dushistov I will have a look at both. Thanks to @CAD97. I honestly was not aware of the difficulties that coverage brings with it. Do you@CAD97 have a tip for me where I can find good resources about how coverage is really implemented?

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.