diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs
index b0aaae51bc9..1815ee62f9f 100644
--- a/src/bin/cargo/commands/test.rs
+++ b/src/bin/cargo/commands/test.rs
@@ -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()
diff --git a/tests/testsuite/cargo_test/help/stdout.term.svg b/tests/testsuite/cargo_test/help/stdout.term.svg
index 5146edb1f15..e5ddd2ee598 100644
--- a/tests/testsuite/cargo_test/help/stdout.term.svg
+++ b/tests/testsuite/cargo_test/help/stdout.term.svg
@@ -37,65 +37,65 @@
Options:
- --doc Test only this library's documentation
+ --no-run Compile, but don't run tests
- --no-run Compile, but don't run tests
+ --no-fail-fast Run all tests regardless of failure
- --no-fail-fast Run all tests regardless of failure
+ --future-incompat-report Outputs a future incompatibility report at the end of the build
- --future-incompat-report Outputs a future incompatibility report at the end of the build
+ --message-format <FMT> Error format
- --message-format <FMT> Error format
+ -q, --quiet Display one character per test instead of one line
- -q, --quiet Display one character per test instead of one line
+ -v, --verbose... Use verbose output (-vv very verbose/build.rs output)
- -v, --verbose... Use verbose output (-vv very verbose/build.rs output)
+ --color <WHEN> Coloring: auto, always, never
- --color <WHEN> Coloring: auto, always, never
+ --config <KEY=VALUE> Override a configuration value
- --config <KEY=VALUE> Override a configuration value
+ -Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for
- -Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for
+ details
- details
+ -h, --help Print help
- -h, --help Print help
+
-
+ Package Selection:
- Package Selection:
+ -p, --package [<SPEC>] Package to run tests for
- -p, --package [<SPEC>] Package to run tests for
+ --workspace Test all packages in the workspace
- --workspace Test all packages in the workspace
+ --exclude <SPEC> Exclude packages from the test
- --exclude <SPEC> Exclude packages from the test
+ --all Alias for --workspace (deprecated)
- --all Alias for --workspace (deprecated)
+
-
+ Target Selection:
- Target Selection:
+ --lib Test only this package's library
- --lib Test only this package's library
+ --bins Test all binaries
- --bins Test all binaries
+ --bin [<NAME>] Test only the specified binary
- --bin [<NAME>] Test only the specified binary
+ --examples Test all examples
- --examples Test all examples
+ --example [<NAME>] Test only the specified example
- --example [<NAME>] Test only the specified example
+ --tests Test all test targets
- --tests Test all test targets
+ --test [<NAME>] Test only the specified test target
- --test [<NAME>] Test only the specified test target
+ --benches Test all bench targets
- --benches Test all bench targets
+ --bench [<NAME>] Test only the specified bench target
- --bench [<NAME>] Test only the specified bench target
+ --all-targets Test all targets (does not include doctests)
- --all-targets Test all targets (does not include doctests)
+ --doc Test only this library's documentation