Skip to content

Commit b05b313

Browse files
authored
chore(rustfmt): remove executable path from usage string (rust-lang#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
1 parent 813d127 commit b05b313

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/bin/main.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,8 @@ fn print_usage_to_stdout(opts: &Options, reason: &str) {
394394
format!("{}\n\n", reason)
395395
};
396396
let msg = format!(
397-
"{}Format Rust code\n\nusage: {} [options] <file>...",
398-
sep,
399-
env::args_os().next().unwrap().to_string_lossy()
397+
"{}Format Rust code\n\nusage: rustfmt [options] <file>...",
398+
sep
400399
);
401400
println!("{}", opts.usage(&msg));
402401
}

tests/rustfmt/main.rs

+9
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,12 @@ fn inline_config() {
106106
&& contains("format_strings = true")
107107
);
108108
}
109+
110+
#[test]
111+
fn rustfmt_usage_text() {
112+
let args = [
113+
"--help",
114+
];
115+
let (stdout, _) = rustfmt(&args);
116+
assert!(stdout.contains(&format!("Format Rust code\n\nusage: rustfmt [options] <file>...")));
117+
}

0 commit comments

Comments
 (0)