Skip to content

Commit e2fbcd9

Browse files
committed
Auto merge of #11912 - epage:help, r=ehuss
test(cli): Track --help output ### What does this PR try to resolve? This makes it easier to evaluate the usability of PRs, like #11905 This follows the pattern of `cargo add` and `cargo remove` of putting these ui tests in `cargo_<cmd>/` directories. `init` didn't follow this pattern, so it was renamed to `cargo_init/`. `cargo_config.rs` was going to conflict with this, it was merged in. We can evaluate other `<cmd>.rs` files at a later point and consolidate. ### How should we test and review this PR? The main risks are - Are all files linked together (`main.rs` -> `<cmd>/mod.rs` -> `<cmd>/<help>.rs` - Are all `help/mod.rs`s pointing to the right command
2 parents 55281fd + 5101372 commit e2fbcd9

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

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: 39 additions & 0 deletions
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.

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: 122 additions & 0 deletions
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.

tests/testsuite/cargo_add/mod.rs

Lines changed: 1 addition & 0 deletions
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;
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)