net/tlsdial,tstest,version: use go command from $PATH

Go now includes the GOROOT bin directory in $PATH while running tests
and generate, so it is no longer necessary to construct a path using
runtime.GOROOT().

Fixes #6689

Signed-off-by: James Tucker <james@tailscale.com>
pull/6933/head
James Tucker 2 years ago committed by James Tucker
parent 467ace7d0c
commit b2c55e62c8

@ -43,7 +43,7 @@ func TestFallbackRootWorks(t *testing.T) {
crtFile := filepath.Join(d, "tlsdial.test.crt") crtFile := filepath.Join(d, "tlsdial.test.crt")
keyFile := filepath.Join(d, "tlsdial.test.key") keyFile := filepath.Join(d, "tlsdial.test.key")
caFile := filepath.Join(d, "rootCA.pem") caFile := filepath.Join(d, "rootCA.pem")
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), cmd := exec.Command("go",
"run", "filippo.io/mkcert", "run", "filippo.io/mkcert",
"--cert-file="+crtFile, "--cert-file="+crtFile,
"--key-file="+keyFile, "--key-file="+keyFile,

@ -11,8 +11,6 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"runtime"
"strings" "strings"
"testing" "testing"
@ -53,7 +51,7 @@ func TestInQemu(t *testing.T) {
} }
t.Logf("using %v", look) t.Logf("using %v", look)
} }
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), cmd := exec.Command("go",
"test", "test",
"--exec="+execVia, "--exec="+execVia,
"-v", "-v",

@ -13,13 +13,11 @@ import (
"encoding/json" "encoding/json"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"runtime"
"testing" "testing"
) )
func TestDeps(t *testing.T) { func TestDeps(t *testing.T) {
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "list", "-json", ".") cmd := exec.Command("go", "list", "-json", ".")
cmd.Env = append(os.Environ(), "GOOS=ios", "GOARCH=arm64") cmd.Env = append(os.Environ(), "GOOS=ios", "GOARCH=arm64")
out, err := cmd.Output() out, err := cmd.Output()
if err != nil { if err != nil {

@ -13,13 +13,11 @@ import (
"encoding/json" "encoding/json"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"runtime"
"testing" "testing"
) )
func TestDeps(t *testing.T) { func TestDeps(t *testing.T) {
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "list", "-json", ".") cmd := exec.Command("go", "list", "-json", ".")
cmd.Env = append(os.Environ(), "GOOS=js", "GOARCH=wasm") cmd.Env = append(os.Environ(), "GOOS=js", "GOARCH=wasm")
out, err := cmd.Output() out, err := cmd.Output()
if err != nil { if err != nil {

@ -23,8 +23,7 @@ var (
func TestFindModuleInfo(t *testing.T) { func TestFindModuleInfo(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
name := filepath.Join(dir, "tailscaled-version-test") name := filepath.Join(dir, "tailscaled-version-test")
goTool := filepath.Join(runtime.GOROOT(), "bin", "go"+exe()) out, err := exec.Command("go", "build", "-o", name, "tailscale.com/cmd/tailscaled").CombinedOutput()
out, err := exec.Command(goTool, "build", "-o", name, "tailscale.com/cmd/tailscaled").CombinedOutput()
if err != nil { if err != nil {
t.Fatalf("failed to build tailscaled: %v\n%s", err, out) t.Fatalf("failed to build tailscaled: %v\n%s", err, out)
} }

Loading…
Cancel
Save