Skip to content

Commit 5101372

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

File tree

157 files changed

+1807
-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

+1807
-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

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

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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+
--no-optional
31+
Mark the dependency as required
32+
33+
The package will be removed from your features.
34+
35+
--rename <NAME>
36+
Rename the dependency
37+
38+
Example uses:
39+
- Depending on multiple versions of a crate
40+
- Depend on crates with the same name from different registries
41+
42+
--ignore-rust-version
43+
Ignore `rust-version` specification in packages (unstable)
44+
45+
--manifest-path <PATH>
46+
Path to Cargo.toml
47+
48+
-p, --package [<SPEC>]
49+
Package to modify
50+
51+
-q, --quiet
52+
Do not print cargo log messages
53+
54+
--dry-run
55+
Don't actually write the manifest
56+
57+
-h, --help
58+
Print help (see a summary with '-h')
59+
60+
-v, --verbose...
61+
Use verbose output (-vv very verbose/build.rs output)
62+
63+
--color <WHEN>
64+
Coloring: auto, always, never
65+
66+
--frozen
67+
Require Cargo.lock and cache are up to date
68+
69+
--locked
70+
Require Cargo.lock is up to date
71+
72+
--offline
73+
Run without accessing the network
74+
75+
--config <KEY=VALUE>
76+
Override a configuration value
77+
78+
-Z <FLAG>
79+
Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
80+
81+
Source:
82+
--path <PATH>
83+
Filesystem path to local crate to add
84+
85+
--git <URI>
86+
Git repository location
87+
88+
Without any other information, cargo will use latest commit on the main branch.
89+
90+
--branch <BRANCH>
91+
Git branch to download the crate from
92+
93+
--tag <TAG>
94+
Git tag to download the crate from
95+
96+
--rev <REV>
97+
Git reference to download the crate from
98+
99+
This is the catch all, handling hashes to named references in remote repositories.
100+
101+
--registry <NAME>
102+
Package registry for this dependency
103+
104+
Section:
105+
--dev
106+
Add as development dependency
107+
108+
Dev-dependencies are not used when compiling a package for building, but are used for
109+
compiling tests, examples, and benchmarks.
110+
111+
These dependencies are not propagated to other packages which depend on this package.
112+
113+
--build
114+
Add as build dependency
115+
116+
Build-dependencies are the only dependencies available for use by build scripts
117+
(`build.rs` files).
118+
119+
--target <TARGET>
120+
Add as dependency to the given target platform
121+
122+
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
@@ -35,6 +35,7 @@ mod git_normalized_name;
3535
mod git_registry;
3636
mod git_rev;
3737
mod git_tag;
38+
mod help;
3839
mod infer_prerelease;
3940
mod invalid_arg;
4041
mod invalid_git_name;

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

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

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

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

0 commit comments

Comments
 (0)