From e376b2bf11a38ff6b46c689fc6e005ae8f3e18a6 Mon Sep 17 00:00:00 2001 From: sneak Date: Sun, 9 Aug 2026 01:42:24 +0000 Subject: [PATCH] build: adopt the mandated test target pattern (closes #2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test: target was a bare `go test $(GO_PKGS)`, diverging from the mandated shape in four ways: no -timeout 30s, no -race, no -cover, and no conditional verbose rerun. It now runs go test -timeout 30s -race -cover $(GO_PKGS) and, on failure, reruns with -v and then exits 1 — so the build still fails even if a flaky test happens to pass on the second attempt. The repo's existing $(GO_PKGS) variable is kept rather than hardcoding ./..., and the recipe is @-prefixed so the rerun banner is the only noise. The substance here is -race, not the Makefile edit: this is the first time the suite has run under the race detector. It is clean, across five consecutive uncached runs, including the tcell terminal layer and the os.Exit-path playthrough tests that were the suspected risk. Timing against the 20-second budget: 5.1s cold (including the race build), ~2.3s warm. The failure path was exercised with a throwaway failing test to confirm the verbose rerun fires and make exits non-zero. Build tooling only; no game behavior change. .golangci.yml is untouched. --- Makefile | 8 ++++++-- TODO.md | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4562048..c2d6274 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,10 @@ fmt-check: lint: golangci-lint run $(GO_PKGS) -# Run the test suite. +# Run the test suite. Quiet on success; on failure, rerun verbosely for the +# full output and still fail the target (the first run already proved the +# tests are broken, so a flaky pass on the rerun must not rescue the build). test: - go test $(GO_PKGS) + @go test -timeout 30s -race -cover $(GO_PKGS) || \ + { echo "--- Rerunning with -v for details ---"; \ + go test -timeout 30s -race -v $(GO_PKGS); exit 1; } diff --git a/TODO.md b/TODO.md index e99d21b..c0833bc 100644 --- a/TODO.md +++ b/TODO.md @@ -34,6 +34,19 @@ wizard commands). # Completed Steps +- 2026-08-09 Policy-shaped `make test` (`make-test-policy-pattern`): the `test:` + target was a bare `go test $(GO_PKGS)` and now runs + `-timeout 30s -race -cover` with the mandated conditional verbose rerun (on + failure it reruns with `-v` and then `exit 1`, so a flaky pass on the second + attempt cannot rescue the build). `$(GO_PKGS)` is kept rather than hardcoding + `./...`. The substance was `-race`, not the Makefile edit: this is the first + time the suite has run under the race detector, and it is clean — no data + races across five consecutive uncached runs, including the tcell terminal + layer and the `os.Exit`-path playthrough tests. Wall clock 5.1s cold + (including the race build) and ~2.3s warm, against the 20s policy budget. The + failure path was exercised with a throwaway failing test to confirm the rerun + fires and `make` exits non-zero. Build tooling only; no game behavior change. + - 2026-08-07 Canonical linter config (`golangci-v2.12.2`): replaced `.golangci.yml` with the shared canonical config (v2 schema; settings now live under `linters.settings`, so the `lll`/`funlen`/`cyclop`/`dupl` thresholds -- 2.49.1