Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to generate and persist a test executable for documentation tests #37048

Closed
sunjay opened this issue Oct 9, 2016 · 2 comments
Closed
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@sunjay
Copy link
Member

sunjay commented Oct 9, 2016

I couldn't find an existing issue for this so I thought I would bring it up. Pardon me if this is a duplicate or in the wrong repository.

I wrote an in depth guide about Rust code coverage a few months ago based on the older guide that had been around for a while. One of the things I wrote about was that you can't currently get code coverage for documentation tests because cargo test or cargo test --doc doesn't output any test executable for documentation tests. The tool being used to generate coverage data, kcov, requires an executable that directly runs the code you want to measure.

It would be really helpful if there was a way not to just temporarily generate an executable for documentation tests, but also to have the option to store that executable somewhere (much like how the unit test executable is generated and stored in target/debug). That way we can manually run it using whatever tools we please.

I'm really surprised that I couldn't find an existing issue for this. There is a StackOverflow question about the issue but it doesn't lead anywhere. Hopefully this is a duplicate and it's been on your radar for some time.

@Mark-Simulacrum Mark-Simulacrum added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label May 14, 2017
@steveklabnik steveklabnik added the T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. label May 18, 2017
@xd009642
Copy link
Contributor

@steveklabnik Has there been any progress on this issue? This is an area of interest for me as well.

@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 26, 2017
@repnop
Copy link
Contributor

repnop commented Oct 3, 2018

I'm like to take a stab at this, if that's okay!

bors added a commit that referenced this issue Jan 18, 2019
…eavus

rustdoc: Add option to persist doc test executables

Fixes #37048.

This is the initial version of the code so the doctest executables can be used for stuff like code coverage (specifically xd009642/tarpaulin#13) the folders it goes into were just a first idea, so any better ones are welcome.

Right now it creates a directory structure like:
```
  given_path/
          |_____ <filename>_rs_<linenum>/
          |_____ ...
          |_____ <filename>_rs_<linenum>/
                 |_____ rust_out

```
I couldn't figure out where it actually outputs the file w/ the name, I suspect its somewhere deeper in the compiler.

It also adds the unstable `--persist-doctests` flag to `rustdoc` that enables this behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants