mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +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)
|
Arg::new(OPT_HUMAN_READABLE_BINARY)
|
||||||
.short('h')
|
.short('h')
|
||||||
.long("human-readable")
|
.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)"),
|
.help("print sizes in human readable format (e.g., 1K 234M 2G)"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_HUMAN_READABLE_DECIMAL)
|
Arg::new(OPT_HUMAN_READABLE_DECIMAL)
|
||||||
.short('H')
|
.short('H')
|
||||||
.long("si")
|
.long("si")
|
||||||
.conflicts_with(OPT_HUMAN_READABLE_BINARY)
|
.overrides_with(OPT_HUMAN_READABLE_DECIMAL)
|
||||||
.help("likewise, but use powers of 1000 not 1024"),
|
.help("likewise, but use powers of 1000 not 1024"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -26,6 +26,12 @@ fn test_df_compatible_si() {
|
||||||
new_ucmd!().arg("-aH").succeeds();
|
new_ucmd!().arg("-aH").succeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_df_overriding() {
|
||||||
|
new_ucmd!().arg("-hH").succeeds();
|
||||||
|
new_ucmd!().arg("-Hh").succeeds();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_df_output() {
|
fn test_df_output() {
|
||||||
let expected = if cfg!(target_os = "macos") {
|
let expected = if cfg!(target_os = "macos") {
|
||||||
|
@ -42,6 +48,22 @@ fn test_df_output() {
|
||||||
assert_eq!(actual, expected);
|
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]
|
#[test]
|
||||||
fn test_total_option_with_single_dash() {
|
fn test_total_option_with_single_dash() {
|
||||||
// These should fail because `-total` should have two dashes,
|
// These should fail because `-total` should have two dashes,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue