Skip to content

Can not ust [EXE] in subcommand #197

@0xPoe

Description

@0xPoe
  1. use trycmd in rustup project
  2. create a test
use rustup::utils::utils;

#[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");
}
  1. test the subcommand's help test
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 = ""
  1. If I change the first line to rustup[EXE]-set-auto-self-update
  2. Run the test with TRYCMD=overwrite , it will delete the [EXE]
  3. If I don't put the 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 <auto-self-update-mode>
        5 +     rustup[EXE] set auto-self-update <auto-self-update-mode>
   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 |     <auto-self-update-mode>     [default: enable]  [possible values: enable, disable, check-only]

See: https://github.com/rust-lang/rustup/actions/runs/4150479617/jobs/7180163449

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions