From 3d6e8b1153ded4b209bc7cd14aaeaeb7454edb1b Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 25 Jun 2026 19:57:26 +0200 Subject: [PATCH] test(cli): de-flake `script run` tests with retry + failure diagnostics (#9801) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `script run command > runs a script and returns result` test runs a trivial, deterministic bun script and asserts exit code 0. On CI it intermittently fails when the standalone worker (notably on Windows) transiently fails to execute the job — identical bun jobs complete successfully elsewhere in the same backend session, so the failure is environmental, not a regression. Two problems made this both flaky and undiagnosable: - `--silent` plus asserting only on `result.code` meant the job's actual error never reached the CI log, so a flake left no trace. - No test-level retry, so a single transient worker hiccup failed the run. Add `retry: 2` to the two worker-executing tests in the block, and include stdout/stderr in the assertion label so the next occurrence is debuggable. Co-authored-by: Claude Opus 4.8 (1M context) --- cli/test/standalone_commands.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/test/standalone_commands.test.ts b/cli/test/standalone_commands.test.ts index bb1e13cde8..271b13867b 100644 --- a/cli/test/standalone_commands.test.ts +++ b/cli/test/standalone_commands.test.ts @@ -286,7 +286,10 @@ describe("script show command", () => { // ============================================================================= describe("script run command", () => { - test("runs a script and returns result", { timeout: 60000 }, async () => { + // retry absorbs transient worker-side job failures on CI (notably the + // Windows standalone worker); the script is deterministic, so a failure is + // environmental rather than a real regression. + test("runs a script and returns result", { timeout: 60000, retry: 2 }, async () => { await withTestBackend(async (backend, tempDir) => { await setupWorkspaceProfile(backend); @@ -301,12 +304,13 @@ describe("script run command", () => { tempDir ); - expect(result.code).toEqual(0); - expect(result.stdout).toContain(`run_result_${uniqueId}`); + const diag = `code: ${result.code}\nstdout: ${result.stdout}\nstderr: ${result.stderr}`; + expect(result.code, diag).toEqual(0); + expect(result.stdout, diag).toContain(`run_result_${uniqueId}`); }); }); - test("exits with code 1 when script fails", { timeout: 60000 }, async () => { + test("exits with code 1 when script fails", { timeout: 60000, retry: 2 }, async () => { await withTestBackend(async (backend, tempDir) => { await setupWorkspaceProfile(backend);