Skip to content

Commit

Permalink
cmd/go: set GO111MODULE=off explicitly in tests that assume GOPATH mode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bryan C. Mills committed Feb 19, 2019
1 parent cf155b0 commit 613f0a3
Show file tree
Hide file tree
Showing 50 changed files with 99 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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+"=") {
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/binary_only.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_GOTMPDIR.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_cache_compile.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_cache_gomips.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_cache_link.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_cache_output.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[!gc] skip

# Set up fresh GOCACHE.
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_nocache.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_relative_pkgdir.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Regression test for golang.org/issue/21309: accept relative -pkgdir argument.

[short] skip
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_relative_tmpdir.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# If GOTMPDIR is relative, 'go build' should derive an absolute $WORK directory.
cd $WORK
mkdir tmp
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/build_runtime_gcflags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/cache_unix.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Integration test for cache directory calculation (cmd/go/internal/cache).

[windows] skip
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/cgo_syso_issue29253.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/clean_testcache.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# go clean -testcache
# should work (see golang.org/issue/29757).
cd x
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/cover_atomic_pkgall.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[short] skip

go test -coverpkg=all -covermode=atomic x
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/cover_pkgall_runtime.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Issue 23882

[short] skip
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/cpu_profile_twice.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Issue 23150

[short] skip
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/fileline.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/gcflags_patterns.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[!gc] skip 'using -gcflags and -ldflags'

# -gcflags=-e applies to named packages, not dependencies
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/get_brace.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[!exec:git] skip

# Set up some empty repositories.
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/get_dotfiles.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[!exec:git] skip

# Set up a benign repository and a repository with a dotfile name.
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/get_tilde.txt
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/get_unicode.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[!exec:git] skip

# Construct a repository that imports a non-ASCII path.
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/get_with_git_trace.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

env GIT_TRACE=1

[!net] skip
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/goflags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# GOFLAGS sets flags for commands

env GOFLAGS='-e -f={{.Dir}} --test.benchtime=1s -count=10'
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/help.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# go help shows overview.
go help
stdout 'Go is a tool'
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/install_cleans_build.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# 'go install' with no arguments should clean up after go build
cd mycmd
go build
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/install_cross_gobin.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

cd mycmd
go build mycmd

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/install_rebuild_gopath.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# GOPATH with p1 in d1, p2 in d2
env GOPATH=$WORK/d1${:}$WORK/d2

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/install_rebuild_removed.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# go command should detect package staleness as source file set changes
go install mypkg
! stale mypkg
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/linkname.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/list_bad_import.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# This test matches mod_list_bad_import, but in GOPATH mode.
# Please keep them in sync.

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/list_compiled_imports.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[!cgo] skip

# go list should report import "C"
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/list_find.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/list_importmap.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# gccgo does not have standard packages.
[gccgo] skip

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/list_std.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[!gc] skip

# listing GOROOT should only find standard packages
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/list_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# go list supports -tags
go list -tags=thetag ./my...
stdout mypkg
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/list_test_e.txt
Original file line number Diff line number Diff line change
@@ -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:'
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/list_test_imports.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/mod_find.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=auto

# Derive module path from import comment.
cd $WORK/x
exists x.go
Expand Down
6 changes: 2 additions & 4 deletions src/cmd/go/testdata/script/mod_gobuild_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ 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

! exec $WORK/testimport.exe x/y/z/w .
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

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/pattern_syntax_error.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# patterns match directories with syntax errors
! go list ./...
! go build ./...
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/run_hello.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# hello world
go run hello.go
stderr 'hello world'
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/run_wildcard.txt
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/script_wait.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

[!exec:echo] skip
[!exec:false] skip

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/test_badtest.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

! go test badtest/...
! stdout ^ok
stdout ^FAIL\tbadtest/badexec
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/test_compile_binary.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

! go test -c compile_binary/...
stderr 'build comment'

Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/test_devnull.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# go test -c -o NUL
# should work (see golang.org/issue/28035).
cd x
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/vendor_complex.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/go/testdata/script/vet_asm.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env GO111MODULE=off

# Issue 27665. Verify that "go vet" analyzes non-Go files.

env GOOS=linux
Expand Down

0 comments on commit 613f0a3

Please sign in to comment.