7

I'm trying to run kcov on a Rust project. This works really well for usual tests, but I haven't been able to figure out how to make it find doc tests.

Does rustdoc create any binaries that I can pass to kcov to run coverage on?

dragostis
  • 2,574
  • 2
  • 20
  • 39
  • 4
    From a quick browsing of the source, I think the answer will be "no", but I'll wait to see if someone more knowledgeable can answer. However, I would question the underlying premise. Examples in documentation exist to show consumers of your code how to use it in a easily-understandable manner. They are executed and validated mostly to prevent the examples from rotting over time. I wouldn't count a doc test as actually validating any functionality of the code, thus I wouldn't include it in coverage statistics. – Shepmaster Feb 22 '16 at 16:34
  • Yeah, I would interpret doctests as testing the documentation, not the code. Coverage is implicitly 100% with doctests because it's testing all the code in the documentation. – Linear Feb 22 '16 at 22:20

1 Answers1

2

Rustdoc compiles binaries in a temporary directory and runs them immediately:

https://github.com/rust-lang/rust/blob/acdd3b9f5a/src/librustdoc/test.rs#L248-L292

I think the TempDir destructor removes the temporary directory and its contents when the function end. There doesn’t seem to be any way to get at the binaries in order to run them in kcov.

Simon Sapin
  • 9,790
  • 3
  • 35
  • 44