Canonical Go make test example omits -count=1, shipping a false green to every repo #44
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
REPO_POLICIES.mdlines 210-215 give this as the canonical Gotesttarget:Go caches successful test results and replays them for an unchanged tree, so
this target exits 0 having executed no test. Observed in
sneak/cattbox, whichcopied it: a
script/precommitrun exited 0 withok sneak.berlin/go/cattbox/cmd/cattbox (cached)for every package, in 0.235s.That is the same false-green class #40
is eliminating for the linter, one gate over — and the pre-commit hook is the
gate a person leans on most, where a cached pass is indistinguishable from a
real one.
Both invocations need the flag. The rerun especially: without it a failing run
replays from cache instead of reproducing the failure, which is exactly when the
output matters.
Proposed replacement:
-count=1defeats the test result cache only; the build cache is untouched,so this costs the runtime of the suite and no recompilation. Measured on
cattbox: 0.235s replayed against ~1.6s executed, with three consecutive executed
runs flat at 1.668s / 1.708s / 1.556s — a recompile would have made the first
one much longer than the rest.
The generic non-Go template above it (
<test-command>) needs no change, but thePython example is worth a look for the same reason if pytest caching is ever
enabled by default there.
Fixed in cattbox by sneak/cattbox#36. A PR against
this repo follows.
PR: #45.
Two notes from writing it. Root
REPO_POLICIES.mdis a symlink toprompts/REPO_POLICIES.md, so one edit covers both. And pytest does nothave this defect —
.pytest_cacherecords which tests failed for--lf/--ffselection, but selected tests still execute; replaying a stored pass needs a
third-party plugin. So no flag was added to the Python example.
Still open after that PR: propagation. Every Go repo that copied this target
has the false green live right now, and fixing the template does not fix them.
That wants its own tracking issue and a PR per repo, as
#40 does for the linter. I have fixed
sneak/cattbox(sneak/cattbox#36); I do not managethe others and have not touched them.