Skip to content

Commit e5b9f23

Browse files
committed
test(cli): Track --help output
This makes it easier to evaluate the usability of PRs, like #11905
1 parent 917ed3a commit e5b9f23

File tree

157 files changed

+1767
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+1767
-0
lines changed

Diff for: tests/testsuite/cargo/help/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use cargo_test_support::curr_dir;
2+
use cargo_test_support::prelude::*;
3+
4+
#[cargo_test]
5+
fn case() {
6+
snapbox::cmd::Command::cargo_ui()
7+
.arg("--help")
8+
.assert()
9+
.success()
10+
.stdout_matches_path(curr_dir!().join("stdout.log"))
11+
.stderr_matches_path(curr_dir!().join("stderr.log"));
12+
}

Diff for: tests/testsuite/cargo/help/stderr.log

Whitespace-only changes.

Diff for: tests/testsuite/cargo/help/stdout.log

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Rust's package manager
2+
3+
Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
4+
5+
Options:
6+
-V, --version Print version info and exit
7+
--list List installed commands
8+
--explain <CODE> Run `rustc --explain CODE`
9+
-v, --verbose... Use verbose output (-vv very verbose/build.rs output)
10+
-q, --quiet Do not print cargo log messages
11+
--color <WHEN> Coloring: auto, always, never
12+
-C <DIRECTORY> Change to DIRECTORY before doing anything
13+
--frozen Require Cargo.lock and cache are up to date
14+
--locked Require Cargo.lock is up to date
15+
--offline Run without accessing the network
16+
--config <KEY=VALUE> Override a configuration value
17+
-Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
18+
-h, --help Print help
19+
20+
Some common cargo commands are (see all commands with --list):
21+
build, b Compile the current package
22+
check, c Analyze the current package and report errors, but don't build object files
23+
clean Remove the target directory
24+
doc, d Build this package's and its dependencies' documentation
25+
new Create a new cargo package
26+
init Create a new cargo package in an existing directory
27+
add Add dependencies to a manifest file
28+
remove Remove dependencies from a manifest file
29+
run, r Run a binary or example of the local package
30+
test, t Run the tests
31+
bench Run the benchmarks
32+
update Update dependencies listed in Cargo.lock
33+
search Search registry for crates
34+
publish Package and upload this package to the registry
35+
install Install a Rust binary. Default location is $HOME/.cargo/bin
36+
uninstall Uninstall a Rust binary
37+
38+
See 'cargo help <command>' for more information on a specific command.

Diff for: tests/testsuite/cargo/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod help;

Diff for: tests/testsuite/cargo_add/help/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use cargo_test_support::curr_dir;
2+
use cargo_test_support::prelude::*;
3+
4+
#[cargo_test]
5+
fn case() {
6+
snapbox::cmd::Command::cargo_ui()
7+
.arg("add")
8+
.arg("--help")
9+
.assert()
10+
.success()
11+
.stdout_matches_path(curr_dir!().join("stdout.log"))
12+
.stderr_matches_path(curr_dir!().join("stderr.log"));
13+
}

Diff for: tests/testsuite/cargo_add/help/stderr.log

Whitespace-only changes.

Diff for: tests/testsuite/cargo_add/help/stdout.log

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
Add dependencies to a Cargo.toml manifest file
2+
3+
Usage: cargo add [OPTIONS] <DEP>[@<VERSION>] ...
4+
cargo add [OPTIONS] --path <PATH> ...
5+
cargo add [OPTIONS] --git <URL> ...
6+
7+
Arguments:
8+
[DEP_ID]...
9+
Reference to a package to add as a dependency
10+
11+
You can reference a package by:
12+
- `<name>`, like `cargo add serde` (latest version will be used)
13+
- `<name>@<version-req>`, like `cargo add serde@1` or `cargo add serde@=1.0.38`
14+
15+
Options:
16+
--no-default-features
17+
Disable the default features
18+
19+
--default-features
20+
Re-enable the default features
21+
22+
-F, --features <FEATURES>
23+
Space or comma separated list of features to activate
24+
25+
--optional
26+
Mark the dependency as optional
27+
28+
The package name will be exposed as feature of your crate.
29+
30+
-v, --verbose...
31+
Use verbose output (-vv very verbose/build.rs output)
32+
33+
--no-optional
34+
Mark the dependency as required
35+
36+
The package will be removed from your features.
37+
38+
--color <WHEN>
39+
Coloring: auto, always, never
40+
41+
--rename <NAME>
42+
Rename the dependency
43+
44+
Example uses:
45+
- Depending on multiple versions of a crate
46+
- Depend on crates with the same name from different registries
47+
48+
--manifest-path <PATH>
49+
Path to Cargo.toml
50+
51+
--frozen
52+
Require Cargo.lock and cache are up to date
53+
54+
-p, --package [<SPEC>]
55+
Package to modify
56+
57+
--locked
58+
Require Cargo.lock is up to date
59+
60+
-q, --quiet
61+
Do not print cargo log messages
62+
63+
--dry-run
64+
Don't actually write the manifest
65+
66+
--offline
67+
Run without accessing the network
68+
69+
--config <KEY=VALUE>
70+
Override a configuration value
71+
72+
-Z <FLAG>
73+
Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
74+
75+
-h, --help
76+
Print help (see a summary with '-h')
77+
78+
Source:
79+
--path <PATH>
80+
Filesystem path to local crate to add
81+
82+
--git <URI>
83+
Git repository location
84+
85+
Without any other information, cargo will use latest commit on the main branch.
86+
87+
--branch <BRANCH>
88+
Git branch to download the crate from
89+
90+
--tag <TAG>
91+
Git tag to download the crate from
92+
93+
--rev <REV>
94+
Git reference to download the crate from
95+
96+
This is the catch all, handling hashes to named references in remote repositories.
97+
98+
--registry <NAME>
99+
Package registry for this dependency
100+
101+
Section:
102+
--dev
103+
Add as development dependency
104+
105+
Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks.
106+
107+
These dependencies are not propagated to other packages which depend on this package.
108+
109+
--build
110+
Add as build dependency
111+
112+
Build-dependencies are the only dependencies available for use by build scripts (`build.rs` files).
113+
114+
--target <TARGET>
115+
Add as dependency to the given target platform
116+
117+
Run `cargo help add` for more detailed information.

Diff for: tests/testsuite/cargo_add/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ mod git_normalized_name;
3333
mod git_registry;
3434
mod git_rev;
3535
mod git_tag;
36+
mod help;
3637
mod infer_prerelease;
3738
mod invalid_arg;
3839
mod invalid_git_external;

Diff for: tests/testsuite/cargo_bench/help/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use cargo_test_support::curr_dir;
2+
use cargo_test_support::prelude::*;
3+
4+
#[cargo_test]
5+
fn case() {
6+
snapbox::cmd::Command::cargo_ui()
7+
.arg("bench")
8+
.arg("--help")
9+
.assert()
10+
.success()
11+
.stdout_matches_path(curr_dir!().join("stdout.log"))
12+
.stderr_matches_path(curr_dir!().join("stderr.log"));
13+
}

Diff for: tests/testsuite/cargo_bench/help/stderr.log

Whitespace-only changes.

