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
This commit is contained in:
Tharun Rajendran 2022-02-11 10:05:45 +05:30 committed by GitHub
parent 813d127c82
commit b05b313800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -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));
}

View File

@ -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>...")));
}