mirror of
https://github.com/golang/go
synced 2024-10-04 15:09:59 +00:00
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:
parent
cf155b00d1
commit
613f0a3144
|
@ -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+"=") {
|
||||
|
|
2
src/cmd/go/testdata/script/binary_only.txt
vendored
2
src/cmd/go/testdata/script/binary_only.txt
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Set up fresh GOCACHE.
|
||||
env GOCACHE=$WORK/gocache
|
||||
mkdir $GOCACHE
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Set up fresh GOCACHE.
|
||||
env GOCACHE=$WORK/gocache
|
||||
mkdir $GOCACHE
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Set up fresh GOCACHE.
|
||||
env GOCACHE=$WORK/gocache
|
||||
mkdir $GOCACHE
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[!gc] skip
|
||||
|
||||
# Set up fresh GOCACHE.
|
||||
|
|
2
src/cmd/go/testdata/script/build_nocache.txt
vendored
2
src/cmd/go/testdata/script/build_nocache.txt
vendored
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Regression test for golang.org/issue/21309: accept relative -pkgdir argument.
|
||||
|
||||
[short] skip
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# If GOTMPDIR is relative, 'go build' should derive an absolute $WORK directory.
|
||||
cd $WORK
|
||||
mkdir tmp
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Set up fresh GOCACHE.
|
||||
env GOCACHE=$WORK/gocache
|
||||
mkdir $GOCACHE
|
||||
|
|
2
src/cmd/go/testdata/script/cache_unix.txt
vendored
2
src/cmd/go/testdata/script/cache_unix.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Integration test for cache directory calculation (cmd/go/internal/cache).
|
||||
|
||||
[windows] skip
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# go clean -testcache
|
||||
# should work (see golang.org/issue/29757).
|
||||
cd x
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[short] skip
|
||||
|
||||
go test -coverpkg=all -covermode=atomic x
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Issue 23882
|
||||
|
||||
[short] skip
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Issue 23150
|
||||
|
||||
[short] skip
|
||||
|
|
2
src/cmd/go/testdata/script/fileline.txt
vendored
2
src/cmd/go/testdata/script/fileline.txt
vendored
|
@ -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:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[!gc] skip 'using -gcflags and -ldflags'
|
||||
|
||||
# -gcflags=-e applies to named packages, not dependencies
|
||||
|
|
2
src/cmd/go/testdata/script/get_brace.txt
vendored
2
src/cmd/go/testdata/script/get_brace.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[!exec:git] skip
|
||||
|
||||
# Set up some empty repositories.
|
||||
|
|
2
src/cmd/go/testdata/script/get_dotfiles.txt
vendored
2
src/cmd/go/testdata/script/get_dotfiles.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[!exec:git] skip
|
||||
|
||||
# Set up a benign repository and a repository with a dotfile name.
|
||||
|
|
2
src/cmd/go/testdata/script/get_tilde.txt
vendored
2
src/cmd/go/testdata/script/get_tilde.txt
vendored
|
@ -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'
|
||||
|
|
2
src/cmd/go/testdata/script/get_unicode.txt
vendored
2
src/cmd/go/testdata/script/get_unicode.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[!exec:git] skip
|
||||
|
||||
# Construct a repository that imports a non-ASCII path.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
env GIT_TRACE=1
|
||||
|
||||
[!net] skip
|
||||
|
|
2
src/cmd/go/testdata/script/goflags.txt
vendored
2
src/cmd/go/testdata/script/goflags.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# GOFLAGS sets flags for commands
|
||||
|
||||
env GOFLAGS='-e -f={{.Dir}} --test.benchtime=1s -count=10'
|
||||
|
|
2
src/cmd/go/testdata/script/help.txt
vendored
2
src/cmd/go/testdata/script/help.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# go help shows overview.
|
||||
go help
|
||||
stdout 'Go is a tool'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# 'go install' with no arguments should clean up after go build
|
||||
cd mycmd
|
||||
go build
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
cd mycmd
|
||||
go build mycmd
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# GOPATH with p1 in d1, p2 in d2
|
||||
env GOPATH=$WORK/d1${:}$WORK/d2
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# go command should detect package staleness as source file set changes
|
||||
go install mypkg
|
||||
! stale mypkg
|
||||
|
|
2
src/cmd/go/testdata/script/linkname.txt
vendored
2
src/cmd/go/testdata/script/linkname.txt
vendored
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# This test matches mod_list_bad_import, but in GOPATH mode.
|
||||
# Please keep them in sync.
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[!cgo] skip
|
||||
|
||||
# go list should report import "C"
|
||||
|
|
2
src/cmd/go/testdata/script/list_find.txt
vendored
2
src/cmd/go/testdata/script/list_find.txt
vendored
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# gccgo does not have standard packages.
|
||||
[gccgo] skip
|
||||
|
||||
|
|
2
src/cmd/go/testdata/script/list_std.txt
vendored
2
src/cmd/go/testdata/script/list_std.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[!gc] skip
|
||||
|
||||
# listing GOROOT should only find standard packages
|
||||
|
|
2
src/cmd/go/testdata/script/list_tags.txt
vendored
2
src/cmd/go/testdata/script/list_tags.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# go list supports -tags
|
||||
go list -tags=thetag ./my...
|
||||
stdout mypkg
|
||||
|
|
2
src/cmd/go/testdata/script/list_test_e.txt
vendored
2
src/cmd/go/testdata/script/list_test_e.txt
vendored
|
@ -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:'
|
||||
|
|
|
@ -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
|
||||
|
|
2
src/cmd/go/testdata/script/mod_find.txt
vendored
2
src/cmd/go/testdata/script/mod_find.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=auto
|
||||
|
||||
# Derive module path from import comment.
|
||||
cd $WORK/x
|
||||
exists x.go
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# patterns match directories with syntax errors
|
||||
! go list ./...
|
||||
! go build ./...
|
||||
|
|
2
src/cmd/go/testdata/script/run_hello.txt
vendored
2
src/cmd/go/testdata/script/run_hello.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# hello world
|
||||
go run hello.go
|
||||
stderr 'hello world'
|
||||
|
|
2
src/cmd/go/testdata/script/run_wildcard.txt
vendored
2
src/cmd/go/testdata/script/run_wildcard.txt
vendored
|
@ -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.
|
||||
|
||||
|
|
2
src/cmd/go/testdata/script/script_wait.txt
vendored
2
src/cmd/go/testdata/script/script_wait.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
[!exec:echo] skip
|
||||
[!exec:false] skip
|
||||
|
||||
|
|
2
src/cmd/go/testdata/script/test_badtest.txt
vendored
2
src/cmd/go/testdata/script/test_badtest.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
! go test badtest/...
|
||||
! stdout ^ok
|
||||
stdout ^FAIL\tbadtest/badexec
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
! go test -c compile_binary/...
|
||||
stderr 'build comment'
|
||||
|
||||
|
|
2
src/cmd/go/testdata/script/test_devnull.txt
vendored
2
src/cmd/go/testdata/script/test_devnull.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# go test -c -o NUL
|
||||
# should work (see golang.org/issue/28035).
|
||||
cd x
|
||||
|
|
|
@ -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
|
||||
|
|
2
src/cmd/go/testdata/script/vet_asm.txt
vendored
2
src/cmd/go/testdata/script/vet_asm.txt
vendored
|
@ -1,3 +1,5 @@
|
|||
env GO111MODULE=off
|
||||
|
||||
# Issue 27665. Verify that "go vet" analyzes non-Go files.
|
||||
|
||||
env GOOS=linux
|
||||
|
|
Loading…
Reference in a new issue