Diff for: tests/testsuite/cargo_bench/help/stdout.log

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Execute all benchmarks of a local package
2+
3+
Usage: cargo[EXE] bench [OPTIONS] [BENCHNAME] [-- [args]...]
4+
5+
Arguments:
6+
[BENCHNAME] If specified, only run benches containing this string in their names
7+
[args]... Arguments for the bench binary
8+
9+
Options:
10+
-q, --quiet Do not print cargo log messages
11+
--lib Benchmark only this package's library
12+
--bin [<NAME>] Benchmark only the specified binary
13+
--bins Benchmark all binaries
14+
-v, --verbose... Use verbose output (-vv very verbose/build.rs output)
15+
--example [<NAME>] Benchmark only the specified example
16+
--color <WHEN> Coloring: auto, always, never
17+
--examples Benchmark all examples
18+
--test [<NAME>] Benchmark only the specified test target
19+
--frozen Require Cargo.lock and cache are up to date
20+
--tests Benchmark all tests
21+
--bench [<NAME>] Benchmark only the specified bench target
22+
--locked Require Cargo.lock is up to date
23+
--benches Benchmark all benches
24+
--offline Run without accessing the network
25+
--all-targets Benchmark all targets
26+
--config <KEY=VALUE> Override a configuration value
27+
--no-run Compile, but don't run benchmarks
28+
-Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
29+
-p, --package [<SPEC>] Package to run benchmarks for
30+
--workspace Benchmark all packages in the workspace
31+
--exclude <SPEC> Exclude packages from the benchmark
32+
--all Alias for --workspace (deprecated)
33+
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs
34+
--keep-going Do not abort the build as soon as there is an error (unstable)
35+
--profile <PROFILE-NAME> Build artifacts with the specified profile
36+
-F, --features <FEATURES> Space or comma separated list of features to activate
37+
--all-features Activate all available features
38+
--no-default-features Do not activate the `default` feature
39+
--target <TRIPLE> Build for the target triple
40+
--target-dir <DIRECTORY> Directory for all generated artifacts
41+
--manifest-path <PATH> Path to Cargo.toml
42+
--ignore-rust-version Ignore `rust-version` specification in packages
43+
--message-format <FMT> Error format
44+
--no-fail-fast Run all benchmarks regardless of failure
45+
--unit-graph Output build graph in JSON (unstable)
46+
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json
47+
-h, --help Print help
48+
49+
Run `cargo help bench` for more detailed information.

Diff for: tests/testsuite/cargo_bench/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod help;

Diff for: tests/testsuite/cargo_build/help/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use cargo_test_support::curr_dir;
2+
use cargo_test_support::prelude::*;
3+
4+
#[cargo_test]
5+
fn case() {
6+
snapbox::cmd::Command::cargo_ui()
7+
.arg("build")
8+
.arg("--help")
9+
.assert()
10+
.success()
11+
.stdout_matches_path(curr_dir!().join("stdout.log"))
12+
.stderr_matches_path(curr_dir!().join("stderr.log"));
13+
}

Diff for: tests/testsuite/cargo_build/help/stderr.log

Whitespace-only changes.

Diff for: tests/testsuite/cargo_build/help/stdout.log

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Compile a local package and all of its dependencies
2+
3+
Usage: cargo[EXE] build [OPTIONS]
4+
5+
Options:
6+
-q, --quiet Do not print cargo log messages
7+
-p, --package [<SPEC>] Package to build (see `cargo help pkgid`)
8+
--workspace Build all packages in the workspace
9+
--exclude <SPEC> Exclude packages from the build
10+
-v, --verbose... Use verbose output (-vv very verbose/build.rs output)
11+
--all Alias for --workspace (deprecated)
12+
--color <WHEN> Coloring: auto, always, never
13+
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs
14+
--keep-going Do not abort the build as soon as there is an error (unstable)
15+
--frozen Require Cargo.lock and cache are up to date
16+
--lib Build only this package's library
17+
--bin [<NAME>] Build only the specified binary
18+
--locked Require Cargo.lock is up to date
19+
--bins Build all binaries
20+
--offline Run without accessing the network
21+
--config <KEY=VALUE> Override a configuration value
22+
--example [<NAME>] Build only the specified example
23+
--examples Build all examples
24+
-Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
25+
--test [<NAME>] Build only the specified test target
26+
--tests Build all tests
27+
--bench [<NAME>] Build only the specified bench target
28+
--benches Build all benches
29+
--all-targets Build all targets
30+
-r, --release Build artifacts in release mode, with optimizations
31+
--profile <PROFILE-NAME> Build artifacts with the specified profile
32+
-F, --features <FEATURES> Space or comma separated list of features to activate
33+
--all-features Activate all available features
34+
--no-default-features Do not activate the `default` feature
35+
--target <TRIPLE> Build for the target triple
36+
--target-dir <DIRECTORY> Directory for all generated artifacts
37+
--out-dir <PATH> Copy final artifacts to this directory (unstable)
38+
--manifest-path <PATH> Path to Cargo.toml
39+
--ignore-rust-version Ignore `rust-version` specification in packages
40+
--message-format <FMT> Error format
41+
--build-plan Output the build plan in JSON (unstable)
42+
--unit-graph Output build graph in JSON (unstable)
43+
--future-incompat-report Outputs a future incompatibility report at the end of the build
44+
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json
45+
-h, --help Print help
46+
47+
Run `cargo help build` for more detailed information.

