mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
Merge pull request #3418 from cakebaker/ticket_3409
df: show error if all types are excluded
This commit is contained in:
commit
e8574ca184
2 changed files with 25 additions and 1 deletions
|
@ -287,6 +287,7 @@ fn get_all_filesystems(opt: &Options) -> Vec<Filesystem> {
|
||||||
mounts
|
mounts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|m| Filesystem::new(m, None))
|
.filter_map(|m| Filesystem::new(m, None))
|
||||||
|
.filter(|fs| opt.show_all_fs || fs.usage.blocks > 0)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +363,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let filesystems = get_all_filesystems(&opt);
|
let filesystems = get_all_filesystems(&opt);
|
||||||
|
|
||||||
if filesystems.is_empty() {
|
if filesystems.is_empty() {
|
||||||
return Err(USimpleError::new(1, "No file systems processed"));
|
return Err(USimpleError::new(1, "no file systems processed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
filesystems
|
filesystems
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
// spell-checker:ignore udev pcent iuse itotal iused ipcent
|
// spell-checker:ignore udev pcent iuse itotal iused ipcent
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -205,6 +207,27 @@ fn test_exclude_type_option() {
|
||||||
new_ucmd!().args(&["-x", "ext4", "-x", "ext3"]).succeeds();
|
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]
|
#[test]
|
||||||
fn test_include_exclude_same_type() {
|
fn test_include_exclude_same_type() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue