Skip to content

Commit 0e6ad5b

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

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

tests/testsuite/cargo/help/mod.rs

Lines changed: 12 additions & 0 deletions
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+
}

tests/testsuite/cargo/help/stderr.log

Whitespace-only changes.

tests/testsuite/cargo/help/stdout.log

Lines changed: 38 additions & 0 deletions
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.

tests/testsuite/cargo/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod help;

tests/testsuite/cargo_add/help/mod.rs

Lines changed: 13 additions & 0 deletions
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+
}

tests/testsuite/cargo_add/help/stderr.log

Whitespace-only changes.
Lines changed: 117 additions & 0 deletions
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.

tests/testsuite/cargo_add/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mod git_normalized_name;
3434
mod git_registry;
3535
mod git_rev;
3636
mod git_tag;
37+
mod help;
3738
mod infer_prerelease;
3839
mod invalid_arg;
3940
mod invalid_git_external;
Lines changed: 13 additions & 0 deletions
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+
}

tests/testsuite/cargo_bench/help/stderr.log

Whitespace-only changes.

0 commit comments

Comments
 (0)