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.
40 lines
1.3 KiB
Makefile
40 lines
1.3 KiB
Makefile
# Development convenience targets. This repo is exempt from the standard
|
|
# policy scaffold (no Dockerfile, CI, or REPO_POLICIES.md); this Makefile
|
|
# is only a thin wrapper around the Go toolchain, golangci-lint, and
|
|
# prettier so `make fmt` / `make check` behave the same as in sneak's
|
|
# other repos.
|
|
|
|
GO_PKGS := ./...
|
|
MD_FILES := $(shell git ls-files '*.md')
|
|
PRETTIER := prettier --tab-width 4 --prose-wrap always
|
|
|
|
.PHONY: check fmt fmt-check lint test
|
|
|
|
# Format, lint, and test — the full local pre-commit gate.
|
|
check: fmt-check lint test
|
|
|
|
# Format Go and Markdown in place.
|
|
fmt:
|
|
gofmt -w .
|
|
$(PRETTIER) --write $(MD_FILES)
|
|
|
|
# Fail if any Go or Markdown file is not formatted.
|
|
fmt-check:
|
|
@unformatted="$$(gofmt -l .)"; \
|
|
if [ -n "$$unformatted" ]; then \
|
|
echo "gofmt needed on:"; echo "$$unformatted"; exit 1; \
|
|
fi
|
|
$(PRETTIER) --check $(MD_FILES)
|
|
|
|
# Run the house linter (config in .golangci.yml).
|
|
lint:
|
|
golangci-lint run $(GO_PKGS)
|
|
|
|
# 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 -timeout 30s -race -cover $(GO_PKGS) || \
|
|
{ echo "--- Rerunning with -v for details ---"; \
|
|
go test -timeout 30s -race -v $(GO_PKGS); exit 1; }
|