test: fix shfmt error message assertions - #1393
Merged
Merged
Conversation
shfmt 3.13.0 started quoting tokens in error messages consistently
(mvdan/sh 16cc925dc), so the messages the formatter tests match on
changed:
parse-problems.sh:10:1: > must be followed by a word
parse-problems.sh:10:1: `>` must be followed by a word
shfmt.sh:25:14: the "function" builtin is a bash feature
shfmt.sh:25:14: the `function` builtin is a bash feature
Accept either form. CI does not see this yet, as the shfmt in the
Ubuntu archive is older than 3.13.
These failures were also being reported against the wrong test: the
three `expect(...).rejects.toThrow(...)` assertions were never awaited,
so the test finished green and the rejection surfaced during whichever
test happened to run next. Await them.
Contributor
Author
|
Opened #1394 which is this PR plus the CI addition to also test against the latest shfmt. |
skovhus
self-requested a review
August 19, 2026 07:48
skovhus
approved these changes
Aug 19, 2026
skovhus
enabled auto-merge
August 19, 2026 07:48
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1393 +/- ##
=======================================
Coverage 80.56% 80.56%
=======================================
Files 29 29
Lines 1513 1513
Branches 374 374
=======================================
Hits 1219 1219
Misses 235 235
Partials 59 59 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The formatter tests fail against shfmt >= 3.13 (I hit this on Fedora with shfmt 3.13.1, on current
main, unrelated to any local change).Changed error messages
mvdan/sh 16cc925dc ("syntax: consistently quote tokens in error messages") landed in shfmt 3.13.0, so two messages the tests match on now look different:
The assertions now accept either quoting style, alongside the pre-existing alternative for much older shfmt versions.
CI does not see this because
verify.ymlinstalls shfmt viaapt-get, and the version in the Ubuntu archive predates 3.13.Missing
awaitWhile tracking this down: the three
expect(...).rejects.toThrow(...)assertions in this file were never awaited or returned. The test therefore finished green and the rejection surfaced during whichever test ran next — so jest blamedshould format when shfmt is presentfor a message belonging toshould throw when parsing using the wrong language dialect, which made this a good deal more confusing than it needed to be.Verified the assertions actually bite now: deliberately corrupting the expected strings fails the tests that own them, rather than their neighbours.