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

Docs for documentation tests should mention where doctests are picked up from (e.g. not from files in tests/*) #9648

Closed
robinst opened this issue Dec 1, 2020 · 4 comments
Labels
A-doctests Area: rustdoc --test A-documenting-cargo-itself Area: Cargo's documentation

Comments

@robinst
Copy link
Contributor

robinst commented Dec 1, 2020

(@GuillaumeGomez asked me to open an issue here, see his comment: GuillaumeGomez/doc-comment#25 (comment))

The docs for documentation tests (https://doc.rust-lang.org/rustdoc/documentation-tests.html) don't currently mention in which files doctests can be put. E.g. they work if put into src/* files, but not in integration test files in tests/*. It would be good if that was mentioned there.

@GuillaumeGomez
Copy link
Member

Actually, this should better be in the cargo book instead since it's a cargo-linked issue here.

@robinst
Copy link
Contributor Author

robinst commented Jan 5, 2021

Good point, maybe add a note here instead: https://doc.rust-lang.org/cargo/commands/cargo-test.html

Documentation tests are also run by default, which is handled by rustdoc. It extracts code samples from documentation comments and executes them. See the rustdoc book for more information on writing doc tests.

@jyn514
Copy link
Member

jyn514 commented Jul 2, 2021

@ehuss could you please move this to rust-lang/cargo?

@ehuss ehuss transferred this issue from rust-lang/rust Jul 2, 2021
@ehuss ehuss added A-doctests Area: rustdoc --test A-documenting-cargo-itself Area: Cargo's documentation labels Jul 2, 2021
@weihanglo
Copy link
Member

Close as #10726 mentioning "doctests only applied to lib target" in more places (7860458, 2c9cfd6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: rustdoc --test A-documenting-cargo-itself Area: Cargo's documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants