From be8389ed4d5cbf49caa8d5001f7b1b804e0293ba Mon Sep 17 00:00:00 2001 From: Ian Roberts Date: Sat, 19 Oct 2024 16:21:53 +0100 Subject: [PATCH] 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. --- webhook_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webhook_test.go b/webhook_test.go index 97f70e2..c3f0610 100755 --- a/webhook_test.go +++ b/webhook_test.go @@ -214,7 +214,8 @@ func buildHookecho(t *testing.T) (binPath string, cleanupFn func()) { 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 { t.Fatalf("Building hookecho: %v", err) } @@ -272,7 +273,8 @@ func buildWebhook(t *testing.T) (binPath string, cleanupFn func()) { 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 { t.Fatalf("Building webhook: %v", err) }