Skip to content

Commit 613f0a3

Browse files
author
Bryan C. Mills
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent cf155b0 commit 613f0a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+99
-4
lines changed

src/cmd/go/go_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ func (tg *testgoData) setenv(name, val string) {
394394
func (tg *testgoData) unsetenv(name string) {
395395
if tg.env == nil {
396396
tg.env = append([]string(nil), os.Environ()...)
397+
tg.env = append(tg.env, "GO111MODULE=off")
397398
}
398399
for i, v := range tg.env {
399400
if strings.HasPrefix(v, name+"=") {

src/cmd/go/testdata/script/binary_only.txt

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

src/cmd/go/testdata/script/build_GOTMPDIR.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Set GOCACHE to a clean directory to ensure that 'go build' has work to report.
24
env GOCACHE=$WORK/gocache
35

src/cmd/go/testdata/script/build_cache_compile.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Set up fresh GOCACHE.
24
env GOCACHE=$WORK/gocache
35
mkdir $GOCACHE

src/cmd/go/testdata/script/build_cache_gomips.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Set up fresh GOCACHE.
24
env GOCACHE=$WORK/gocache
35
mkdir $GOCACHE

src/cmd/go/testdata/script/build_cache_link.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Set up fresh GOCACHE.
24
env GOCACHE=$WORK/gocache
35
mkdir $GOCACHE

src/cmd/go/testdata/script/build_cache_output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[!gc] skip
24

35
# Set up fresh GOCACHE.

src/cmd/go/testdata/script/build_nocache.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# As of Go 1.12, the module cache is required.
24

35
# If none of the variables we use to locate GOCACHE are set, the cache is off

src/cmd/go/testdata/script/build_relative_pkgdir.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Regression test for golang.org/issue/21309: accept relative -pkgdir argument.
24

35
[short] skip

src/cmd/go/testdata/script/build_relative_tmpdir.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# If GOTMPDIR is relative, 'go build' should derive an absolute $WORK directory.
24
cd $WORK
35
mkdir tmp

src/cmd/go/testdata/script/build_runtime_gcflags.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Set up fresh GOCACHE.
24
env GOCACHE=$WORK/gocache
35
mkdir $GOCACHE

src/cmd/go/testdata/script/cache_unix.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Integration test for cache directory calculation (cmd/go/internal/cache).
24

35
[windows] skip

src/cmd/go/testdata/script/cgo_syso_issue29253.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# This test tests that we can link in-package syso files that provides symbols
24
# for cgo. See issue 29253.
35
[!cgo] stop

src/cmd/go/testdata/script/clean_testcache.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# go clean -testcache
24
# should work (see golang.org/issue/29757).
35
cd x

src/cmd/go/testdata/script/cover_atomic_pkgall.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[short] skip
24

35
go test -coverpkg=all -covermode=atomic x

src/cmd/go/testdata/script/cover_pkgall_runtime.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Issue 23882
24

35
[short] skip

src/cmd/go/testdata/script/cpu_profile_twice.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Issue 23150
24

35
[short] skip

src/cmd/go/testdata/script/fileline.txt

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

src/cmd/go/testdata/script/gcflags_patterns.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[!gc] skip 'using -gcflags and -ldflags'
24

35
# -gcflags=-e applies to named packages, not dependencies

src/cmd/go/testdata/script/get_brace.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[!exec:git] skip
24

35
# Set up some empty repositories.

src/cmd/go/testdata/script/get_dotfiles.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[!exec:git] skip
24

35
# Set up a benign repository and a repository with a dotfile name.

src/cmd/go/testdata/script/get_tilde.txt

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

src/cmd/go/testdata/script/get_unicode.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[!exec:git] skip
24

35
# Construct a repository that imports a non-ASCII path.

src/cmd/go/testdata/script/get_with_git_trace.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
env GIT_TRACE=1
24

35
[!net] skip

src/cmd/go/testdata/script/goflags.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# GOFLAGS sets flags for commands
24

35
env GOFLAGS='-e -f={{.Dir}} --test.benchtime=1s -count=10'

src/cmd/go/testdata/script/help.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# go help shows overview.
24
go help
35
stdout 'Go is a tool'

src/cmd/go/testdata/script/install_cleans_build.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# 'go install' with no arguments should clean up after go build
24
cd mycmd
35
go build

src/cmd/go/testdata/script/install_cross_gobin.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
cd mycmd
24
go build mycmd
35

src/cmd/go/testdata/script/install_rebuild_gopath.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# GOPATH with p1 in d1, p2 in d2
24
env GOPATH=$WORK/d1${:}$WORK/d2
35

src/cmd/go/testdata/script/install_rebuild_removed.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# go command should detect package staleness as source file set changes
24
go install mypkg
35
! stale mypkg

src/cmd/go/testdata/script/linkname.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# check for linker name in error message about linker crash
24
[!gc] skip
35
! go build -ldflags=-crash_for_testing x.go

src/cmd/go/testdata/script/list_bad_import.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# This test matches mod_list_bad_import, but in GOPATH mode.
24
# Please keep them in sync.
35

src/cmd/go/testdata/script/list_compiled_imports.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[!cgo] skip
24

35
# go list should report import "C"

src/cmd/go/testdata/script/list_find.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# go list -find should not report imports
24

35
go list -f {{.Incomplete}} x/y/z... # should probably exit non-zero but never has

src/cmd/go/testdata/script/list_importmap.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# gccgo does not have standard packages.
24
[gccgo] skip
35

src/cmd/go/testdata/script/list_std.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[!gc] skip
24

35
# listing GOROOT should only find standard packages

src/cmd/go/testdata/script/list_tags.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# go list supports -tags
24
go list -tags=thetag ./my...
35
stdout mypkg

src/cmd/go/testdata/script/list_test_e.txt

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

src/cmd/go/testdata/script/list_test_imports.txt

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

src/cmd/go/testdata/script/mod_find.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=auto
2+
13
# Derive module path from import comment.
24
cd $WORK/x
35
exists x.go

src/cmd/go/testdata/script/mod_gobuild_import.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,19 @@ env GO111MODULE=off
77
! exec $WORK/testimport.exe x/y/z/w .
88

99
# GO111MODULE=auto in GOPATH/src
10-
env GO111MODULE=
11-
! exec $WORK/testimport.exe x/y/z/w .
1210
env GO111MODULE=auto
1311
! exec $WORK/testimport.exe x/y/z/w .
1412

1513
# GO111MODULE=auto outside GOPATH/src
1614
cd $GOPATH/other
17-
env GO111MODULE=
15+
env GO111MODULE=auto
1816
exec $WORK/testimport.exe other/x/y/z/w .
1917
stdout w2.go
2018

2119
! exec $WORK/testimport.exe x/y/z/w .
2220
stderr 'cannot find module providing package x/y/z/w'
2321

2422
cd z
25-
env GO111MODULE=auto
2623
exec $WORK/testimport.exe other/x/y/z/w .
2724
stdout w2.go
2825

@@ -33,6 +30,7 @@ stdout w2.go
3330

3431
# GO111MODULE=on in GOPATH/src
3532
cd $GOPATH/src
33+
env GO111MODULE=on
3634
exec $WORK/testimport.exe x/y/z/w .
3735
stdout w1.go
3836
cd w

src/cmd/go/testdata/script/pattern_syntax_error.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# patterns match directories with syntax errors
24
! go list ./...
35
! go build ./...

src/cmd/go/testdata/script/run_hello.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# hello world
24
go run hello.go
35
stderr 'hello world'

src/cmd/go/testdata/script/run_wildcard.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Fix for https://github.com/golang/go/issues/28696:
24
# go run x/... should not panic when directory x doesn't exist.
35

src/cmd/go/testdata/script/script_wait.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
[!exec:echo] skip
24
[!exec:false] skip
35

src/cmd/go/testdata/script/test_badtest.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
! go test badtest/...
24
! stdout ^ok
35
stdout ^FAIL\tbadtest/badexec

src/cmd/go/testdata/script/test_compile_binary.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
! go test -c compile_binary/...
24
stderr 'build comment'
35

src/cmd/go/testdata/script/test_devnull.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# go test -c -o NUL
24
# should work (see golang.org/issue/28035).
35
cd x

src/cmd/go/testdata/script/vendor_complex.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# smoke test for complex build configuration
24
go build -o complex.exe complex
35
[exec:gccgo] go build -compiler=gccgo -o complex.exe complex

src/cmd/go/testdata/script/vet_asm.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
env GO111MODULE=off
2+
13
# Issue 27665. Verify that "go vet" analyzes non-Go files.
24

35
env GOOS=linux

0 commit comments

Comments
 (0)