Diff for: tests/testsuite/cargo_build/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod help;

Diff for: tests/testsuite/cargo_check/help/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use cargo_test_support::curr_dir;
2+
use cargo_test_support::prelude::*;
3+
4+
#[cargo_test]
5+
fn case() {
6+
snapbox::cmd::Command::cargo_ui()
7+
.arg("check")
8+
.arg("--help")
9+
.assert()
10+
.success()
11+
.stdout_matches_path(curr_dir!().join("stdout.log"))
12+
.stderr_matches_path(curr_dir!().join("stderr.log"));
13+
}

Diff for: tests/testsuite/cargo_check/help/stderr.log

Whitespace-only changes.

Diff for: tests/testsuite/cargo_check/help/stdout.log

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Check a local package and all of its dependencies for errors
2+
3+
Usage: cargo[EXE] check [OPTIONS]
4+
5+
Options:
6+
-q, --quiet Do not print cargo log messages
7+
-p, --package [<SPEC>] Package(s) to check
8+
--workspace Check all packages in the workspace
9+
--exclude <SPEC> Exclude packages from the check
10+
-v, --verbose... Use verbose output (-vv very verbose/build.rs output)
11+
--all Alias for --workspace (deprecated)
12+
--color <WHEN> Coloring: auto, always, never
13+
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs
14+
--keep-going Do not abort the build as soon as there is an error (unstable)
15+
--frozen Require Cargo.lock and cache are up to date
16+
--lib Check only this package's library
17+
--bin [<NAME>] Check only the specified binary
18+
--locked Require Cargo.lock is up to date
19+
--bins Check all binaries
20+
--offline Run without accessing the network
21+
--config <KEY=VALUE> Override a configuration value
22+
--example [<NAME>] Check only the specified example
23+
--examples Check all examples
24+
-Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
25+
--test [<NAME>] Check only the specified test target
26+
--tests Check all tests
27+
--bench [<NAME>] Check only the specified bench target
28+
--benches Check all benches
29+
--all-targets Check all targets
30+
-r, --release Check artifacts in release mode, with optimizations
31+
--profile <PROFILE-NAME> Check artifacts with the specified profile
32+
-F, --features <FEATURES> Space or comma separated list of features to activate
33+
--all-features Activate all available features
34+
--no-default-features Do not activate the `default` feature
35+
--target <TRIPLE> Check for the target triple
36+
--target-dir <DIRECTORY> Directory for all generated artifacts
37+
--manifest-path <PATH> Path to Cargo.toml
38+
--ignore-rust-version Ignore `rust-version` specification in packages
39+
--message-format <FMT> Error format
40+
--unit-graph Output build graph in JSON (unstable)
41+
--future-incompat-report Outputs a future incompatibility report at the end of the build
42+
--timings[=<FMTS>] Timing output formats (unstable) (comma separated): html, json
43+
-h, --help Print help
44+
45+
Run `cargo help check` for more detailed information.

Diff for: tests/testsuite/cargo_check/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod help;

Diff for: tests/testsuite/cargo_clean/help/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use cargo_test_support::curr_dir;
2+
use cargo_test_support::prelude::*;
3+
4+
#[cargo_test]
5+
fn case() {
6+
snapbox::cmd::Command::cargo_ui()
7+
.arg("clean")
8+
.arg("--help")
9+
.assert()
10+
.success()
11+
.stdout_matches_path(curr_dir!().join("stdout.log"))
12+
.stderr_matches_path(curr_dir!().join("stderr.log"));
13+
}

Diff for: tests/testsuite/cargo_clean/help/stderr.log

Whitespace-only changes.

0 commit comments

Comments
 (0)