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

df: show error if all types are excluded

Fixes #3409
This commit is contained in:
Daniel Hofstetter 2022-04-15 15:26:17 +02:00
parent 346902e30b
commit cc4b28780b
2 changed files with 25 additions and 1 deletions

View file

@ -287,6 +287,7 @@ fn get_all_filesystems(opt: &Options) -> Vec<Filesystem> {
mounts
.into_iter()
.filter_map(|m| Filesystem::new(m, None))
.filter(|fs| opt.show_all_fs || fs.usage.blocks > 0)
.collect()
}
@ -362,7 +363,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let filesystems = get_all_filesystems(&opt);
if filesystems.is_empty() {
return Err(USimpleError::new(1, "No file systems processed"));
return Err(USimpleError::new(1, "no file systems processed"));
}
filesystems

View file

@ -1,4 +1,6 @@
// spell-checker:ignore udev pcent iuse itotal iused ipcent
use std::collections::HashSet;
use crate::common::util::*;
#[test]
@ -204,6 +206,27 @@ fn test_exclude_type_option() {
new_ucmd!().args(&["-x", "ext4", "-x", "ext3"]).succeeds();
}
#[test]
fn test_exclude_all_types() {
let fs_types = new_ucmd!()
.arg("--output=fstype")
.succeeds()
.stdout_move_str();
let fs_types: HashSet<_> = fs_types.lines().skip(1).collect();
let mut args = Vec::new();
for fs_type in fs_types {
args.push("-x");
args.push(fs_type.trim_end());
}
new_ucmd!()
.args(&args)
.fails()
.stderr_contains("no file systems processed");
}
#[test]
fn test_include_exclude_same_type() {
new_ucmd!()