Skip to content

Commit 6eb3569

Browse files
peyton-altclaude
andcommitted
test(agent): make the ctx-cancel matrix case deterministic
CI's test-core failed on TestGenerateText_Matrix/geminicli/CanceledCarriesSentinelAndEvidence with Stderr = "" and StdoutBytes = 0. That is the signature of the child never having run: the test cancelled on a fixed `time.Sleep(50ms)`, which races subprocess startup, so on a loaded runner the kill landed before sh executed either printf. My test, my flake — a fixed delay is exactly the wrong tool for synchronising with a subprocess. The child now touches a sentinel file after writing both streams, and the parent waits for that file before cancelling, so the cancel is ordered after the writes by construction rather than by hope. The sentinel is per-subtest because these run in parallel across five providers; a shared path would let one provider's child release another's cancel. A 10s ceiling still cancels regardless, so a genuinely stuck child fails loudly instead of hanging. Checked that the fix did not simply defang the assertion: mutating HandleTextGenResult's ctx branch back to a bare sentinel still fails this case with "evidence lost". Stressed at -count=50 -cpu=1,2,4 (150 executions), clean. Also split the table-driver into per-scenario functions. It had grown past maintidx (complexity 25, MI 18) once the composition assertions and the two stdout cases landed. Extracting is the right fix rather than a nolint, and t.Parallel now lives at the single t.Run site so tparallel can see it. All 35 subtests (5 providers x 7 scenarios) preserved — verified by count, not by assumption. Verified: 8573 unit tests, lint 0 issues on a cleaned cache. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 7133988 commit 6eb3569

1 file changed

Lines changed: 200 additions & 173 deletions

File tree

0 commit comments

Comments
 (0)