mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 03:36:18 +00:00
Merge pull request #3376 from jfinkels/df-error-on-nonexistent-files
df: show error when file argument does not exist
This commit is contained in:
commit
f114d63b4e
2 changed files with 43 additions and 15 deletions
|
@ -28,16 +28,18 @@ fn test_df_compatible_si() {
|
|||
|
||||
#[test]
|
||||
fn test_df_output() {
|
||||
// TODO These should fail because `-total` should have two dashes,
|
||||
// not just one. But they don't fail.
|
||||
if cfg!(target_os = "macos") {
|
||||
new_ucmd!().arg("-H").arg("-total").succeeds().
|
||||
stdout_only("Filesystem Size Used Available Capacity Use% Mounted on \n");
|
||||
let expected = if cfg!(target_os = "macos") {
|
||||
"Filesystem Size Used Available Capacity Use% Mounted on "
|
||||
} else {
|
||||
new_ucmd!().arg("-H").arg("-total").succeeds().stdout_only(
|
||||
"Filesystem Size Used Available Use% Mounted on \n",
|
||||
);
|
||||
}
|
||||
"Filesystem Size Used Available Use% Mounted on "
|
||||
};
|
||||
let output = new_ucmd!()
|
||||
.arg("-H")
|
||||
.arg("--total")
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let actual = output.lines().take(1).collect::<Vec<&str>>()[0];
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
/// Test that the order of rows in the table does not change across executions.
|
||||
|
@ -295,3 +297,16 @@ fn test_output_field_no_more_than_once() {
|
|||
.fails()
|
||||
.usage_error("option --output: field 'target' used more than once");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nonexistent_file() {
|
||||
new_ucmd!()
|
||||
.arg("does-not-exist")
|
||||
.fails()
|
||||
.stderr_only("df: does-not-exist: No such file or directory");
|
||||
new_ucmd!()
|
||||
.args(&["--output=file", "does-not-exist", "."])
|
||||
.fails()
|
||||
.stderr_is("df: does-not-exist: No such file or directory\n")
|
||||
.stdout_is("File \n. \n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue