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

Enhance documentation of testing #10726

Merged
merged 9 commits into from
Jun 5, 2022
Merged

Conversation

weihanglo
Copy link
Member

What does this PR try to resolve?

Enhance Cargo docs a bit on testing topic. Related issues:

How should we test and review this PR?

All changes are described in commit message.
You can build the doc and help proofread some of these pages:

  • guide/tests.html
  • reference/cargo-targets.html#tests
  • commands/cargo-test.html#description
  • commands/cargo-build.html#description
  • commands/cargo-rustc.html#description
  • commands/cargo-bench.html#description

Additional information

I am not sure whether we should include undocumented execution model of doctests, which is the last commit, though I added a warning pointing out this truth. I can drop it if anyone in the team disagrees.

- Mention that in `src/` Cargo also collect doc tests.
- Remove outdated statement: Cargo no longer tests examples by default.
- Add a link to "Cargo Targets: Tests" to help people learn about it.
NOTE: This is an undocumented implementation details.
@rust-highfive
Copy link

r? @ehuss

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 3, 2022
@epage
Copy link
Contributor

epage commented Jun 3, 2022

Overall, looks like a good improvement. Addressing the wording tweak is all I see thats needed before merging

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

Looks good!

src/doc/man/cargo-test.md Outdated Show resolved Hide resolved
the test harness to tell it to run only benchmarks.
Benchmarks are built with the `--test` option to `rustc` which creates a
special executable by linking your code with libtest. The executable
automatically runs all functions annotated with the `#[test]` attribute.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
automatically runs all functions annotated with the `#[test]` attribute.
automatically runs all functions annotated with `#[test]` and `#[bench]` attributes.

I was slightly confused reading this due to the mention of #[test]. I'm not sure if this is any clearer. This is delving into some low-level details that is mostly not relevant to the average user.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. Now I feel like mentioning #[bench] is enough. I'll put it back then.

- Rephrase doctest exec model as "not guranteed and may change" instead
- Mention `#[bench]` in what cargo-bench automatically runs
- Make it clear for build/rustc when mentioning bin targets auto-built
Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

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

@ehuss not merging this in case you want to look over the changes in response to your comments

weihanglo and others added 2 commits June 4, 2022 21:43
This is too details and not for averaged users.
@ehuss
Copy link
Contributor

ehuss commented Jun 5, 2022

Thanks! I pushed a small wording tweak.

@bors r=epage

@bors
Copy link
Contributor

bors commented Jun 5, 2022

📌 Commit 5d33609 has been approved by epage

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 5, 2022
@bors
Copy link
Contributor

bors commented Jun 5, 2022

⌛ Testing commit 5d33609 with merge cce487e...

@bors
Copy link
Contributor

bors commented Jun 5, 2022

☀️ Test successful - checks-actions
Approved by: epage
Pushing cce487e to master...

@bors bors merged commit cce487e into rust-lang:master Jun 5, 2022
@weihanglo weihanglo deleted the test-doc-enhance branch June 5, 2022 21:18
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 8, 2022
Update cargo

7 commits in 38472bc19f2f76e245eba54a6e97ee6821b3c1db..85e457e158db216a2938d51bc3b617a5a7fe6015
2022-05-31 02:03:24 +0000 to 2022-06-07 21:57:52 +0000
- Make -Z http-registry use index.crates.io when accessing crates-io (rust-lang/cargo#10725)
- Respect submodule update=none strategy in .gitmodules (rust-lang/cargo#10717)
- Expose rust-version through env var (rust-lang/cargo#10713)
- add validation for string "true"/"false" in lto profile (rust-lang/cargo#10676)
- Enhance documentation of testing (rust-lang/cargo#10726)
- Clear disk space on CI. (rust-lang/cargo#10724)
- Enforce to use tar v0.4.38 (rust-lang/cargo#10720)
@ehuss ehuss added this to the 1.63.0 milestone Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants