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

Add precision about which files will have their documentation examples tested #80649

Conversation

GuillaumeGomez
Copy link
Member

Fixes #79587.

cc @robinst

Having a second opinion on the wording from a native english speaker would be very useful here.

r? @jyn514

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 3, 2021
@@ -3,6 +3,9 @@
`rustdoc` supports executing your documentation examples as tests. This makes sure
that examples within your documentation are up to date and working.

Before going any further, please note that only documentation examples in the source
code are run. So if you have ones in your `tests` folder files, they won't be run.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it should be part of the Cargo docs or the book. Rustdoc doesn't assign any meaning to src/ or tests/.

Copy link
Member

@jyn514 jyn514 Jan 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or in other words, if you use rustdoc --test directly it works fine. It's only going through cargo that breaks.

$ rustdoc --test tests/doc.rs 

running 1 test
test tests/doc.rs - (line 1) ... FAILED

failures:

---- tests/doc.rs - (line 1) stdout ----
Test executable failed (exit code 101).

stderr:
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `2`', tests/doc.rs:3:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. I'll comment that on the issue. Closing this PR then!

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2021
@GuillaumeGomez GuillaumeGomez deleted the improve-doc-test-documentation branch January 3, 2021 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-cargo Relevant to the cargo team, 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

Successfully merging this pull request may close these issues.

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