Commit 613f0a31 authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go: set GO111MODULE=off explicitly in tests that assume GOPATH mode

We will soon switch GO111MODULE to 'on' by default, and when that
happens these tests will otherwise break.

Updates #30228

Change-Id: I1016d429b1dfb889d1aae8bc86fb2567cf0fc56f
Reviewed-on: https://go-review.googlesource.com/c/162697
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
parent cf155b00
...@@ -394,6 +394,7 @@ func (tg *testgoData) setenv(name, val string) { ...@@ -394,6 +394,7 @@ func (tg *testgoData) setenv(name, val string) {
func (tg *testgoData) unsetenv(name string) { func (tg *testgoData) unsetenv(name string) {
if tg.env == nil { if tg.env == nil {
tg.env = append([]string(nil), os.Environ()...) tg.env = append([]string(nil), os.Environ()...)
tg.env = append(tg.env, "GO111MODULE=off")
} }
for i, v := range tg.env { for i, v := range tg.env {
if strings.HasPrefix(v, name+"=") { if strings.HasPrefix(v, name+"=") {
......
env GO111MODULE=off
# check that error for missing binary-only says where it should be # check that error for missing binary-only says where it should be
! go build b ! go build b
stderr pkg[\\/].*a\.a stderr pkg[\\/].*a\.a
......
env GO111MODULE=off
# Set GOCACHE to a clean directory to ensure that 'go build' has work to report. # Set GOCACHE to a clean directory to ensure that 'go build' has work to report.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
......
env GO111MODULE=off
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
mkdir $GOCACHE mkdir $GOCACHE
......
env GO111MODULE=off
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
mkdir $GOCACHE mkdir $GOCACHE
......
env GO111MODULE=off
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
mkdir $GOCACHE mkdir $GOCACHE
......
env GO111MODULE=off
[!gc] skip [!gc] skip
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
......
env GO111MODULE=off
# As of Go 1.12, the module cache is required. # As of Go 1.12, the module cache is required.
# If none of the variables we use to locate GOCACHE are set, the cache is off # If none of the variables we use to locate GOCACHE are set, the cache is off
......
env GO111MODULE=off
# Regression test for golang.org/issue/21309: accept relative -pkgdir argument. # Regression test for golang.org/issue/21309: accept relative -pkgdir argument.
[short] skip [short] skip
......
env GO111MODULE=off
# If GOTMPDIR is relative, 'go build' should derive an absolute $WORK directory. # If GOTMPDIR is relative, 'go build' should derive an absolute $WORK directory.
cd $WORK cd $WORK
mkdir tmp mkdir tmp
......
env GO111MODULE=off
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
mkdir $GOCACHE mkdir $GOCACHE
......
env GO111MODULE=off
# Integration test for cache directory calculation (cmd/go/internal/cache). # Integration test for cache directory calculation (cmd/go/internal/cache).
[windows] skip [windows] skip
......
env GO111MODULE=off
# This test tests that we can link in-package syso files that provides symbols # This test tests that we can link in-package syso files that provides symbols
# for cgo. See issue 29253. # for cgo. See issue 29253.
[!cgo] stop [!cgo] stop
......
env GO111MODULE=off
# go clean -testcache # go clean -testcache
# should work (see golang.org/issue/29757). # should work (see golang.org/issue/29757).
cd x cd x
......
env GO111MODULE=off
[short] skip [short] skip
go test -coverpkg=all -covermode=atomic x go test -coverpkg=all -covermode=atomic x
......
env GO111MODULE=off
# Issue 23882 # Issue 23882
[short] skip [short] skip
......
env GO111MODULE=off
# Issue 23150 # Issue 23150
[short] skip [short] skip
......
env GO111MODULE=off
# look for short, relative file:line in error message # look for short, relative file:line in error message
! go run ../../gopath/x/y/z/err.go ! go run ../../gopath/x/y/z/err.go
stderr ^..[\\/]x[\\/]y[\\/]z[\\/]err.go: stderr ^..[\\/]x[\\/]y[\\/]z[\\/]err.go:
......
env GO111MODULE=off
[!gc] skip 'using -gcflags and -ldflags' [!gc] skip 'using -gcflags and -ldflags'
# -gcflags=-e applies to named packages, not dependencies # -gcflags=-e applies to named packages, not dependencies
......
env GO111MODULE=off
[!exec:git] skip [!exec:git] skip
# Set up some empty repositories. # Set up some empty repositories.
......
env GO111MODULE=off
[!exec:git] skip [!exec:git] skip
# Set up a benign repository and a repository with a dotfile name. # Set up a benign repository and a repository with a dotfile name.
......
env GO111MODULE=off
# Paths containing windows short names should be rejected before attempting to fetch. # Paths containing windows short names should be rejected before attempting to fetch.
! go get example.com/longna~1.dir/thing ! go get example.com/longna~1.dir/thing
stderr 'trailing tilde and digits' stderr 'trailing tilde and digits'
......
env GO111MODULE=off
[!exec:git] skip [!exec:git] skip
# Construct a repository that imports a non-ASCII path. # Construct a repository that imports a non-ASCII path.
......
env GO111MODULE=off
env GIT_TRACE=1 env GIT_TRACE=1
[!net] skip [!net] skip
......
env GO111MODULE=off
# GOFLAGS sets flags for commands # GOFLAGS sets flags for commands
env GOFLAGS='-e -f={{.Dir}} --test.benchtime=1s -count=10' env GOFLAGS='-e -f={{.Dir}} --test.benchtime=1s -count=10'
......
env GO111MODULE=off
# go help shows overview. # go help shows overview.
go help go help
stdout 'Go is a tool' stdout 'Go is a tool'
......
env GO111MODULE=off
# 'go install' with no arguments should clean up after go build # 'go install' with no arguments should clean up after go build
cd mycmd cd mycmd
go build go build
......
env GO111MODULE=off
cd mycmd cd mycmd
go build mycmd go build mycmd
......
env GO111MODULE=off
# GOPATH with p1 in d1, p2 in d2 # GOPATH with p1 in d1, p2 in d2
env GOPATH=$WORK/d1${:}$WORK/d2 env GOPATH=$WORK/d1${:}$WORK/d2
......
env GO111MODULE=off
# go command should detect package staleness as source file set changes # go command should detect package staleness as source file set changes
go install mypkg go install mypkg
! stale mypkg ! stale mypkg
......
env GO111MODULE=off
# check for linker name in error message about linker crash # check for linker name in error message about linker crash
[!gc] skip [!gc] skip
! go build -ldflags=-crash_for_testing x.go ! go build -ldflags=-crash_for_testing x.go
......
env GO111MODULE=off
# This test matches mod_list_bad_import, but in GOPATH mode. # This test matches mod_list_bad_import, but in GOPATH mode.
# Please keep them in sync. # Please keep them in sync.
......
env GO111MODULE=off
[!cgo] skip [!cgo] skip
# go list should report import "C" # go list should report import "C"
......
env GO111MODULE=off
# go list -find should not report imports # go list -find should not report imports
go list -f {{.Incomplete}} x/y/z... # should probably exit non-zero but never has go list -f {{.Incomplete}} x/y/z... # should probably exit non-zero but never has
......
env GO111MODULE=off
# gccgo does not have standard packages. # gccgo does not have standard packages.
[gccgo] skip [gccgo] skip
......
env GO111MODULE=off
[!gc] skip [!gc] skip
# listing GOROOT should only find standard packages # listing GOROOT should only find standard packages
......
env GO111MODULE=off
# go list supports -tags # go list supports -tags
go list -tags=thetag ./my... go list -tags=thetag ./my...
stdout mypkg stdout mypkg
......
env GO111MODULE=off
# issue 25980: crash in go list -e -test # issue 25980: crash in go list -e -test
go list -e -test -f '{{.Error}}' p go list -e -test -f '{{.Error}}' p
stdout '^p[/\\]d_test.go:2:8: cannot find package "d" in any of:' stdout '^p[/\\]d_test.go:2:8: cannot find package "d" in any of:'
......
env GO111MODULE=off
# issue 26880: list with tests has wrong variant in imports # issue 26880: list with tests has wrong variant in imports
go list -test -f '{{.ImportPath}}:{{with .Imports}} {{join . ", "}}{{end}}' a b go list -test -f '{{.ImportPath}}:{{with .Imports}} {{join . ", "}}{{end}}' a b
cmp stdout imports.txt cmp stdout imports.txt
......
env GO111MODULE=auto
# Derive module path from import comment. # Derive module path from import comment.
cd $WORK/x cd $WORK/x
exists x.go exists x.go
......
...@@ -7,14 +7,12 @@ env GO111MODULE=off ...@@ -7,14 +7,12 @@ env GO111MODULE=off
! exec $WORK/testimport.exe x/y/z/w . ! exec $WORK/testimport.exe x/y/z/w .
# GO111MODULE=auto in GOPATH/src # GO111MODULE=auto in GOPATH/src
env GO111MODULE=
! exec $WORK/testimport.exe x/y/z/w .
env GO111MODULE=auto env GO111MODULE=auto
! exec $WORK/testimport.exe x/y/z/w . ! exec $WORK/testimport.exe x/y/z/w .
# GO111MODULE=auto outside GOPATH/src # GO111MODULE=auto outside GOPATH/src
cd $GOPATH/other cd $GOPATH/other
env GO111MODULE= env GO111MODULE=auto
exec $WORK/testimport.exe other/x/y/z/w . exec $WORK/testimport.exe other/x/y/z/w .
stdout w2.go stdout w2.go
...@@ -22,7 +20,6 @@ stdout w2.go ...@@ -22,7 +20,6 @@ stdout w2.go
stderr 'cannot find module providing package x/y/z/w' stderr 'cannot find module providing package x/y/z/w'
cd z cd z
env GO111MODULE=auto
exec $WORK/testimport.exe other/x/y/z/w . exec $WORK/testimport.exe other/x/y/z/w .
stdout w2.go stdout w2.go
...@@ -33,6 +30,7 @@ stdout w2.go ...@@ -33,6 +30,7 @@ stdout w2.go
# GO111MODULE=on in GOPATH/src # GO111MODULE=on in GOPATH/src
cd $GOPATH/src cd $GOPATH/src
env GO111MODULE=on
exec $WORK/testimport.exe x/y/z/w . exec $WORK/testimport.exe x/y/z/w .
stdout w1.go stdout w1.go
cd w cd w
......
env GO111MODULE=off
# patterns match directories with syntax errors # patterns match directories with syntax errors
! go list ./... ! go list ./...
! go build ./... ! go build ./...
......
env GO111MODULE=off
# hello world # hello world
go run hello.go go run hello.go
stderr 'hello world' stderr 'hello world'
......
env GO111MODULE=off
# Fix for https://github.com/golang/go/issues/28696: # Fix for https://github.com/golang/go/issues/28696:
# go run x/... should not panic when directory x doesn't exist. # go run x/... should not panic when directory x doesn't exist.
......
env GO111MODULE=off
[!exec:echo] skip [!exec:echo] skip
[!exec:false] skip [!exec:false] skip
......
env GO111MODULE=off
! go test badtest/... ! go test badtest/...
! stdout ^ok ! stdout ^ok
stdout ^FAIL\tbadtest/badexec stdout ^FAIL\tbadtest/badexec
......
env GO111MODULE=off
! go test -c compile_binary/... ! go test -c compile_binary/...
stderr 'build comment' stderr 'build comment'
......
env GO111MODULE=off
# go test -c -o NUL # go test -c -o NUL
# should work (see golang.org/issue/28035). # should work (see golang.org/issue/28035).
cd x cd x
......
env GO111MODULE=off
# smoke test for complex build configuration # smoke test for complex build configuration
go build -o complex.exe complex go build -o complex.exe complex
[exec:gccgo] go build -compiler=gccgo -o complex.exe complex [exec:gccgo] go build -compiler=gccgo -o complex.exe complex
......
env GO111MODULE=off
# Issue 27665. Verify that "go vet" analyzes non-Go files. # Issue 27665. Verify that "go vet" analyzes non-Go files.
env GOOS=linux env GOOS=linux
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment