beads/scripts/check-testing-short.sh
Jim Wordelman 5941096915
Fix: check-testing-short.sh flags comments and misnames the offending function (round 2) (#5809)
* test(feat): red — Fix: check-testing-short.sh flags comments and misnames the offending function (refs be-0v13)

* feat: green — Fix: check-testing-short.sh flags comments and misnames the offending function (refs be-0v13)

Skip comment-only mentions of testing.Short() before the allowlist
check: read the exact matched line and treat a line whose first
non-whitespace characters are // as non-offending. Existing
func-attribution logic already reports "unknown" for a hit above the
first func in a file, so no change was needed there.

Also fixes two test-fixture bugs found while confirming RED: the RED
test file's own source contained the literal substring testing.Short()
(now built via string concatenation into a shortCall const so the
checker doesn't flag this file when it scans the real repo tree), and
single-file temp-dir fixtures omitted the grep filename prefix
(now every fixture dir gets a companion .go file so find+grep always
sees 2+ filenames, matching real repo-root invocations).

* test(scripts): red — check-testing-short.sh must not attribute a hit between two functions to the preceding one (refs be-r56j)

* fix(scripts): green — resolve testing.Short() hits to the containing function, not the nearest preceding one (refs be-r56j)

* chore: release gate PASS for be-053u-check-testing-short-round2

* ci: retrigger — unrelated Ryuk reaper flake in storage/uow/tracker job

The "Test (storage domain + uow)" job failed on an infrastructure flake
unrelated to this PR's diff. That job runs three package trees in one
go test invocation (.github/workflows/pr.yml:676), so Go runs their test
binaries in parallel and each starts its own Dolt testcontainer. The
binaries share a single testcontainers Ryuk reaper; in this run the
internal/tracker binary reused a sibling's reaper and its handshake was
reset:

  23:12:21 Reaper obtained from Docker for this test session 6a74346c
  23:12:21 Reaper handshake failed: read ack: ... connection reset by peer

With no live connection holding the session open, Ryuk reaped the
session's containers. The tracker package's Dolt container went down
mid-suite and every subsequent store-backed test failed with
"connection refused" on 127.0.0.1:32772.

This is be-2on, root-caused on a different PR (#5339) with the identical
signature. The durable fix is PR #5770 (disable Ryuk on the Dolt
testcontainer steps), which is open and awaiting upstream merge.

This PR touches only scripts/check-testing-short.sh, its test, and a
release-gate record — nothing in internal/tracker or the Dolt path.
Empty commit to re-trigger CI.
2026-08-19 21:01:15 -07:00

64 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# Ensure testing.Short() is only used for true runtime/stress/large-fixture skips.
set -euo pipefail
allowed=$(
cat <<'EOF'
internal/hooks/hooks_test.go::TestRunSync_Timeout
internal/hooks/hooks_test.go::TestRunSync_KillsDescendants
internal/testutil/fixtures/fixtures_test.go::TestXLargeDolt
internal/testutil/fixtures/fixtures_test.go::TestLargeFromJSONL
internal/storage/dolt/concurrent_test.go::TestHighContentionStress
internal/storage/dolt/concurrent_test.go::TestConcurrentWorkQueueDrain
internal/storage/dolt/lease_test.go::TestConcurrentHeartbeatReclaimClose
internal/storage/uow/lostupdate_dolt_test.go::TestUOW_ConcurrentMergeOps_NoLostUpdate
internal/workapi/sweep_test.go::TestCandidateIDMatcherLargeFixture
EOF
)
status=0
while IFS=: read -r file line _; do
file="${file#./}"
if [[ -z "$file" || -z "$line" ]]; then
continue
fi
content=$(sed -n "${line}p" "$file")
if [[ "$content" =~ ^[[:space:]]*// ]]; then
continue
fi
func=$(
awk -v target="$line" '
NR > target { exit }
/^func [A-Za-z0-9_]+\(/ {
current = $0
sub(/^func /, "", current)
sub(/\(.*/, "", current)
next
}
current != "" && /^}/ { current = "" }
END { print current }
' "$file"
)
key="${file}::${func}"
if ! grep -Fxq "$key" <<<"$allowed"; then
printf 'Disallowed testing.Short() at %s:%s in %s\n' "$file" "$line" "${func:-unknown}" >&2
status=1
fi
done < <(find . -type f -name '*.go' -not -path './.git/*' -exec grep -n 'testing\.Short()' {} + || true)
if (( status != 0 )); then
cat >&2 <<'EOF'
testing.Short() is reserved for true runtime, stress, or large-fixture skips.
Use build tags, environment checks, or named wrappers for integration/e2e/API
boundaries instead.
EOF
exit "$status"
fi
printf 'testing.Short() usage is limited to approved runtime/stress/large-fixture skips.\n'