mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/doc: use empty GOPATH when running the tests
Otherwise, a populated GOPATH might result in failures such as: $ go test [...] no buildable Go source files in [...]/gopherjs/compiler/natives/src/crypto/rand exit status 1 Move the initialization of the dirs walker out of the init func, so that we can control its behavior in the tests. Updates #24464. Change-Id: I4b26a7d3d6809bdd8e9b6b0556d566e7855f80fe Reviewed-on: https://go-review.googlesource.com/101836 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
041c5d8348
commit
77c3ef6f6f
4 changed files with 16 additions and 7 deletions
|
|
@ -7,7 +7,6 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"go/build"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
|
@ -16,6 +15,14 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// otherwise the tests are brittle, as they may give unexpected
|
||||
// output or errors when a suffix match with GOPATH takes place
|
||||
buildCtx.GOPATH = ""
|
||||
dirsInit()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func maybeSkip(t *testing.T) {
|
||||
if strings.HasPrefix(runtime.GOOS, "nacl") {
|
||||
t.Skip("nacl does not have a full file tree")
|
||||
|
|
@ -653,7 +660,7 @@ func TestDotSlashLookup(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
if err := os.Chdir(filepath.Join(build.Default.GOROOT, "src", "text")); err != nil {
|
||||
if err := os.Chdir(filepath.Join(buildCtx.GOROOT, "src", "text")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var b bytes.Buffer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue