docs: Encourage CLI testing

This commit is contained in:
Ed Page 2021-12-06 14:58:56 -06:00
parent f18f3559e2
commit 7dfd1f2e6b

View file

@ -38,14 +38,15 @@ you can set `App::help_heading`.
**From clap v2**
1. Update your dependency
1. Add CLI tests, `-h` and `--help` output at a minimum (recommendation: [trycmd](https://docs.rs/trycmd/) for snapshot testing)
2. Update your dependency
1. *If you use `no-default-features`:* add the `std` feature
2. Resolve compiler errors
3. Resolve behavior changes
3. Resolve compiler errors
4. Resolve behavior changes
1. Refactor your `App` creation to a function and add a test similar to the one below, resolving any of its assertions
2. Look over the "subtle changes" under BREAKING CHANGES
3. *If using builder:* test your application under various circumstances to see if `ArgMatches` asserts regarding `AllowInvalidUtf8`.
4. *At your leisure:* resolve deprecation notices
5. *At your leisure:* resolve deprecation notices
Example test:
```rust
@ -61,14 +62,15 @@ fn verify_app() {
**From structopt 0.3.25**
1. Update your dependency, adding the `derive` feature flag
1. Add CLI tests, `-h` and `--help` output at a minimum (recommendation: [trycmd](https://docs.rs/trycmd/) for snapshot testing)
2. Update your dependency, adding the `derive` feature flag
1. *If you use `no-default-features`:* add the `std` feature
2. Resolve compiler errors, including
3. Resolve compiler errors, including
1. Update your `use` statements from `structopt` and `structopt::clap` to `clap`
3. Resolve behavior changes
4. Resolve behavior changes
1. Add a test similar to the one below, resolving any of its assertions
2. Look over the "subtle changes" under BREAKING CHANGES
4. *At your leisure:* resolve deprecation notices
5. *At your leisure:* resolve deprecation notices
Example test:
```rust
@ -86,19 +88,20 @@ fn verify_app() {
**From clap v3.0.0-beta.5**
1. Update your dependency
1. Add CLI tests, `-h` and `--help` output at a minimum (recommendation: [trycmd](https://docs.rs/trycmd/) for snapshot testing)
2. Update your dependency
1. Add in `derive`, `env`, `cargo`, or `unicode` feature flags as needed
2. Resolve compiler errors
3. Resolve compiler errors
2. *If you use `yaml`, `clap_app!`, or usage parser:* revert any changes you made for clap3
2. Change `Arg::about` `Arg::long_about` back to `help` and `long_help` and change `PossibleValue::about` to `help` ([clap-rs/clap#2937](https://github.com/clap-rs/clap/discussions/2937))
3. Change `AppSettings::HelpRequired` to `AppSettings::HelpExpected`
4. Change `PossibleValue::hidden` to `PossibleValue::hide`
5. Change `App::subcommand_placeholder` to `App::subcommand_value_name` / `App::subcommand_help_heading`
3. Resolve behavior changes
4. Resolve behavior changes
2. Add the above listed test appropriate for your application and resolve any problems it reports
1. *If using `derive`:* see the structopt breaking changes section for `Vec` changes
3. *If using builder:* test your application under various circumstances to see if `ArgMatches` asserts regarding `AllowInvalidUtf8`.
4. *At your leisure:* resolve deprecation notices
5. *At your leisure:* resolve deprecation notices
### BREAKING CHANGES