Add a make cover target so coverage is measurable under the make-targets-only rule #17

Closed
opened 2026-08-09 03:46:16 +02:00 by clawbot · 1 comment
Collaborator

Problem

Coverage is currently unmeasurable without violating repo policy. Only make
targets and script/ entrypoints may be used, and no target reports coverage
detail — so "which functions are untested?" can only be answered by grepping
test files for identifiers by hand.

That is exactly how the current coverage gaps (#5 rings, #6 sticks, #7 wizard,
#14 traps) had to be found, and it is slow and error-prone.

Note #2 adds -cover to make test, which prints a single per-package
percentage. That is a coarse signal — useful as a trend, useless for finding
which function is uncovered. This issue is about the per-function view.

Definition of done

  1. A make cover target that produces a per-function coverage report
    (the -coverprofile + go tool cover -func shape), so specific untested
    functions are identifiable.
  2. An HTML report is generated or trivially obtainable — either a second
    target (make cover-html) or a documented one-liner in the README.
  3. The coverage profile is written somewhere ignored by git, and .gitignore
    is updated so a stray profile can never be committed.
  4. make check must not run make cover and must remain non-file-
    modifying — policy requires make check not to modify any files in the
    repo. Verify this: run make check, then confirm git status is clean.
  5. The README's make-target list mentions the new target.
  6. make check fully green.
  7. TODO.md updated in the same commit.
  8. Commit title ends with (closes #N).

Implementation requirements

  • Follow the existing Makefile's conventions: $(GO_PKGS), the .PHONY
    line, and a short comment above the target like its neighbors.
  • Do NOT add a Dockerfile, CI config, or script/ entrypoints — this repo is
    exempt.
  • Do NOT modify .golangci.yml.
  • No Go source changes; this is build tooling only.
  • make targets only for verification.
  • Never mention Claude or Anthropic anywhere.

Priority

Low — this is a tooling convenience. It is genuinely more valuable before
the four coverage issues than after, since it turns "did we actually improve
coverage?" into a measurable question, but it does not block them.

## Problem Coverage is currently unmeasurable without violating repo policy. Only `make` targets and `script/` entrypoints may be used, and no target reports coverage detail — so "which functions are untested?" can only be answered by grepping test files for identifiers by hand. That is exactly how the current coverage gaps (#5 rings, #6 sticks, #7 wizard, #14 traps) had to be found, and it is slow and error-prone. Note #2 adds `-cover` to `make test`, which prints a single per-package percentage. That is a coarse signal — useful as a trend, useless for finding *which* function is uncovered. This issue is about the per-function view. ## Definition of done 1. A `make cover` target that produces a **per-function** coverage report (the `-coverprofile` + `go tool cover -func` shape), so specific untested functions are identifiable. 2. An HTML report is generated or trivially obtainable — either a second target (`make cover-html`) or a documented one-liner in the README. 3. The coverage profile is written somewhere ignored by git, and `.gitignore` is updated so a stray profile can never be committed. 4. `make check` must **not** run `make cover` and must remain non-file- modifying — policy requires `make check` not to modify any files in the repo. Verify this: run `make check`, then confirm `git status` is clean. 5. The README's make-target list mentions the new target. 6. `make check` fully green. 7. `TODO.md` updated in the same commit. 8. Commit title ends with ` (closes #N)`. ## Implementation requirements - Follow the existing Makefile's conventions: `$(GO_PKGS)`, the `.PHONY` line, and a short comment above the target like its neighbors. - Do NOT add a Dockerfile, CI config, or `script/` entrypoints — this repo is exempt. - Do NOT modify `.golangci.yml`. - No Go source changes; this is build tooling only. - `make` targets only for verification. - Never mention Claude or Anthropic anywhere. ## Priority Low — this is a tooling convenience. It is genuinely more valuable **before** the four coverage issues than after, since it turns "did we actually improve coverage?" into a measurable question, but it does not block them.
Author
Collaborator

Done in e3ab4ab on next, in #46.

make cover writes build/coverage.out and prints the per-function report. make cover-html depends on cover and renders the same profile to build/coverage.html, echoing the path — a target rather than a README one-liner, since the one-liner would have been a raw go tool cover invocation in the docs.

Both use $(GO_PKGS) and the existing .PHONY line, and both are out of check: they write files, and check must not modify the working tree. The check recipe now says so in a comment. Coverage artifacts land under build/, which .gitignore covers as a whole.

README.md's make-target list names both, and points at build/coverage.html.

TODO.md has a Completed Steps entry in the same commit.

Verification, make targets only:

  • GOFLAGS=-count=1 make cover-html printed per-function lines and total: (statements) 62.6%, then wrote build/coverage.html. Sample of what the per-function view gives that make test's per-package percentage cannot: game/weapons.go:109: wield 0.0%, term/tcell.go:94: ReadChar 0.0%.
  • git status --porcelain empty with build/coverage.out, build/coverage.html and build/rogue all present.
  • GOFLAGS=-count=1 make check green in 22.5s, check still fmt-check lint test. The lint layer reported DONE 13.2s with 0 issues., not CACHED; test lines cmd/rogue 1.075s and game 4.049s, no (cached) marker. git status --porcelain empty afterwards.

make cover runs without -race deliberately — coverage is a measurement, not the gate, and make test is where the race detector runs.

Done in `e3ab4ab` on `next`, in https://git.eeqj.de/sneak/rgoue/pulls/46. `make cover` writes `build/coverage.out` and prints the per-function report. `make cover-html` depends on `cover` and renders the same profile to `build/coverage.html`, echoing the path — a target rather than a README one-liner, since the one-liner would have been a raw `go tool cover` invocation in the docs. Both use `$(GO_PKGS)` and the existing `.PHONY` line, and both are out of `check`: they write files, and `check` must not modify the working tree. The `check` recipe now says so in a comment. Coverage artifacts land under `build/`, which `.gitignore` covers as a whole. `README.md`'s make-target list names both, and points at `build/coverage.html`. `TODO.md` has a Completed Steps entry in the same commit. Verification, `make` targets only: - `GOFLAGS=-count=1 make cover-html` printed per-function lines and `total: (statements) 62.6%`, then `wrote build/coverage.html`. Sample of what the per-function view gives that `make test`'s per-package percentage cannot: `game/weapons.go:109: wield 0.0%`, `term/tcell.go:94: ReadChar 0.0%`. - `git status --porcelain` empty with `build/coverage.out`, `build/coverage.html` and `build/rogue` all present. - `GOFLAGS=-count=1 make check` green in 22.5s, `check` still `fmt-check lint test`. The lint layer reported `DONE 13.2s` with `0 issues.`, not `CACHED`; test lines `cmd/rogue 1.075s` and `game 4.049s`, no `(cached)` marker. `git status --porcelain` empty afterwards. `make cover` runs without `-race` deliberately — coverage is a measurement, not the gate, and `make test` is where the race detector runs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/rgoue#17