From d14b5d2b6702b716b751271c530e6e495364d28a Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 19 Aug 2026 00:31:53 -0700 Subject: [PATCH] test: fix shfmt error message assertions 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. --- server/src/shfmt/__tests__/index.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/shfmt/__tests__/index.test.ts b/server/src/shfmt/__tests__/index.test.ts index 6cbb56d22..5c093062e 100644 --- a/server/src/shfmt/__tests__/index.test.ts +++ b/server/src/shfmt/__tests__/index.test.ts @@ -55,21 +55,21 @@ describe('formatter', () => { }) it('should throw when formatting fails', async () => { - expect(async () => { + await expect(async () => { await getFormattingResult({ document: FIXTURE_DOCUMENT.PARSE_PROBLEMS }) }).rejects.toThrow( - /Shfmt: exited with status 1: .*\/testing\/fixtures\/parse-problems.sh:10:1: > must be followed by a word/, + /Shfmt: exited with status 1: .*\/testing\/fixtures\/parse-problems.sh:10:1: [`"']?>[`"']? must be followed by a word/, ) }) it('should throw when parsing using the wrong language dialect', async () => { - expect(async () => { + await expect(async () => { await getFormattingResult({ document: FIXTURE_DOCUMENT.SHFMT, shfmtConfig: { languageDialect: 'posix' }, }) }).rejects.toThrow( - /Shfmt: exited with status 1: .*\/testing\/fixtures\/shfmt\.sh:25:14: (the "function" builtin|a command can only contain words and redirects; encountered \()/, + /Shfmt: exited with status 1: .*\/testing\/fixtures\/shfmt\.sh:25:14: (the [`"']?function[`"']? builtin|a command can only contain words and redirects; encountered \()/, ) }) @@ -607,10 +607,10 @@ describe('formatter', () => { FIXTURE_DOCUMENT.PARSE_PROBLEMS.getText(), ) - expect(async () => { + await expect(async () => { await getFormattingResult({ document: testDocument }) }).rejects.toThrow( - /Shfmt: exited with status 1: :10:1: > must be followed by a word/, + /Shfmt: exited with status 1: :10:1: [`"']?>[`"']? must be followed by a word/, ) })