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?

2
  • 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. Commented Feb 22, 2016 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. Commented Feb 22, 2016 at 22:20

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

There is. You can intercept them and copy them, but it's a pain to write.
Ok, let’s say no easy way :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.