Uh oh!
There was an error while loading. Please reload this page.
chore(makefile): derive the bats test count instead of hardcoding it - #690
Merged
Conversation
The help text advertised a "868-test bats suite". The real number on develop is 946, and nothing anywhere enforces the two agree — so it drifts on every PR that adds a test and had been wrong for a long time. Re-hardcoding today's value only resets the drift clock. BATS_TEST_COUNT is derived from the source of truth instead: bats declares one test per `@test` at line start, so a grep over scripts/tests/*.bats matches its own count exactly. Verified against a real run — 946 derived, 946 reported. Recursively expanded (`=`, not `:=`) so only `help` pays for the grep. Confirmed by pointing the variable at a marker-touching shell: `make check` — the pre-push path, budgeted under 60 s — never expands it; `make help` does. The same stale 868 appeared a second time in the `check` rationale comment. Prose can't be derived, so the count is simply dropped there; the sentence is about the two-minute runtime, which is the part that actually justifies keeping bats out of `check`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
shujaatTracebloc
approved these changes
Aug 12, 2026
shujaatTracebloc
left a comment
Contributor
There was a problem hiding this comment.
Approving.
Derivation is right and the = vs := choice is the load-bearing detail — make check is the pre-push path with a sub-60s budget and recursive expansion means it never pays for the grep. Checked the failure mode too: 2>/dev/null plus wc -l means a missing/renamed scripts/tests/*.bats degrades to 0-test, not to a broken help target, and ^@test can't match a commented-out #@test.
Help text only — no runtime path touches this.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
make helpadvertised a "868-test bats suite". The real total ondevelopis 946, and nothing enforces the two agree — so the number drifts on every PR that adds a test, and had been wrong for a long time.It also appeared a second time, in the
checkrationale comment ("the repo's real unit suite (868 tests)"), which the original report didn't mention. Both are fixed here; agrepconfirms no hardcoded suite count remains in the repo.The fix
Derived from the source of truth rather than written down:
bats declares one test per
@testat line start, so this matches its own count exactly. Verified against a real run: 946 derived, 946 reported bybats.Deliberately not re-hardcoded to today's value — that would just reset the drift clock, which is the actual failure mode here.
For the prose comment there is nothing to derive, so the count is simply dropped. The sentence is about the ~2-minute runtime, which is the part that actually justifies keeping bats out of
check.Why
=and not:=Recursively expanded, so only
helppays for the grep —make checkis the pre-push path with a sub-60 s budget and shouldn't shell out for a string it never prints.I checked this rather than assuming it, and the first two ways I tried were both confounded, so for anyone verifying later:
--eval='BATS_TEST_COUNT = …'is evaluated before the makefile is read, so the file's own assignment overrides it — every result was a false negative.make check BATS_TEST_COUNT=…) is expanded regardless, because make propagates it throughMAKEFLAGS— a false positive.The test that actually isolates it is a copy of the real Makefile with only the variable's body swapped for a marker-touching shell:
make check(=)make help(=)make check(:=):=was not usedTest plan
make check— green.make help— prints946-test bats suite.make bats— 946 tests, 0 failures; matches the derived number.grep -nE '\b[0-9]{3}[- ]?tests?\b' Makefile— no matches.Note
No issue was filed for this — it came in as a direct report. Recent history has precedent for small chores carrying only the PR number (e.g. #684, #667), so I followed that rather than opening a ticket to close it immediately. Happy to file one if you'd rather it were tracked on the board.
🤖 Generated with Claude Code
Note
Low Risk
Makefile-only developer UX change with no runtime, CI behavior, or test logic impact beyond accurate help text.
Overview
Fixes stale bats suite counts in the Makefile by deriving the total from
scripts/tests/*.bats(^@testlines) intoBATS_TEST_COUNT, somake helpalways shows the current size (e.g. 946) instead of the old hardcoded 868.Uses recursive
=so the grep runs only whenhelpprints the string—make checkstays on its fast path without an extra shell invocation. Thechecktarget comment no longer cites a fixed test count; it only explains why the full bats run stays incheck-all.Reviewed by Cursor Bugbot for commit b856c9f. Bugbot is set up for automated code reviews on this repo. Configure here.