Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chmod: fix GNU test 'chmod/usage' #4442

Merged
merged 2 commits into from
Mar 17, 2023
Merged

Conversation

bbara
Copy link
Contributor

@bbara bbara commented Feb 26, 2023

fixes chmod/usage.

The description of the test says:

These test cases assume GNU behavior for "options" like -w.

The tests are (basically) combinations (and re-occurrences) of options, like (f considered as valid file):
chmod -- -w -- f, chmod -- -- -- f, chmod -w -w -- f

I then tried (testwise):

$ chmod -gw -w f -w
chmod: invalid mode: ‘-gw,-w,-w’

which seems to me like the options (like -w) are splitted from the files.
So my idea was to split the options from the files, keep order, and then "uniq" them before giving them to clap.

However, target is to find the not-working test cases, port them to the Rust unit tests, fix them, check for regression :)

@tertsdiepraam
Copy link
Member

Nice! Could you be a bit more descriptive in the PR title and description? I.e. describe the actual change you're making or the bug you're fixing?

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/misc/timeout. tests/misc/timeout is passing on 'main'. Maybe you have to rebase?

@bbara bbara force-pushed the chmod-usage branch 2 times, most recently from 1816490 to 0ae26a7 Compare February 28, 2023 19:21
@bbara
Copy link
Contributor Author

bbara commented Feb 28, 2023

Beside the not allowed re-occurence of options, I found another problem:
Symbolic Modes allow only one letter of 'ugo' after the sign (-+=) [1]. This wasn't considered so far. I guess this might fix GNU's usage test, but let's see.

[1] https://www.gnu.org/software/coreutils/manual/html_node/Symbolic-Modes.html

@bbara bbara changed the title chmod: improve GNU compatibility chmod: fix GNU test 'chmod/usage' Feb 28, 2023
@bbara bbara marked this pull request as ready for review March 4, 2023 00:34
@github-actions
Copy link

github-actions bot commented Mar 4, 2023

GNU testsuite comparison:

Congrats! The gnu test tests/chmod/usage is no longer failing!
Congrats! The gnu test tests/tail-2/inotify-dir-recreate is no longer failing!
GNU test failed: tests/misc/timeout. tests/misc/timeout is passing on 'main'. Maybe you have to rebase?

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This utility seems to be a bit of a mess 😅 (which is by no means your fault), I'm glad you picked this to improve!

There's maybe an alternative approach here that's worth exploring where files can take hyphen values? Though I'm not sure we can get that to be just as compatible.

tests/by-util/test_chmod.rs Outdated Show resolved Hide resolved
src/uucore/src/lib/features/mode.rs Outdated Show resolved Hide resolved
src/uucore/src/lib/features/mode.rs Outdated Show resolved Hide resolved
src/uucore/src/lib/features/mode.rs Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Mar 6, 2023

GNU testsuite comparison:

Congrats! The gnu test tests/chmod/usage is no longer failing!

src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's mostly good now! Just needs a bit more comments to explain why all this is necessary.

src/uu/chmod/src/chmod.rs Outdated Show resolved Hide resolved
@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/chmod/usage is no longer failing!

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! Great work!

@tertsdiepraam tertsdiepraam merged commit 2a4b48f into uutils:main Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants