package thintest import ( "fmt" "strings" "testing" "amadan.net/oficina/equipo/internal/wire" ) // TestFixRoundGetsEveryShard (stopped-jobs audit, fix 4): hosted CI // failed in three shards. The fix round's feedback names every shard and // keeps each one's failing test and message, within its budget; before, // it kept the last 60 lines of the output, which only the last shard // reached ("Shard 16 also failed but its output wasn't included"). func TestFixRoundGetsEveryShard(t *testing.T) { r := newToolRigAt(t, wire.ProtocolCurrent) base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) id, _ := r.pushed("s", "Swipe down to dismiss the keyboard", base, cand) task := r.task(id) r.expect(wire.FrameWatchMerge) c := r.dispatched(wire.SpecialistChecks, base, cand, 0) names := []string{"check shard 5 of 23", "check shard 10 of 23", "check shard 16 of 23"} var units []wire.CIUnit for n, name := range names { var b strings.Builder fmt.Fprintf(&b, "--- FAIL: TestShard%d (0.01s)\n shard_test.go:%d: shard %d broke\n", n, n, n) for b.Len() < 12<<10 { fmt.Fprintf(&b, "ok \tamadan.net/pkg%d\t0.1s\n", b.Len()) } units = append(units, wire.CIUnit{Name: name, Log: b.String() + "FAIL\n"}) } rep := hostedReport(c, task.Branch, wire.HostedFailure, names...) head := "Hosted CI on oficina/sample: failed.\nFailed: " + strings.Join(names, "; ") + "\n" rep.Output = head + wire.JoinCIUnits(units, wire.MaxChecksOutput-len(head)) r.step("s-c", rep) fix := r.dispatched(wire.SpecialistEngineering, cand, "", 1) for n, name := range names { for _, want := range []string{wire.CIUnitHeader(name) + "\n", fmt.Sprintf("--- FAIL: TestShard%d (0.01s)\n shard_test.go:%d: shard %d broke\n", n, n, n)} { if !strings.Contains(fix.Feedback, want) { t.Errorf("feedback lacks %q", want) } } } if len(fix.Feedback) > wire.MaxTaskBrief+4000 { t.Fatalf("feedback %d bytes", len(fix.Feedback)) } } // The local gate failed with hosted CI's failing units beside it (the // runner's combined diagnostic): the fix round's feedback still keeps // every unit's failing test. func TestFixRoundGetsEveryShardBesideTheLocalGate(t *testing.T) { r := newToolRigAt(t, wire.ProtocolCurrent) base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) id, _ := r.pushed("g", "Swipe down to dismiss the keyboard", base, cand) _ = id r.expect(wire.FrameWatchMerge) c := r.dispatched(wire.SpecialistChecks, base, cand, 0) var units []wire.CIUnit for n := range 3 { var b strings.Builder fmt.Fprintf(&b, "--- FAIL: TestShard%d (0.01s)\n shard_test.go:%d: shard %d broke\n", n, n, n) for b.Len() < 12<<10 { fmt.Fprintf(&b, "ok \tamadan.net/pkg%d\t0.1s\n", b.Len()) } units = append(units, wire.CIUnit{Name: fmt.Sprintf("check shard %d of 23", n+1), Log: b.String()}) } hosted := "Hosted CI on oficina/sample at 2222222: failed.\n" + wire.JoinCIUnits(units, wire.MaxChecksOutput) output := "Candidate gate diagnostic:\n" + strings.Repeat("local noise\n", 400) + "\nHosted CI diagnostic:\n" + wire.ClipCIOutput(hosted, wire.MaxChecksOutput/3) r.checks("g-c", c, wire.ChecksFailed, exit(1), "", output) fix := r.dispatched(wire.SpecialistEngineering, cand, "", 1) for n := range 3 { if want := fmt.Sprintf("--- FAIL: TestShard%d (0.01s)\n shard_test.go:%d: shard %d broke\n", n, n, n); !strings.Contains(fix.Feedback, want) { t.Errorf("feedback lacks %q", want) } } }