oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package thintest
2
3import (
4 "fmt"
5 "strings"
6 "testing"
7
8 "amadan.net/oficina/equipo/internal/wire"
9)
10
11// TestFixRoundGetsEveryShard (stopped-jobs audit, fix 4): hosted CI
12// failed in three shards. The fix round's feedback names every shard and
13// keeps each one's failing test and message, within its budget; before,
14// it kept the last 60 lines of the output, which only the last shard
15// reached ("Shard 16 also failed but its output wasn't included").
16func TestFixRoundGetsEveryShard(t *testing.T) {
17 r := newToolRigAt(t, wire.ProtocolCurrent)
18 base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40)
19 id, _ := r.pushed("s", "Swipe down to dismiss the keyboard", base, cand)
20 task := r.task(id)
21 r.expect(wire.FrameWatchMerge)
22 c := r.dispatched(wire.SpecialistChecks, base, cand, 0)
23 names := []string{"check shard 5 of 23", "check shard 10 of 23", "check shard 16 of 23"}
24 var units []wire.CIUnit
25 for n, name := range names {
26 var b strings.Builder
27 fmt.Fprintf(&b, "--- FAIL: TestShard%d (0.01s)\n shard_test.go:%d: shard %d broke\n", n, n, n)
28 for b.Len() < 12<<10 {
29 fmt.Fprintf(&b, "ok \tamadan.net/pkg%d\t0.1s\n", b.Len())
30 }
31 units = append(units, wire.CIUnit{Name: name, Log: b.String() + "FAIL\n"})
32 }
33 rep := hostedReport(c, task.Branch, wire.HostedFailure, names...)
34 head := "Hosted CI on oficina/sample: failed.\nFailed: " + strings.Join(names, "; ") + "\n"
35 rep.Output = head + wire.JoinCIUnits(units, wire.MaxChecksOutput-len(head))
36 r.step("s-c", rep)
37 fix := r.dispatched(wire.SpecialistEngineering, cand, "", 1)
38 for n, name := range names {
39 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)} {
40 if !strings.Contains(fix.Feedback, want) {
41 t.Errorf("feedback lacks %q", want)
42 }
43 }
44 }
45 if len(fix.Feedback) > wire.MaxTaskBrief+4000 {
46 t.Fatalf("feedback %d bytes", len(fix.Feedback))
47 }
48}
49
50// The local gate failed with hosted CI's failing units beside it (the
51// runner's combined diagnostic): the fix round's feedback still keeps
52// every unit's failing test.
53func TestFixRoundGetsEveryShardBesideTheLocalGate(t *testing.T) {
54 r := newToolRigAt(t, wire.ProtocolCurrent)
55 base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40)
56 id, _ := r.pushed("g", "Swipe down to dismiss the keyboard", base, cand)
57 _ = id
58 r.expect(wire.FrameWatchMerge)
59 c := r.dispatched(wire.SpecialistChecks, base, cand, 0)
60 var units []wire.CIUnit
61 for n := range 3 {
62 var b strings.Builder
63 fmt.Fprintf(&b, "--- FAIL: TestShard%d (0.01s)\n shard_test.go:%d: shard %d broke\n", n, n, n)
64 for b.Len() < 12<<10 {
65 fmt.Fprintf(&b, "ok \tamadan.net/pkg%d\t0.1s\n", b.Len())
66 }
67 units = append(units, wire.CIUnit{Name: fmt.Sprintf("check shard %d of 23", n+1), Log: b.String()})
68 }
69 hosted := "Hosted CI on oficina/sample at 2222222: failed.\n" + wire.JoinCIUnits(units, wire.MaxChecksOutput)
70 output := "Candidate gate diagnostic:\n" + strings.Repeat("local noise\n", 400) + "\nHosted CI diagnostic:\n" + wire.ClipCIOutput(hosted, wire.MaxChecksOutput/3)
71 r.checks("g-c", c, wire.ChecksFailed, exit(1), "", output)
72 fix := r.dispatched(wire.SpecialistEngineering, cand, "", 1)
73 for n := range 3 {
74 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) {
75 t.Errorf("feedback lacks %q", want)
76 }
77 }
78}
79