diff --git a/LESSONS.md b/LESSONS.md index 4248f956c..d233653ac 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -408,7 +408,15 @@ TestSettingsSaveKeepsWhatItDoesNotSend (internal/gui) every setting. Both bodies say what they ran; neither ran `go test ./internal/cli` (40s). The same day three commits that each fit the core's script budget at their own base left it 4 bytes over together (61a93b531). -- Seen 1× (2026-11-11). +- 11-15: 261f48226 (Disconnect and quit) added POST /api/quit/disconnect + and ran internal/gui and five GUI files, not internal/cli. The CLI + guard was red on ubuntu and macOS CI at 0ffb21f83 (#6786). After + this rule had been written and missed again, the check moved to the + package GUI changes do run: internal/gui's + TestEveryRouteIsNamedForTheCLI fails on a route that the CLI's list + doesn't name. When a rule keeps being missed, put its check where + the work already runs. +- Seen 2× (2026-11-11, 2026-11-15). **A full run gives the slow packages room.** `go test ./...` at the default 10m timeout times out in internal/gateway (#2108), and under load in diff --git a/internal/gui/route_cli_named_test.go b/internal/gui/route_cli_named_test.go new file mode 100644 index 000000000..f76b4ac3c --- /dev/null +++ b/internal/gui/route_cli_named_test.go @@ -0,0 +1,47 @@ +package gui + +import ( + "os" + "path/filepath" + "regexp" + "strings" + "testing" +) + +// Every /api route this package serves is named in internal/cli's route +// list (cliForRoute or notYet in settings_parity_test.go), checked here +// too: a GUI change runs this package, and a new route unnamed there left +// TestEveryRouteHasACommandOrIsNamed red on main again and again (#5946, +// #6162, #6677, #6724, #6786), each found by CI after the push. That +// test still says which command a route has; this one only says the +// route was named at all. +func TestEveryRouteIsNamedForTheCLI(t *testing.T) { + list, err := os.ReadFile(filepath.Join("..", "cli", "settings_parity_test.go")) + if err != nil { + t.Fatal(err) + } + files, err := filepath.Glob("*.go") + if err != nil { + t.Fatal(err) + } + re := regexp.MustCompile(`HandleFunc\("([A-Z]+ /api/[^"]*)"`) + n := 0 + for _, f := range files { + if strings.HasSuffix(f, "_test.go") { + continue + } + b, err := os.ReadFile(f) + if err != nil { + t.Fatal(err) + } + for _, m := range re.FindAllStringSubmatch(string(b), -1) { + n++ + if !strings.Contains(string(list), `"`+m[1]+`":`) { + t.Errorf("%s (%s) isn't named in internal/cli/settings_parity_test.go: add it to cliForRoute with its command, or to notYet with why there's none", m[1], f) + } + } + } + if n < 200 { + t.Fatalf("read %d routes", n) + } +}