Skip to content

tests: validate "patch" and "ed" commands once, print meaningful messages#226

Open
marc-hb wants to merge 1 commit intouutils:mainfrom
marc-hb:testcmds
Open

tests: validate "patch" and "ed" commands once, print meaningful messages#226
marc-hb wants to merge 1 commit intouutils:mainfrom
marc-hb:testcmds

Conversation

@marc-hb
Copy link
Copy Markdown

@marc-hb marc-hb commented May 6, 2026

macOS' /usr/bin/patch and GNU patch have very subtle incompatibilities that cause only some "more advanced" tests to fail in obscure and very time-consuming ways - while other tests pass. In some cases (depending on test threads racing), the lack of newlines in some test data even causes the whole test suite to stall.

This fix runs patch -version (only once), makes sure the output starts with "GNU patch" and shows a meaningful assert message when not. It also looks for gpatch instead of patch on macOS and shows a meaningful assert message if either is missing.

Fixes: #225

This also provides faster and better feedback when ed is missing (see #39) and implements a portable and basic check.

Last but not least, this new code is generic enough to support the validation of any other test dependency in the future.

…ages

macOS' /usr/bin/patch and GNU patch have very subtle incompatibilities
that cause only some "more advanced" tests to fail in obscure and very
time-consuming ways - while other tests pass. In some cases (depending
on test threads racing), the lack of newlines in some test data even
causes the whole test suite to stall.

This fix runs `patch -version` (only once), makes sure the output starts
with "GNU patch" and shows a meaningful assert message when not. It also
looks for `gpatch` instead of `patch` on macOS and shows a meaningful
assert message if either is missing.

Fixes: #TODO

This also provides faster and better feedback when `ed` is missing (see
uutils#39) and implements a portable and basic check.

Last but not least, this new code is generic enough to support the
validation of any other test dependency in the future.
@marc-hb marc-hb marked this pull request as ready for review May 6, 2026 21:47
@marc-hb
Copy link
Copy Markdown
Author

marc-hb commented May 6, 2026

This seems unrelated:

https://results.pre-commit.ci/run/github/341787720/1778103980.1j7-ePVIRuecaKMwwUj_Qg

.pre-commit-config.yaml is not a file

@marc-hb
Copy link
Copy Markdown
Author

marc-hb commented May 6, 2026

With this fix, the /opt/homebrew/opt/gpatch/libexec/gnubin PATH change that can be seen in 44c195c is not needed anymore and can be dropped. Installing gpatch is still required of course.

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.

macOS /usr/bin/patch cause obscure failures and stalls

1 participant