tests: use GOROOT to find go command

This should ensure that, even if a developer or CI server has multiple versions of go installed, the version used to build the tools under test will be the same version that is running the test harness.
This commit is contained in:
Ian Roberts 2024-10-19 16:21:53 +01:00
parent c72da0b125
commit be8389ed4d

View file

@ -214,7 +214,8 @@ func buildHookecho(t *testing.T) (binPath string, cleanupFn func()) {
binPath += ".exe" binPath += ".exe"
} }
cmd := exec.Command("go", "build", "-o", binPath, "test/hookecho.go") gobin := filepath.Join(runtime.GOROOT(), "bin", "go")
cmd := exec.Command(gobin, "build", "-o", binPath, "test/hookecho.go")
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
t.Fatalf("Building hookecho: %v", err) t.Fatalf("Building hookecho: %v", err)
} }
@ -272,7 +273,8 @@ func buildWebhook(t *testing.T) (binPath string, cleanupFn func()) {
binPath += ".exe" binPath += ".exe"
} }
cmd := exec.Command("go", "build", "-o", binPath) gobin := filepath.Join(runtime.GOROOT(), "bin", "go")
cmd := exec.Command(gobin, "build", "-o", binPath)
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
t.Fatalf("Building webhook: %v", err) t.Fatalf("Building webhook: %v", err)
} }