test(cli): de-flake script run tests with retry + failure diagnostics (#9801)

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) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-06-25 19:57:26 +02:00
committed by GitHub
co-authored by Claude Opus 4.8
parent ba768fee88
commit 3d6e8b1153
+8 -4
View File
@@ -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);