diff options
| author | Tharun Rajendran <rajendrantharun@live.com> | 2022-02-11 10:05:45 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-10 22:35:45 -0600 |
| commit | b05b3138001c97cbabeb3e20a0960b9f75341ee0 (patch) | |
| tree | 44e0e4a57f3de720aadb062fbe61a3372930b869 | |
| parent | 813d127c824eb22e3fe1fc7a34bf12ad4c0fa2f6 (diff) | |
| download | rust-b05b3138001c97cbabeb3e20a0960b9f75341ee0.tar.gz rust-b05b3138001c97cbabeb3e20a0960b9f75341ee0.zip | |
chore(rustfmt): remove executable path from usage string (#5216)
* chore(rustfmt): remove executable path from usage string * add unit test for usage string * rename test and check usage text in a single assert
| -rw-r--r-- | src/bin/main.rs | 5 | ||||
| -rw-r--r-- | tests/rustfmt/main.rs | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs index 6f5b09fc86a..196de6056b5 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -394,9 +394,8 @@ fn print_usage_to_stdout(opts: &Options, reason: &str) { format!("{}\n\n", reason) }; let msg = format!( - "{}Format Rust code\n\nusage: {} [options] <file>...", - sep, - env::args_os().next().unwrap().to_string_lossy() + "{}Format Rust code\n\nusage: rustfmt [options] <file>...", + sep ); println!("{}", opts.usage(&msg)); } diff --git a/tests/rustfmt/main.rs b/tests/rustfmt/main.rs index 8effb1c6fca..6976cc4d346 100644 --- a/tests/rustfmt/main.rs +++ b/tests/rustfmt/main.rs @@ -106,3 +106,12 @@ fn inline_config() { && contains("format_strings = true") ); } + +#[test] +fn rustfmt_usage_text() { + let args = [ + "--help", + ]; + let (stdout, _) = rustfmt(&args); + assert!(stdout.contains(&format!("Format Rust code\n\nusage: rustfmt [options] <file>..."))); +} |
