Skip to content

[Hackathon] fix(rerun): batch --wait exits 0 when refused conflicts leave the rerun incomplete #380

Closed as not planned

Description

@Herbicide7665

Verified against (commit SHA or released version)

commit 988c035 (v0.14.0)

Discord Username / User ID

weili_yang33

What does this improvement do?

Summary

A mixed batch rerun under --wait — some tests dispatch and are polled, others come back in conflicts[] — decides its exit code from the dispatched subset alone. When every dispatched rerun passes, the command exits 0 even though the refused tests never ran. A CI gate therefore goes green on an incomplete rerun.

test run --all already closes this exact hole with a hard-conflict gate. test rerun and testlist run are missing that sibling gate.

What happened

runTestRerunCore's --wait tail (src/commands/test.ts, the gates after emitCiArtifacts) checks, in order: auth escalation, deferred/timeout, then resolveWaitFailure. After those gates it returns normally. conflicts only reaches the JSON payload and its summary.conflicts count — no gate reads it:

  • test.ts:13502-13553 — the rerun --wait tail: three gates, no conflict gate, then return.
  • testlist.ts:1037-1045 — the testlist run --wait tail: assertNoDeferred → resolveWaitFailure → assertNoNotFound → return. Same gap.

Compare test run --all (test.ts:10745-10766), which throws CONFLICT (exit 6) in this shape. Its comment states the invariant directly: "without this gate a passing resumable run would mask an unresolved hard conflict and exit 0".

Two existing unit tests encode the exit-0 behavior today (test.rerun.spec.ts: "partial conflict: accepted proceed, conflicts reported" and "partial conflict (some accepted + some conflicts) still exits 0 on all-passed"), so the gap is baked into the suite, not just the code.

Reproduction

  1. Project has tests A and B. Start a run of B from another terminal (or a teammate/CI triggers it), so B has a run in flight.
  2. Run:
$ testsprite test rerun <A-id> <B-id> --wait --output json; echo "exit=$?"
Batch rerun complete: 1/1 passed, 0 failed/blocked, 0 timed out
{ "accepted": [ ...A passed... ], "conflicts": [ { "testId": "<B-id>", "currentRunId": "run_..." } ], "summary": { "passed": 1, "conflicts": 1, "total": 1 } }
exit=0
  1. B was never rerun, but the command reports success. In CI, the step passes and the pipeline continues on an incomplete rerun.

The identical batch shape through test run --all exits 6 with CONFLICT.

Expected

A --wait batch with unresolved conflicts — tests the operator asked to rerun but that were refused — must not exit 0. Mirror test run --all's hard-conflict gate: throw CONFLICT (exit 6) after the auth / deferred / poll-failure gates, so a real failure still wins the headline (run --all orders it the same way).

Scope note

The non---wait paths are out of scope here: without --wait the command is fire-and-forget and test run --all also exits 0 with conflicts reported in the payload. The all-conflict no-op cases (zero dispatched) already exit 6 in both commands; only the mixed --wait tail is broken.

Related

Details / implementation notes

Branch ready: fix/batch-wait-conflict-exit-code (commit c79cda4). The change adds the conflict gate to the rerun --wait tail and a assertNoHardConflicts helper to testlist run, mirrors runTestRunAll's gate ordering, and updates the two specs that encoded the old exit-0 behavior plus three new cases (pass+conflict → 6, fail+conflict → 1, non-in-flight conflict reasons rendering reason-aware wording). Full gate green: npm run typecheck, npm run lint (0 errors, baseline warnings unchanged), npm test (115 files, 4580 passed, 11 skipped). PR to follow once this issue is assigned.

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. added
    needs-triage
    hackathon
    on Oct 12, 2026
  2. zeshi-du commented on Oct 20, 2026

    @zeshi-du
    Contributor

    Thanks @Herbicide7665, confirmed: in a mixed batch under --wait, test rerun and testlist run take the exit code from dispatched runs only, while test run --all exits 6.

    test rerun is being folded into test run, deprecated in an upcoming release and removed in 1.0, so we're not taking changes to rerun-only code paths. testlist run will follow test run --all as part of the 1.0 exit-code changes, since changing it in 0.x would break existing CI scripts. Tracked internally as DEV-2180.

    Closing as not planned.

  3. removed
    needs-triage
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hackathon

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions