mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
df: -h -H shouldn't cause an error #3366
This commit is contained in:
parent
c2e214bd99
commit
85d113ab79
2 changed files with 24 additions and 2 deletions
|
@ -443,14 +443,14 @@ pub fn uu_app<'a>() -> Command<'a> {
|
|||
Arg::new(OPT_HUMAN_READABLE_BINARY)
|
||||
.short('h')
|
||||
.long("human-readable")
|
||||
.conflicts_with(OPT_HUMAN_READABLE_DECIMAL)
|
||||
.overrides_with(OPT_HUMAN_READABLE_DECIMAL)
|
||||
.help("print sizes in human readable format (e.g., 1K 234M 2G)"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(OPT_HUMAN_READABLE_DECIMAL)
|
||||
.short('H')
|
||||
.long("si")
|
||||
.conflicts_with(OPT_HUMAN_READABLE_BINARY)
|
||||
.overrides_with(OPT_HUMAN_READABLE_DECIMAL)
|
||||
.help("likewise, but use powers of 1000 not 1024"),
|
||||
)
|
||||
.arg(
|
||||
|
|
|
@ -26,6 +26,12 @@ fn test_df_compatible_si() {
|
|||
new_ucmd!().arg("-aH").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_df_overriding() {
|
||||
new_ucmd!().arg("-hH").succeeds();
|
||||
new_ucmd!().arg("-Hh").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_df_output() {
|
||||
let expected = if cfg!(target_os = "macos") {
|
||||
|
@ -42,6 +48,22 @@ fn test_df_output() {
|
|||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_df_output_overridden() {
|
||||
let expected = if cfg!(target_os = "macos") {
|
||||
"Filesystem Size Used Available Capacity Use% Mounted on "
|
||||
} else {
|
||||
"Filesystem Size Used Available Use% Mounted on "
|
||||
};
|
||||
let output = new_ucmd!()
|
||||
.arg("-hH")
|
||||
.arg("--total")
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let actual = output.lines().take(1).collect::<Vec<&str>>()[0];
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_total_option_with_single_dash() {
|
||||
// These should fail because `-total` should have two dashes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue