Skip to content

Commit eec1240

Browse files
committed
du: test existing correct behavior: warn about --inodes -b conflict
1 parent 8a5a2ee commit eec1240

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/by-util/test_du.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,3 +1264,35 @@ fn test_du_blocksize_zero_do_not_panic() {
12641264
));
12651265
}
12661266
}
1267+
1268+
#[test]
1269+
fn test_du_inodes_blocksize_ineffective() {
1270+
let ts = TestScenario::new(util_name!());
1271+
let at = &ts.fixtures;
1272+
let fpath = at.plus("test.txt");
1273+
std::fs::File::create(&fpath)
1274+
.expect("cannot create test file")
1275+
.set_len(123_456)
1276+
.expect("cannot truncate test len to size");
1277+
for method in ["-B3", "--block-size=3"] {
1278+
// No warning
1279+
ts.ucmd()
1280+
.arg(method)
1281+
.arg("--inodes")
1282+
.arg("test.txt")
1283+
.succeeds()
1284+
.stdout_only("1\ttest.txt\n");
1285+
}
1286+
for method in ["--apparent-size", "-b"] {
1287+
// A warning appears!
1288+
ts.ucmd()
1289+
.arg(method)
1290+
.arg("--inodes")
1291+
.arg("test.txt")
1292+
.succeeds()
1293+
.stdout_is("1\ttest.txt\n")
1294+
.stderr_is(
1295+
"du: warning: options --apparent-size and -b are ineffective with --inodes\n",
1296+
);
1297+
}
1298+
}

0 commit comments

Comments
 (0)