| 1 | package thintest |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/wire" |
| 8 | ) |
| 9 | |
| 10 | // TestTimedOutCandidateGoesToChecks (stopped-jobs audit, example 2): |
| 11 | // Engineering ran out of time with its change made; the runner pushed |
| 12 | // the work and reported the step done with the reason step_timeout. The |
| 13 | // instance keeps the reason (the work is unfinished), runs checks and |
| 14 | // then review on the candidate, tells Review the step ran out of time, |
| 15 | // and never retries the step on its own. |
| 16 | func TestTimedOutCandidateGoesToChecks(t *testing.T) { |
| 17 | r := newToolRigAt(t, wire.ProtocolCurrent) |
| 18 | base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) |
| 19 | id, d := r.started("o", "Swipe down to dismiss the keyboard") |
| 20 | r.step("o-run", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, Family: "claude", Account: "claude-a"}) |
| 21 | r.step("o-done", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepDone, Reason: "step_timeout", BaseSHA: base, CandidateSHA: cand, Pushed: true, Termination: true, Family: "claude", Account: "claude-a"}) |
| 22 | r.expect(wire.FrameWatchMerge) |
| 23 | c := r.dispatched(wire.SpecialistChecks, base, cand, 0) |
| 24 | k := r.task(id) |
| 25 | if s := k.Steps[0]; s.State != wire.StepDone || s.Reason != "step_timeout" || !s.Pushed || k.NeedsYou != "" { |
| 26 | t.Fatalf("timed-out candidate %+v needs %q", s, k.NeedsYou) |
| 27 | } |
| 28 | r.checks("o-c", c, wire.ChecksPassed, exit(0), "", "") |
| 29 | rv := r.dispatched(wire.SpecialistReview, base, cand, 0) |
| 30 | if !strings.Contains(rv.Brief, "ran out of time") { |
| 31 | t.Fatalf("Review not told the step ran out of time: %q", rv.Brief) |
| 32 | } |
| 33 | if len(r.triageActions("triage_retry")) != 0 { |
| 34 | t.Fatal("retried a step that kept its work") |
| 35 | } |
| 36 | if page := r.get(r.inst.Cookie(), "/tasks/"+id, 200); !strings.Contains(page, "It ran out of time.") { |
| 37 | t.Fatalf("task page does not say the step ran out of time: %s", page) |
| 38 | } |
| 39 | // A finished step's candidate is not marked. |
| 40 | id2, d2 := r.started("f", "Fix the typo") |
| 41 | r.step("f-run", wire.StepReport{TaskID: id2, StepID: d2.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, Family: "claude", Account: "claude-a"}) |
| 42 | cand2 := strings.Repeat("3", 40) |
| 43 | r.step("f-done", wire.StepReport{TaskID: id2, StepID: d2.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: base, CandidateSHA: cand2, Pushed: true, Termination: true, Family: "claude", Account: "claude-a"}) |
| 44 | r.expect(wire.FrameWatchMerge) |
| 45 | c2 := r.dispatched(wire.SpecialistChecks, base, cand2, 0) |
| 46 | r.checks("f-c", c2, wire.ChecksPassed, exit(0), "", "") |
| 47 | if rv := r.dispatched(wire.SpecialistReview, base, cand2, 0); strings.Contains(rv.Brief, "ran out of time") { |
| 48 | t.Fatalf("a finished step's Review told it ran out of time: %q", rv.Brief) |
| 49 | } |
| 50 | } |
| 51 | |