Auto merge of #13756 - dtolnay-contrib:testdoc, r=weihanglo

Recategorize cargo test's `--doc` flag under "Target Selection"

### What does this PR try to resolve?

In `cargo help test`, the `--doc` flag is listed under a section called "Target Selection" next to `--lib`, `--bin`, `--bins`, `--example`, `--examples`, `--test`, `--tests`, `--bench`, `--benches`, and `--all-targets`.

But in `cargo test --help`, it was instead listed in an "Options" section next to `--no-run`, `--message-format`, `--color`, etc, which seems less appropriate than "Target Selection".

### How should we test and review this PR?

- `cargo build --release`
- `cargo test --release --test testsuite -- cargo_test::help::case`
- `target/release/cargo test --help`
- `target/release/cargo help test` (unchanged)
This commit is contained in:
bors 2024-04-15 03:01:12 +00:00
commit a9f86addbc
2 changed files with 34 additions and 31 deletions

View File

@ -18,7 +18,6 @@ pub fn cli() -> Command {
.num_args(0..)
.last(true),
)
.arg(flag("doc", "Test only this library's documentation"))
.arg(flag("no-run", "Compile, but don't run tests"))
.arg(flag("no-fail-fast", "Run all tests regardless of failure"))
.arg_future_incompat_report()
@ -47,6 +46,10 @@ pub fn cli() -> Command {
"Test all bench targets",
"Test all targets (does not include doctests)",
)
.arg(
flag("doc", "Test only this library's documentation")
.help_heading(heading::TARGET_SELECTION),
)
.arg_features()
.arg_jobs()
.arg_unsupported_keep_going()

View File

@ -37,65 +37,65 @@
</tspan>
<tspan x="10px" y="172px"><tspan class="fg-green bold">Options:</tspan>
</tspan>
<tspan x="10px" y="190px"><tspan> </tspan><tspan class="fg-cyan bold">--doc</tspan><tspan> Test only this library's documentation</tspan>
<tspan x="10px" y="190px"><tspan> </tspan><tspan class="fg-cyan bold">--no-run</tspan><tspan> Compile, but don't run tests</tspan>
</tspan>
<tspan x="10px" y="208px"><tspan> </tspan><tspan class="fg-cyan bold">--no-run</tspan><tspan> Compile, but don't run tests</tspan>
<tspan x="10px" y="208px"><tspan> </tspan><tspan class="fg-cyan bold">--no-fail-fast</tspan><tspan> Run all tests regardless of failure</tspan>
</tspan>
<tspan x="10px" y="226px"><tspan> </tspan><tspan class="fg-cyan bold">--no-fail-fast</tspan><tspan> Run all tests regardless of failure</tspan>
<tspan x="10px" y="226px"><tspan> </tspan><tspan class="fg-cyan bold">--future-incompat-report</tspan><tspan> Outputs a future incompatibility report at the end of the build</tspan>
</tspan>
<tspan x="10px" y="244px"><tspan> </tspan><tspan class="fg-cyan bold">--future-incompat-report</tspan><tspan> Outputs a future incompatibility report at the end of the build</tspan>
<tspan x="10px" y="244px"><tspan> </tspan><tspan class="fg-cyan bold">--message-format</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;FMT&gt;</tspan><tspan> Error format</tspan>
</tspan>
<tspan x="10px" y="262px"><tspan> </tspan><tspan class="fg-cyan bold">--message-format</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;FMT&gt;</tspan><tspan> Error format</tspan>
<tspan x="10px" y="262px"><tspan> </tspan><tspan class="fg-cyan bold">-q</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--quiet</tspan><tspan> Display one character per test instead of one line</tspan>
</tspan>
<tspan x="10px" y="280px"><tspan> </tspan><tspan class="fg-cyan bold">-q</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--quiet</tspan><tspan> Display one character per test instead of one line</tspan>
<tspan x="10px" y="280px"><tspan> </tspan><tspan class="fg-cyan bold">-v</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--verbose</tspan><tspan class="fg-cyan">...</tspan><tspan> Use verbose output (-vv very verbose/build.rs output)</tspan>
</tspan>
<tspan x="10px" y="298px"><tspan> </tspan><tspan class="fg-cyan bold">-v</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--verbose</tspan><tspan class="fg-cyan">...</tspan><tspan> Use verbose output (-vv very verbose/build.rs output)</tspan>
<tspan x="10px" y="298px"><tspan> </tspan><tspan class="fg-cyan bold">--color</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;WHEN&gt;</tspan><tspan> Coloring: auto, always, never</tspan>
</tspan>
<tspan x="10px" y="316px"><tspan> </tspan><tspan class="fg-cyan bold">--color</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;WHEN&gt;</tspan><tspan> Coloring: auto, always, never</tspan>
<tspan x="10px" y="316px"><tspan> </tspan><tspan class="fg-cyan bold">--config</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;KEY=VALUE&gt;</tspan><tspan> Override a configuration value</tspan>
</tspan>
<tspan x="10px" y="334px"><tspan> </tspan><tspan class="fg-cyan bold">--config</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;KEY=VALUE&gt;</tspan><tspan> Override a configuration value</tspan>
<tspan x="10px" y="334px"><tspan> </tspan><tspan class="fg-cyan bold">-Z</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;FLAG&gt;</tspan><tspan> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for</tspan>
</tspan>
<tspan x="10px" y="352px"><tspan> </tspan><tspan class="fg-cyan bold">-Z</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;FLAG&gt;</tspan><tspan> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for</tspan>
<tspan x="10px" y="352px"><tspan> details</tspan>
</tspan>
<tspan x="10px" y="370px"><tspan> details</tspan>
<tspan x="10px" y="370px"><tspan> </tspan><tspan class="fg-cyan bold">-h</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--help</tspan><tspan> Print help</tspan>
</tspan>
<tspan x="10px" y="388px"><tspan> </tspan><tspan class="fg-cyan bold">-h</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--help</tspan><tspan> Print help</tspan>
<tspan x="10px" y="388px">
</tspan>
<tspan x="10px" y="406px">
<tspan x="10px" y="406px"><tspan class="fg-green bold">Package Selection:</tspan>
</tspan>
<tspan x="10px" y="424px"><tspan class="fg-green bold">Package Selection:</tspan>
<tspan x="10px" y="424px"><tspan> </tspan><tspan class="fg-cyan bold">-p</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--package</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;SPEC&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Package to run tests for</tspan>
</tspan>
<tspan x="10px" y="442px"><tspan> </tspan><tspan class="fg-cyan bold">-p</tspan><tspan>, </tspan><tspan class="fg-cyan bold">--package</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;SPEC&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Package to run tests for</tspan>
<tspan x="10px" y="442px"><tspan> </tspan><tspan class="fg-cyan bold">--workspace</tspan><tspan> Test all packages in the workspace</tspan>
</tspan>
<tspan x="10px" y="460px"><tspan> </tspan><tspan class="fg-cyan bold">--workspace</tspan><tspan> Test all packages in the workspace</tspan>
<tspan x="10px" y="460px"><tspan> </tspan><tspan class="fg-cyan bold">--exclude</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;SPEC&gt;</tspan><tspan> Exclude packages from the test</tspan>
</tspan>
<tspan x="10px" y="478px"><tspan> </tspan><tspan class="fg-cyan bold">--exclude</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan">&lt;SPEC&gt;</tspan><tspan> Exclude packages from the test</tspan>
<tspan x="10px" y="478px"><tspan> </tspan><tspan class="fg-cyan bold">--all</tspan><tspan> Alias for --workspace (deprecated)</tspan>
</tspan>
<tspan x="10px" y="496px"><tspan> </tspan><tspan class="fg-cyan bold">--all</tspan><tspan> Alias for --workspace (deprecated)</tspan>
<tspan x="10px" y="496px">
</tspan>
<tspan x="10px" y="514px">
<tspan x="10px" y="514px"><tspan class="fg-green bold">Target Selection:</tspan>
</tspan>
<tspan x="10px" y="532px"><tspan class="fg-green bold">Target Selection:</tspan>
<tspan x="10px" y="532px"><tspan> </tspan><tspan class="fg-cyan bold">--lib</tspan><tspan> Test only this package's library</tspan>
</tspan>
<tspan x="10px" y="550px"><tspan> </tspan><tspan class="fg-cyan bold">--lib</tspan><tspan> Test only this package's library</tspan>
<tspan x="10px" y="550px"><tspan> </tspan><tspan class="fg-cyan bold">--bins</tspan><tspan> Test all binaries</tspan>
</tspan>
<tspan x="10px" y="568px"><tspan> </tspan><tspan class="fg-cyan bold">--bins</tspan><tspan> Test all binaries</tspan>
<tspan x="10px" y="568px"><tspan> </tspan><tspan class="fg-cyan bold">--bin</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;NAME&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Test only the specified binary</tspan>
</tspan>
<tspan x="10px" y="586px"><tspan> </tspan><tspan class="fg-cyan bold">--bin</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;NAME&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Test only the specified binary</tspan>
<tspan x="10px" y="586px"><tspan> </tspan><tspan class="fg-cyan bold">--examples</tspan><tspan> Test all examples</tspan>
</tspan>
<tspan x="10px" y="604px"><tspan> </tspan><tspan class="fg-cyan bold">--examples</tspan><tspan> Test all examples</tspan>
<tspan x="10px" y="604px"><tspan> </tspan><tspan class="fg-cyan bold">--example</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;NAME&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Test only the specified example</tspan>
</tspan>
<tspan x="10px" y="622px"><tspan> </tspan><tspan class="fg-cyan bold">--example</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;NAME&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Test only the specified example</tspan>
<tspan x="10px" y="622px"><tspan> </tspan><tspan class="fg-cyan bold">--tests</tspan><tspan> Test all test targets</tspan>
</tspan>
<tspan x="10px" y="640px"><tspan> </tspan><tspan class="fg-cyan bold">--tests</tspan><tspan> Test all test targets</tspan>
<tspan x="10px" y="640px"><tspan> </tspan><tspan class="fg-cyan bold">--test</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;NAME&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Test only the specified test target</tspan>
</tspan>
<tspan x="10px" y="658px"><tspan> </tspan><tspan class="fg-cyan bold">--test</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;NAME&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Test only the specified test target</tspan>
<tspan x="10px" y="658px"><tspan> </tspan><tspan class="fg-cyan bold">--benches</tspan><tspan> Test all bench targets</tspan>
</tspan>
<tspan x="10px" y="676px"><tspan> </tspan><tspan class="fg-cyan bold">--benches</tspan><tspan> Test all bench targets</tspan>
<tspan x="10px" y="676px"><tspan> </tspan><tspan class="fg-cyan bold">--bench</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;NAME&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Test only the specified bench target</tspan>
</tspan>
<tspan x="10px" y="694px"><tspan> </tspan><tspan class="fg-cyan bold">--bench</tspan><tspan class="fg-cyan"> [</tspan><tspan class="fg-cyan">&lt;NAME&gt;</tspan><tspan class="fg-cyan">]</tspan><tspan> Test only the specified bench target</tspan>
<tspan x="10px" y="694px"><tspan> </tspan><tspan class="fg-cyan bold">--all-targets</tspan><tspan> Test all targets (does not include doctests)</tspan>
</tspan>
<tspan x="10px" y="712px"><tspan> </tspan><tspan class="fg-cyan bold">--all-targets</tspan><tspan> Test all targets (does not include doctests)</tspan>
<tspan x="10px" y="712px"><tspan> </tspan><tspan class="fg-cyan bold">--doc</tspan><tspan> Test only this library's documentation</tspan>
</tspan>
<tspan x="10px" y="730px">
</tspan>

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB