fn ui_tests() {
let t = trycmd::TestCases::new();
let rustup_init = trycmd::cargo::cargo_bin("rustup-init");
let rustup = trycmd::cargo::cargo_bin("rustup");
t.register_bin("rustup-init", &rustup_init);
// Copy rustup-init to rustup so that the tests can run it.
utils::copy_file(&rustup_init, &rustup).unwrap();
t.register_bin("rustup", &rustup);
t.case("tests/cli-ui/*.toml");
}
3. test the subcommand's help test
```toml
bin.name = "rustup"
args = ["set","auto-self-update","--help"]
stdout = """
rustup-set-auto-self-update
The rustup auto self update mode
USAGE:
rustup[EXE] set auto-self-update <auto-self-update-mode>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
ARGS:
<auto-self-update-mode> [default: enable] [possible values: enable, disable, check-only]
"""
stderr = ""
If I change the first line to rustup[EXE]-set-auto-self-update
Run the test with TRYCMD=overwrite, it will delete the [EXE]
If I don't put the EXE into the subcommand help text, then you will get an error:
[test]
fn ui_tests() { let t = trycmd::TestCases::new(); let rustup_init = trycmd::cargo::cargo_bin("rustup-init"); let rustup = trycmd::cargo::cargo_bin("rustup"); t.register_bin("rustup-init", &rustup_init); // Copy rustup-init to rustup so that the tests can run it. utils::copy_file(&rustup_init, &rustup).unwrap(); t.register_bin("rustup", &rustup); t.case("tests/cli-ui/*.toml"); }
rustup[EXE]-set-auto-self-update
TRYCMD=overwrite
, it will delete the[EXE]
EXE
into the subcommand help text, then you will get an error:Testing tests\cli-ui\rustup_set_cmd_auto-self-update_cmd_help_flag_stdout.toml ... failed Exit: success
---- expected: stdout ++++ actual: stdout 1 - rustup-set-auto-self-update 1 + rustup[EXE]-set-auto-self-update 2 2 | The rustup auto self update mode 3 3 | 4 4 | USAGE: 5 - rustup set auto-self-update
5 + rustup[EXE] set auto-self-update
6 6 |
7 7 | FLAGS:
8 8 | -h, --help Prints help information
9 9 | -V, --version Prints version information
10 10 |
11 11 | ARGS:
12 12 | [default: enable] [possible values: enable, disable, check-only]