//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>
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package scripts_test
|
|
|
|
import (
|
|
"os/exec"
|
|
"testing"
|
|
|
|
"github.com/steveyegge/beads/internal/testutil/bazeltest"
|
|
)
|
|
|
|
// skipOrFailWithoutHostTool handles a missing host tool. Under go test the
|
|
// test skips, as it always has. Under Bazel it fails: //scripts:scripts_test
|
|
// relies on the executor's bash, git, python3 and friends (the rbe-west
|
|
// worker image, or the runner in fork-cache mode), so a skip there would
|
|
// hide an executor that lacks one behind a green, cacheable result.
|
|
func skipOrFailWithoutHostTool(t *testing.T, format string, args ...any) {
|
|
t.Helper()
|
|
if bazeltest.IsBazel() {
|
|
t.Fatalf("executor lacks a host tool: "+format, args...)
|
|
}
|
|
t.Skipf(format, args...)
|
|
}
|
|
|
|
// requireHostTool returns the path of a host tool, or skips/fails via
|
|
// skipOrFailWithoutHostTool when it is missing.
|
|
func requireHostTool(t *testing.T, name string) string {
|
|
t.Helper()
|
|
path, err := exec.LookPath(name)
|
|
if err != nil {
|
|
skipOrFailWithoutHostTool(t, "%s not available: %v", name, err)
|
|
}
|
|
return path
|
|
}
|
|
|
|
// testGo returns the go binary to run. Under Bazel that is the registered Go
|
|
// SDK (BUILD data, BEADS_TEST_GO), which is go.mod's toolchain: the go on the
|
|
// executor's PATH may be another release.
|
|
func testGo(t *testing.T) string {
|
|
t.Helper()
|
|
if bazeltest.IsBazel() {
|
|
path, err := bazeltest.RunfileEnv("BEADS_TEST_GO")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return path
|
|
}
|
|
return requireHostTool(t, "go")
|
|
}
|