From 143f5c80bf2e8402f0fe7869198dc2a57e3278b7 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Tue, 23 Dec 2025 23:49:42 -0800 Subject: [PATCH] Fix TestMain to find module root before building bd binary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TestMain in beads_hash_multiclone_test.go was running `go build ./cmd/bd` from the package directory (internal/beads) instead of the module root, causing the build to fail with "directory not found". Now uses `go list -m -f '{{.Dir}}'` to locate the module root and sets cmd.Dir appropriately before building. This fixes the integration test setup that was preventing TestRoutingIntegration from running. (bd-g9eu) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/beads/beads_hash_multiclone_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/beads/beads_hash_multiclone_test.go b/internal/beads/beads_hash_multiclone_test.go index 01bc1441..89ee842a 100644 --- a/internal/beads/beads_hash_multiclone_test.go +++ b/internal/beads/beads_hash_multiclone_test.go @@ -24,16 +24,26 @@ func TestMain(m *testing.M) { if runtime.GOOS == "windows" { binName = "bd.exe" } - + tmpDir, err := os.MkdirTemp("", "bd-test-bin-*") if err != nil { fmt.Fprintf(os.Stderr, "Failed to create temp dir for bd binary: %v\n", err) os.Exit(1) } defer os.RemoveAll(tmpDir) - + + // Find module root directory (where go.mod lives) + modRootCmd := exec.Command("go", "list", "-m", "-f", "{{.Dir}}") + modRootOut, err := modRootCmd.Output() + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to find module root: %v\n", err) + os.Exit(1) + } + modRoot := strings.TrimSpace(string(modRootOut)) + testBDBinary = filepath.Join(tmpDir, binName) cmd := exec.Command("go", "build", "-o", testBDBinary, "./cmd/bd") + cmd.Dir = modRoot // Build from module root where ./cmd/bd exists if out, err := cmd.CombinedOutput(); err != nil { fmt.Fprintf(os.Stderr, "Failed to build bd binary: %v\n%s\n", err, out) os.Exit(1)