coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

chmod: fix incorrect test

Open BenWiederhake opened this issue 6 months ago • 4 comments

First of all, let's observe that uutils and GNU coreutils behave identically in a special edgecase, and emit exactly the same warning message:

$ touch file
$ chmod =0777 file; ls -l file
-rwxrwxrwx 1 user user 0 Aug 12 00:02 file
$ chmod -w file # GNU says "r-xr-xrwx" in the error message
chmod: file: new permissions are r-xr-xrwx, not r-xr-xr-x
[$? = 1]
$ chmod =0777 file; ls -l file # (reset test setup)
-rwxrwxrwx 1 user user 0 Aug 12 00:02 file
$ cargo run -q --features chmod chmod -w file # uutils correctly says "r-xr-xrwx" in the error message, too
chmod: file: new permissions are r-xr-xrwx, not r-xr-xr-x
[$? = 1]

So uutils is already correct.

However, this test somehow fails:

$ cargo test -q --features chmod -- test_chmod_ugoa
<SNIP irrelevant output>
Diff < left / right > :
<chmod: file: new permissions are r-xr-xrwx, not r-xr-xr-x
>chmod: file: new permissions are r-xrwxrwx, not r-xr-xr-x
<SNIP irrelevant output>

In other words, the test code itself is wrong, because it asserts the wrong output. Also, for the record, even uutils changes the permissions to -r-xr-xrwx, which is correct.

This PR fixes the incorrect test.

Note that this does NOT fix #6637, which is a bug in the way that cargo test is invoked.

BenWiederhake avatar Aug 11 '24 22:08 BenWiederhake