Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not ust [EXE] in subcommand #197

Closed
hi-rustin opened this issue Feb 11, 2023 · 3 comments
Closed

Can not ust [EXE] in subcommand #197

hi-rustin opened this issue Feb 11, 2023 · 3 comments

Comments

@hi-rustin
Copy link

  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

@hi-rustin
Copy link
Author

Now, I just use ... as a workaround.

@hi-rustin
Copy link
Author

I see, this seems a bug of clap. clap-rs/clap#3693

@epage
Copy link
Contributor

epage commented Feb 11, 2023

Want to take on updating from clap 2 to clap 4?

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants