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

du: Return non zero error code when dealing with permissions errors

Nd make the tests/du/no-x.sh & long-sloop.sh pass
This commit is contained in:
Sylvestre Ledru 2022-04-09 23:46:01 +02:00
parent 398ded6789
commit a2cefd9b52
2 changed files with 23 additions and 3 deletions

View file

@ -429,7 +429,7 @@ fn test_du_no_permission() {
ts.ccmd("chmod").arg("-r").arg(SUB_DIR_LINKS).succeeds();
let result = ts.ucmd().arg(SUB_DIR_LINKS).run(); // TODO: replace with ".fails()" once `du` is fixed
let result = ts.ucmd().arg(SUB_DIR_LINKS).fails();
result.stderr_contains(
"du: cannot read directory 'subdir/links': Permission denied (os error 13)",
);
@ -449,6 +449,21 @@ fn test_du_no_permission() {
_du_no_permission(result.stdout_str());
}
#[cfg(not(target_os = "windows"))]
#[cfg(feature = "chmod")]
#[test]
fn test_du_no_exec_permission() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.mkdir_all("d/no-x/y");
ts.ccmd("chmod").arg("u=rw").arg("d/no-x").succeeds();
let result = ts.ucmd().arg("d/no-x").fails();
result.stderr_contains("du: cannot access 'd/no-x/y': Permission denied");
}
#[cfg(target_vendor = "apple")]
fn _du_no_permission(s: &str) {
assert_eq!(s, "0\tsubdir/links\n");