beads/scripts/check-testing-short.sh
Julian Knutsen 0500fc6f40
ci(bazel): run the scripts and source-walking tests remotely; retire their go test legs (#7320)
//scripts:scripts_test and //scripts/check-versions:check-versions_test
drop their host-tools/no-remote-exec/no-remote-cache tags and run on the
rbe-west workers like every other target (the worker image ships bash, git,
python3, jq, yq, curl, openssl, unzip and coreutils; a missing tool fails the
test under Bazel rather than skipping it). Go comes in hermetically as the
registered SDK; check-versions.sh's `go build` is stood in for by the
Bazel-built checker.

The tests that walked the source checkout now get it as data:
tools/bazel/go_srcs.py keeps a managed `repo_files` filegroup in every
package and aggregates them into //:repo_files (exactly the tracked files
Bazel can see; make bazel-sync-check fails on a package without one).
scripts_test and docsync_test take it instead of hand-listed filegroups,
and every TEST_SRCDIR/IsBazel skip and go-test-only block in them is gone.
The release formula under .bazelignore'd .beads/ comes in through a
@beads_formulas local repository; npm-package/ and .claude/ are visible to
Bazel again (only their node_modules/worktrees stay ignored), so the npm
manifest release check and the AGENTS.md skill links run under Bazel too.
TestZZStdioNotLeaked falls back to TestMain's pre-run streams instead of
skipping in a shard without its baseline.

tools/bazel/equivalence_allowlist.txt shrinks from 20 skip entries to the
two cmd/bd tests of plain go test's own bd build fallback, which Bazel never
takes; pr-preflight-platforms now runs them on Linux, macOS and Windows. The
scripts-go-checks scripts-test and allowlisted legs, their scripts
(scripts-go-test.sh, allowlisted-go-tests.sh, run_allowlisted_go_tests.py)
and main.yml's --compile-only warm for them are removed. The vet leg stays
(ga-96smfk.18).

Refs: ga-96smfk.16

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 22:20:16 +00:00

67 lines
2 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
# Symlinked .go files count too: under Bazel the tree is a runfiles symlink
# forest. find does not descend into symlinked directories (bazel-* links).
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 -o -type l \) -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'