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: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Bryan C. Mills 2019-02-13 15:06:46 -05:00
parent cf155b00d1
commit 613f0a3144
50 changed files with 99 additions and 4 deletions

View file

@ -394,6 +394,7 @@ func (tg *testgoData) setenv(name, val string) {
func (tg *testgoData) unsetenv(name string) {
if tg.env == nil {
tg.env = append([]string(nil), os.Environ()...)
tg.env = append(tg.env, "GO111MODULE=off")
}
for i, v := range tg.env {
if strings.HasPrefix(v, name+"=") {

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# check that error for missing binary-only says where it should be
! go build b
stderr pkg[\\/].*a\.a

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Set GOCACHE to a clean directory to ensure that 'go build' has work to report.
env GOCACHE=$WORK/gocache

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[!gc] skip
# Set up fresh GOCACHE.

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# 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

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Regression test for golang.org/issue/21309: accept relative -pkgdir argument.
[short] skip

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# If GOTMPDIR is relative, 'go build' should derive an absolute $WORK directory.
cd $WORK
mkdir tmp

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Integration test for cache directory calculation (cmd/go/internal/cache).
[windows] skip

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# This test tests that we can link in-package syso files that provides symbols
# for cgo. See issue 29253.
[!cgo] stop

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# go clean -testcache
# should work (see golang.org/issue/29757).
cd x

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[short] skip
go test -coverpkg=all -covermode=atomic x

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Issue 23882
[short] skip

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Issue 23150
[short] skip

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# look for short, relative file:line in error message
! go run ../../gopath/x/y/z/err.go
stderr ^..[\\/]x[\\/]y[\\/]z[\\/]err.go:

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[!gc] skip 'using -gcflags and -ldflags'
# -gcflags=-e applies to named packages, not dependencies

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[!exec:git] skip
# Set up some empty repositories.

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[!exec:git] skip
# Set up a benign repository and a repository with a dotfile name.

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Paths containing windows short names should be rejected before attempting to fetch.
! go get example.com/longna~1.dir/thing
stderr 'trailing tilde and digits'

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[!exec:git] skip
# Construct a repository that imports a non-ASCII path.

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
env GIT_TRACE=1
[!net] skip

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# GOFLAGS sets flags for commands
env GOFLAGS='-e -f={{.Dir}} --test.benchtime=1s -count=10'

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# go help shows overview.
go help
stdout 'Go is a tool'

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# 'go install' with no arguments should clean up after go build
cd mycmd
go build

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
cd mycmd
go build mycmd

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# GOPATH with p1 in d1, p2 in d2
env GOPATH=$WORK/d1${:}$WORK/d2

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# go command should detect package staleness as source file set changes
go install mypkg
! stale mypkg

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# check for linker name in error message about linker crash
[!gc] skip
! go build -ldflags=-crash_for_testing x.go

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# This test matches mod_list_bad_import, but in GOPATH mode.
# Please keep them in sync.

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[!cgo] skip
# go list should report import "C"

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# go list -find should not report imports
go list -f {{.Incomplete}} x/y/z... # should probably exit non-zero but never has

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# gccgo does not have standard packages.
[gccgo] skip

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[!gc] skip
# listing GOROOT should only find standard packages

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# go list supports -tags
go list -tags=thetag ./my...
stdout mypkg

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# issue 25980: crash in go list -e -test
go list -e -test -f '{{.Error}}' p
stdout '^p[/\\]d_test.go:2:8: cannot find package "d" in any of:'

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# issue 26880: list with tests has wrong variant in imports
go list -test -f '{{.ImportPath}}:{{with .Imports}} {{join . ", "}}{{end}}' a b
cmp stdout imports.txt

View file

@ -1,3 +1,5 @@
env GO111MODULE=auto
# Derive module path from import comment.
cd $WORK/x
exists x.go

View file

@ -7,14 +7,12 @@ env GO111MODULE=off
! exec $WORK/testimport.exe x/y/z/w .
# GO111MODULE=auto in GOPATH/src
env GO111MODULE=
! exec $WORK/testimport.exe x/y/z/w .
env GO111MODULE=auto
! exec $WORK/testimport.exe x/y/z/w .
# GO111MODULE=auto outside GOPATH/src
cd $GOPATH/other
env GO111MODULE=
env GO111MODULE=auto
exec $WORK/testimport.exe other/x/y/z/w .
stdout w2.go
@ -22,7 +20,6 @@ stdout w2.go
stderr 'cannot find module providing package x/y/z/w'
cd z
env GO111MODULE=auto
exec $WORK/testimport.exe other/x/y/z/w .
stdout w2.go
@ -33,6 +30,7 @@ stdout w2.go
# GO111MODULE=on in GOPATH/src
cd $GOPATH/src
env GO111MODULE=on
exec $WORK/testimport.exe x/y/z/w .
stdout w1.go
cd w

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# patterns match directories with syntax errors
! go list ./...
! go build ./...

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# hello world
go run hello.go
stderr 'hello world'

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Fix for https://github.com/golang/go/issues/28696:
# go run x/... should not panic when directory x doesn't exist.

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
[!exec:echo] skip
[!exec:false] skip

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
! go test badtest/...
! stdout ^ok
stdout ^FAIL\tbadtest/badexec

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
! go test -c compile_binary/...
stderr 'build comment'

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# go test -c -o NUL
# should work (see golang.org/issue/28035).
cd x

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# smoke test for complex build configuration
go build -o complex.exe complex
[exec:gccgo] go build -compiler=gccgo -o complex.exe complex

View file

@ -1,3 +1,5 @@
env GO111MODULE=off
# Issue 27665. Verify that "go vet" analyzes non-Go files.
env GOOS=linux