1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

df: implement the File column

Implement the "File" column in the `df` output table. Before this
commit, a blank entry appeared in the "File" column for each
row. After this commit, a "-" entry appears when `df` is run with no
positional arguments and the filename appears when run with positional
arguments. For example:

    $ touch a b c && df --output=target,file a b c
    Mounted on File
    /          a
    /          b
    /          c
This commit is contained in:
Jeffrey Finkelstein 2022-03-21 22:03:10 -04:00 committed by jfinkels
parent e1f8893289
commit ab717ce370
4 changed files with 76 additions and 7 deletions

View file

@ -222,4 +222,45 @@ fn test_output_selects_columns() {
);
}
// ToDO: more tests...
// TODO Fix the spacing.
#[test]
fn test_output_file_all_filesystems() {
// When run with no positional arguments, `df` lets "-" represent
// the "File" entry for each row.
let output = new_ucmd!()
.arg("--output=file")
.succeeds()
.stdout_move_str();
let mut lines = output.lines();
assert_eq!(lines.next().unwrap(), "File ");
for line in lines {
assert_eq!(line, "- ");
}
}
// TODO Fix the spacing.
#[test]
fn test_output_file_specific_files() {
// Create three files.
let (at, mut ucmd) = at_and_ucmd!();
at.touch("a");
at.touch("b");
at.touch("c");
// When run with positional arguments, the filesystems should
// appear in the "File" column.
let output = ucmd
.args(&["--output=file", "a", "b", "c"])
.succeeds()
.stdout_move_str();
let actual: Vec<&str> = output.lines().collect();
assert_eq!(
actual,
vec![
"File ",
"a ",
"b ",
"c "
]
);
}