Fix TestMain to find module root before building bd binary
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 <noreply@anthropic.com>
This commit is contained in:
@@ -32,8 +32,18 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpDir)
|
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)
|
testBDBinary = filepath.Join(tmpDir, binName)
|
||||||
cmd := exec.Command("go", "build", "-o", testBDBinary, "./cmd/bd")
|
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 {
|
if out, err := cmd.CombinedOutput(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to build bd binary: %v\n%s\n", err, out)
|
fmt.Fprintf(os.Stderr, "Failed to build bd binary: %v\n%s\n", err, out)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user