From d6e78d738d796e575148458209bb9eed01a9a766 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Wed, 16 Apr 2025 05:11:57 +0200 Subject: [PATCH] du: test existing correct behavior: warn about --inodes -b conflict --- tests/by-util/test_du.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/by-util/test_du.rs b/tests/by-util/test_du.rs index 668c1ed1b..4a7a1bc50 100644 --- a/tests/by-util/test_du.rs +++ b/tests/by-util/test_du.rs @@ -1264,3 +1264,32 @@ fn test_du_blocksize_zero_do_not_panic() { )); } } + +#[test] +fn test_du_inodes_blocksize_ineffective() { + let ts = TestScenario::new(util_name!()); + let at = &ts.fixtures; + let fpath = at.plus("test.txt"); + at.touch(fpath); + for method in ["-B3", "--block-size=3"] { + // No warning + ts.ucmd() + .arg(method) + .arg("--inodes") + .arg("test.txt") + .succeeds() + .stdout_only("1\ttest.txt\n"); + } + for method in ["--apparent-size", "-b"] { + // A warning appears! + ts.ucmd() + .arg(method) + .arg("--inodes") + .arg("test.txt") + .succeeds() + .stdout_is("1\ttest.txt\n") + .stderr_is( + "du: warning: options --apparent-size and -b are ineffective with --inodes\n", + ); + } +}