]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: do not write test vet binary to GOROOT
authorBryan C. Mills <bcmills@google.com>
Tue, 19 Feb 2019 19:43:52 +0000 (14:43 -0500)
committerBryan C. Mills <bcmills@google.com>
Tue, 19 Feb 2019 20:54:12 +0000 (20:54 +0000)
Updates #28387

Change-Id: Ie5a5f1f798eb5900f9c7bdef165abcca02dd0dde
Reviewed-on: https://go-review.googlesource.com/c/163037
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/vet/vet_test.go

index d106c5c29ce7c1c1405fcaceb66179746c44cddc..6e8cc70440e54b15caa8257b56653171617eae55 100644 (file)
@@ -21,15 +21,21 @@ import (
        "testing"
 )
 
-const (
-       dataDir = "testdata"
-       binary  = "./testvet.exe"
-)
+const dataDir = "testdata"
+
+var binary string
 
 // We implement TestMain so remove the test binary when all is done.
 func TestMain(m *testing.M) {
+       dir, err := ioutil.TempDir("", "vet_test")
+       if err != nil {
+               fmt.Fprintln(os.Stderr, err)
+               os.Exit(1)
+       }
+       defer os.RemoveAll(dir)
+       binary = filepath.Join(dir, "testvet.exe")
+
        result := m.Run()
-       os.Remove(binary)
        os.Exit(result)
 }