mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-18 02:48:40 +00:00
tstest/integration: use go binary from runtime.GOROOT
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
bf5fc8edda
commit
a07a504b16
@ -105,13 +105,34 @@ func TestIntegration(t *testing.T) {
|
|||||||
t.Logf("number of HTTP logcatcher requests: %v", logc.numRequests())
|
t.Logf("number of HTTP logcatcher requests: %v", logc.numRequests())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exe() string {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return ".exe"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func findGo(t *testing.T) string {
|
||||||
|
goBin := filepath.Join(runtime.GOROOT(), "bin", "go"+exe())
|
||||||
|
if fi, err := os.Stat(goBin); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
t.Fatalf("failed to find go at %v", goBin)
|
||||||
|
}
|
||||||
|
t.Fatalf("looking for go binary: %v", err)
|
||||||
|
} else if !fi.Mode().IsRegular() {
|
||||||
|
t.Fatalf("%v is unexpected %v", goBin, fi.Mode())
|
||||||
|
}
|
||||||
|
t.Logf("using go binary %v", goBin)
|
||||||
|
return goBin
|
||||||
|
}
|
||||||
|
|
||||||
func build(t *testing.T, outDir, target string) string {
|
func build(t *testing.T, outDir, target string) string {
|
||||||
exe := ""
|
exe := ""
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
exe = ".exe"
|
exe = ".exe"
|
||||||
}
|
}
|
||||||
bin := filepath.Join(outDir, path.Base(target)) + exe
|
bin := filepath.Join(outDir, path.Base(target)) + exe
|
||||||
errOut, err := exec.Command("go", "build", "-o", bin, target).CombinedOutput()
|
errOut, err := exec.Command(findGo(t), "build", "-o", bin, target).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to build %v: %v, %s", target, err, errOut)
|
t.Fatalf("failed to build %v: %v, %s", target, err, errOut)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user