From 4ce091cbd824f5382e92cbcc330e0729d6f22c01 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 2 Sep 2021 20:11:20 -0700 Subject: [PATCH] version: use `go` from the current toolchain to compile in tests. Signed-off-by: David Anderson --- version/modinfo_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/version/modinfo_test.go b/version/modinfo_test.go index c7c1a14a3..117b46ca1 100644 --- a/version/modinfo_test.go +++ b/version/modinfo_test.go @@ -7,6 +7,7 @@ package version import ( "os/exec" "path/filepath" + "runtime" "strings" "testing" ) @@ -14,7 +15,8 @@ import ( func TestFindModuleInfo(t *testing.T) { dir := t.TempDir() name := filepath.Join(dir, "tailscaled-version-test") - out, err := exec.Command("go", "build", "-o", name, "tailscale.com/cmd/tailscaled").CombinedOutput() + goTool := filepath.Join(runtime.GOROOT(), "bin", "go"+exe()) + out, err := exec.Command(goTool, "build", "-o", name, "tailscale.com/cmd/tailscaled").CombinedOutput() if err != nil { t.Fatalf("failed to build tailscaled: %v\n%s", err, out) } @@ -27,3 +29,10 @@ func TestFindModuleInfo(t *testing.T) { t.Errorf("unexpected modinfo contents %q", modinfo) } } + +func exe() string { + if runtime.GOOS == "windows" { + return ".exe" + } + return "" +}