1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

df: respect -t arg when specific file is provided

Fixes #3325
This commit is contained in:
Daniel Hofstetter 2022-04-15 08:05:24 +02:00
parent 4ea443bf42
commit 2d4552cce4
2 changed files with 58 additions and 15 deletions

View file

@ -199,7 +199,42 @@ fn test_type_option() {
new_ucmd!()
.args(&["-t", fs_type, "-t", "nonexisting"])
.succeeds();
new_ucmd!().args(&["-t", "nonexisting"]).fails();
new_ucmd!()
.args(&["-t", "nonexisting"])
.fails()
.stderr_contains("no file systems processed");
}
#[test]
fn test_type_option_with_file() {
let fs_type = new_ucmd!()
.args(&["--output=fstype", "."])
.succeeds()
.stdout_move_str();
let fs_type = fs_type.lines().nth(1).unwrap().trim();
new_ucmd!().args(&["-t", fs_type, "."]).succeeds();
new_ucmd!()
.args(&["-t", "nonexisting", "."])
.fails()
.stderr_contains("no file systems processed");
let fs_types = new_ucmd!()
.arg("--output=fstype")
.succeeds()
.stdout_move_str();
let fs_types: Vec<_> = fs_types
.lines()
.skip(1)
.filter(|t| t.trim() != fs_type && t.trim() != "")
.collect();
if !fs_types.is_empty() {
new_ucmd!()
.args(&["-t", fs_types[0], "."])
.fails()
.stderr_contains("no file systems processed");
}
}
#[test]