Merge pull request #3418 from cakebaker/ticket_3409

df: show error if all types are excluded
This commit is contained in:
Terts Diepraam 2022-04-20 23:51:36 +02:00 committed by GitHub
commit e8574ca184
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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]
@ -205,6 +207,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!()