]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: prepare tests for GO111MODULE=on by default
authorJay Conrod <jayconrod@google.com>
Tue, 15 Sep 2020 16:59:05 +0000 (12:59 -0400)
committerJay Conrod <jayconrod@google.com>
Thu, 17 Sep 2020 13:25:29 +0000 (13:25 +0000)
Set GO111MODULE=off explicitly in tests specific to GOPATH mode.

Added a go.mod file to other tests that assumed GOPATH mode.

Fixed an issue in the build metadata file generated in
modload/build.go, which did not end with a newline. This broke the
build_dash_x test, which expects to be able to run the script printed
by 'go build -x' to produce the same result. The script is broken if
the build metadata file doesn't end with a newline.

Change-Id: I59f2a492a9f5a66f6c4aa702f429909d5c5e815d
Reviewed-on: https://go-review.googlesource.com/c/go/+/255051
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>

106 files changed:
src/cmd/go/internal/modload/build.go
src/cmd/go/testdata/script/build_cache_arch_mode.txt
src/cmd/go/testdata/script/build_cache_disabled.txt
src/cmd/go/testdata/script/build_cd_gopath_different.txt
src/cmd/go/testdata/script/build_cgo_consistent_results.txt
src/cmd/go/testdata/script/build_dash_x.txt
src/cmd/go/testdata/script/build_exe.txt
src/cmd/go/testdata/script/build_gopath_order.txt
src/cmd/go/testdata/script/build_import_comment.txt
src/cmd/go/testdata/script/build_import_cycle.txt
src/cmd/go/testdata/script/build_internal.txt
src/cmd/go/testdata/script/build_issue6480.txt
src/cmd/go/testdata/script/build_link_x_import_path_escape.txt
src/cmd/go/testdata/script/build_n_cgo.txt
src/cmd/go/testdata/script/build_no_go.txt
src/cmd/go/testdata/script/build_output.txt
src/cmd/go/testdata/script/build_patterns_outside_gopath.txt
src/cmd/go/testdata/script/build_plugin_non_main.txt
src/cmd/go/testdata/script/build_test_only.txt
src/cmd/go/testdata/script/build_vendor.txt
src/cmd/go/testdata/script/cgo_asm_error.txt
src/cmd/go/testdata/script/cgo_bad_directives.txt
src/cmd/go/testdata/script/cgo_depends_on_syscall.txt
src/cmd/go/testdata/script/cover_asm.txt
src/cmd/go/testdata/script/cover_blank_func_decl.txt
src/cmd/go/testdata/script/cover_cgo.txt
src/cmd/go/testdata/script/cover_cgo_extra_file.txt
src/cmd/go/testdata/script/cover_cgo_extra_test.txt
src/cmd/go/testdata/script/cover_cgo_xtest.txt
src/cmd/go/testdata/script/cover_dash_c.txt
src/cmd/go/testdata/script/cover_dep_loop.txt
src/cmd/go/testdata/script/cover_dot_import.txt
src/cmd/go/testdata/script/cover_error.txt
src/cmd/go/testdata/script/cover_import_main_loop.txt
src/cmd/go/testdata/script/cover_pattern.txt
src/cmd/go/testdata/script/cover_statements.txt
src/cmd/go/testdata/script/cover_sync_atomic_import.txt
src/cmd/go/testdata/script/generate_bad_imports.txt
src/cmd/go/testdata/script/generate_invalid.txt
src/cmd/go/testdata/script/get_custom_domain_wildcard.txt
src/cmd/go/testdata/script/get_dash_t.txt
src/cmd/go/testdata/script/get_domain_root.txt
src/cmd/go/testdata/script/get_dot_slash_download.txt
src/cmd/go/testdata/script/get_goroot.txt
src/cmd/go/testdata/script/get_insecure_custom_domain.txt
src/cmd/go/testdata/script/get_insecure_update.txt
src/cmd/go/testdata/script/get_internal_wildcard.txt
src/cmd/go/testdata/script/get_issue11307.txt
src/cmd/go/testdata/script/get_legacy.txt [moved from src/cmd/go/testdata/script/mod_get_legacy.txt with 97% similarity]
src/cmd/go/testdata/script/get_race.txt
src/cmd/go/testdata/script/get_test_only.txt
src/cmd/go/testdata/script/get_update.txt
src/cmd/go/testdata/script/get_update_unknown_protocol.txt
src/cmd/go/testdata/script/get_update_wildcard.txt
src/cmd/go/testdata/script/get_vcs_error_message.txt
src/cmd/go/testdata/script/get_vendor.txt
src/cmd/go/testdata/script/gopath_vendor_dup_err.txt
src/cmd/go/testdata/script/install_cgo_excluded.txt
src/cmd/go/testdata/script/install_relative_gobin_fail.txt
src/cmd/go/testdata/script/install_shadow_gopath.txt
src/cmd/go/testdata/script/link_syso_issue33139.txt
src/cmd/go/testdata/script/list_case_collision.txt
src/cmd/go/testdata/script/list_dedup_packages.txt
src/cmd/go/testdata/script/list_symlink.txt
src/cmd/go/testdata/script/list_symlink_internal.txt
src/cmd/go/testdata/script/list_symlink_vendor_issue14054.txt
src/cmd/go/testdata/script/list_symlink_vendor_issue15201.txt
src/cmd/go/testdata/script/list_test_simple.txt
src/cmd/go/testdata/script/list_wildcard_skip_nonmatching.txt
src/cmd/go/testdata/script/load_test_pkg_err.txt
src/cmd/go/testdata/script/run_hello_pkg.txt
src/cmd/go/testdata/script/run_vendor.txt
src/cmd/go/testdata/script/test_benchmark_fatal.txt
src/cmd/go/testdata/script/test_benchmark_labels.txt
src/cmd/go/testdata/script/test_build_failure.txt
src/cmd/go/testdata/script/test_deadline.txt
src/cmd/go/testdata/script/test_empty.txt
src/cmd/go/testdata/script/test_example_goexit.txt
src/cmd/go/testdata/script/test_import_error_stack.txt
src/cmd/go/testdata/script/test_json.txt
src/cmd/go/testdata/script/test_main_twice.txt
src/cmd/go/testdata/script/test_match_no_tests_build_failure.txt
src/cmd/go/testdata/script/test_no_run_example.txt
src/cmd/go/testdata/script/test_no_tests.txt
src/cmd/go/testdata/script/test_race.txt
src/cmd/go/testdata/script/test_race_cover_mode_issue20435.txt
src/cmd/go/testdata/script/test_race_install.txt
src/cmd/go/testdata/script/test_race_install_cgo.txt
src/cmd/go/testdata/script/test_regexps.txt
src/cmd/go/testdata/script/test_relative_import.txt
src/cmd/go/testdata/script/test_relative_import_dash_i.txt
src/cmd/go/testdata/script/test_syntax_error_says_fail.txt
src/cmd/go/testdata/script/test_vendor.txt
src/cmd/go/testdata/script/test_vet.txt
src/cmd/go/testdata/script/test_write_profiles_on_timeout.txt
src/cmd/go/testdata/script/test_xtestonly_works.txt
src/cmd/go/testdata/script/testing_issue40908.txt
src/cmd/go/testdata/script/vendor_gopath_issue11409.txt
src/cmd/go/testdata/script/vendor_import.txt
src/cmd/go/testdata/script/vendor_import_wrong.txt
src/cmd/go/testdata/script/vendor_issue12156.txt
src/cmd/go/testdata/script/vendor_list_issue11977.txt
src/cmd/go/testdata/script/vendor_resolve.txt
src/cmd/go/testdata/script/vendor_test_issue11864.txt
src/cmd/go/testdata/script/vendor_test_issue14613.txt
src/cmd/go/testdata/script/vet.txt

index 9ca6230500e3ef6c7bc9f091cc1f9dcb9eac7675..2c7cfb732d96cc6b4555a98be9a2d30eac97cd4e 100644 (file)
@@ -355,13 +355,13 @@ func ModInfoProg(info string, isgccgo bool) []byte {
 import _ "unsafe"
 //go:linkname __debug_modinfo__ runtime.modinfo
 var __debug_modinfo__ = %q
-       `, string(infoStart)+info+string(infoEnd)))
+`, string(infoStart)+info+string(infoEnd)))
        } else {
                return []byte(fmt.Sprintf(`package main
 import _ "unsafe"
 //go:linkname __set_debug_modinfo__ runtime.setmodinfo
 func __set_debug_modinfo__(string)
 func init() { __set_debug_modinfo__(%q) }
-       `, string(infoStart)+info+string(infoEnd)))
+`, string(infoStart)+info+string(infoEnd)))
        }
 }
index 7e751d02b9bfed53b14bb34c86dbe24dd8ddf294..68e662555f95b72a3f62a6a655c322125d98118c 100644 (file)
@@ -3,7 +3,6 @@
 [short] skip
 
 # 386
-cd $GOPATH/src/mycmd
 env GOOS=linux
 env GOARCH=386
 env GO386=387
@@ -12,7 +11,6 @@ env GO386=sse2
 stale mycmd
 
 # arm
-cd $GOPATH/src/mycmd
 env GOOS=linux
 env GOARCH=arm
 env GOARM=5
@@ -21,7 +19,11 @@ env GOARM=7
 stale mycmd
 
 
--- mycmd/x.go --
+-- go.mod --
+module mycmd
+
+go 1.16
+-- x.go --
 package main
 
-func main() {}
\ No newline at end of file
+func main() {}
index 2e1327880b49f24de6e5cc80c407475fcaab7081..8b005c857fcf99dd89fda7ef752cf13b52864471 100644 (file)
@@ -18,8 +18,6 @@ env GOCACHE=off
 go doc fmt
 stdout Printf
 
-go fmt .
-
 ! go tool compile -h
 stderr usage:
 
@@ -40,6 +38,12 @@ stdout rsc.io/quote
 
 go mod verify
 
+
+# Commands that load but don't build packages should work.
+go fmt .
+
+go doc .
+
 -- main.go --
 package main
 
index 698b3d70f4b332ed41e9ece7485181043dfd1da9..a7a4bf412d0c11399ead394381707138111bce61 100644 (file)
@@ -1,4 +1,5 @@
 [gccgo] skip 'gccgo does not support -ldflags -X'
+env GO111MODULE=off
 go build run_go.go
 
 # Apply identity function to GOPATH
index 42f1cc1a747bc1301be53c8dad058a7683467062..88a24de81478408ea807b1f1846680dc06627602 100644 (file)
@@ -11,7 +11,11 @@ go build -x -o $WORK/exe2$GOEXE cgotest
 
 cmp $WORK/exe1$GOEXE $WORK/exe2$GOEXE
 
--- cgotest/m.go --
+-- go.mod --
+module cgotest
+
+go 1.16
+-- m.go --
 package cgotest
 
 import "C"
index 3082095c5c4a94070338bba13c9e0bb394ad84c4..6fd5bbe182bfd45d7b42c299d65e1cde11c1e95a 100644 (file)
@@ -46,4 +46,4 @@ func main() {
 -- header.txt --
 set -e
 -- hello.txt --
-hello
\ No newline at end of file
+hello
index fd13259fcc716fb903f5fe6b29b5c7477952a361..a994d170884d64a5d0badecbb9d3e4031236b219 100644 (file)
@@ -1,12 +1,16 @@
-# go build with -o and -buildmode=exe should on a non-main package should throw an error
+# go build with -o and -buildmode=exe should report an error on a non-main package.
 
-! go build -buildmode=exe -o out$GOEXE not_main
+! go build -buildmode=exe -o out$GOEXE ./not_main
 stderr '-buildmode=exe requires exactly one main package'
 ! exists out$GOEXE
-! go build -buildmode=exe -o out$GOEXE main_one main_two
+! go build -buildmode=exe -o out$GOEXE ./main_one ./main_two
 stderr '-buildmode=exe requires exactly one main package'
 ! exists out$GOEXE
 
+-- go.mod --
+module m
+
+go 1.16
 -- not_main/not_main.go --
 package not_main
 
@@ -18,4 +22,4 @@ func main() {}
 -- main_two/main_two.go --
 package main
 
-func main() {}
\ No newline at end of file
+func main() {}
index ac26c28a9f2e3ca7859252b511ebcd2efcda88ad..caf25022e4cdd94ab9f9f83a47261d5bd56886c6 100644 (file)
@@ -3,6 +3,7 @@
 # -I arguments to compiler could end up not in GOPATH order,
 # leading to unexpected import resolution in the compiler.
 
+env GO111MODULE=off
 env GOPATH=$WORK/p1${:}$WORK/p2
 mkdir $WORK/p1/src/foo $WORK/p2/src/baz
 mkdir $WORK/p2/pkg/${GOOS}_${GOARCH} $WORK/p1/src/bar
@@ -32,4 +33,4 @@ bad
 -- bar.go --
 package bar
 import _ "baz"
-import _ "foo"
\ No newline at end of file
+import _ "foo"
index 0ab643914d117c403fafb27d3f7f966b90620a9c..b500340bfb48b6e0405702caa67d7cb267d8bec3 100644 (file)
@@ -1,6 +1,6 @@
-# TODO: add a go.mod file and test with GO111MODULE explicitly on and off.
-# We only report the 'expects import' error when modules are disabled.
-# Do we report comment parse errors or conflicts in module mode? We shouldn't.
+# Test in GOPATH mode first.
+env GO111MODULE=off
+cd m
 
 # Import comment matches
 go build -n works.go
@@ -17,31 +17,52 @@ stderr 'cannot parse import comment'
 ! go build -n conflict.go
 stderr 'found import comments'
 
--- bad.go --
+
+# Test in module mode.
+# We ignore import comments, so these commands should succeed.
+env GO111MODULE=on
+
+# Import comment matches
+go build -n works.go
+
+# Import comment mismatch
+go build -n wrongplace.go
+
+# Import comment syntax error
+go build -n bad.go
+
+# Import comment conflict
+go build -n conflict.go
+
+-- m/go.mod --
+module m
+
+go 1.16
+-- m/bad.go --
 package p
 
-import "bad"
--- conflict.go --
+import "m/bad"
+-- m/conflict.go --
 package p
 
-import "conflict"
--- works.go --
+import "m/conflict"
+-- m/works.go --
 package p
 
-import _ "works/x"
--- wrongplace.go --
+import _ "m/works/x"
+-- m/wrongplace.go --
 package p
 
-import "wrongplace"
--- bad/bad.go --
+import "m/wrongplace"
+-- m/bad/bad.go --
 package bad // import
--- conflict/a.go --
+-- m/conflict/a.go --
 package conflict // import "a"
--- conflict/b.go --
+-- m/conflict/b.go --
 package conflict /* import "b" */
--- works/x/x.go --
-package x // import "works/x"
--- works/x/x1.go --
+-- m/works/x/x.go --
+package x // import "m/works/x"
+-- m/works/x/x1.go --
 package x // important! not an import comment
--- wrongplace/x.go --
+-- m/wrongplace/x.go --
 package x // import "my/x"
index 0154305c275e2faaa43c665764cb84ab654b418b..16e4e87daeeeae113061b4c62bb28dd389bd273e 100644 (file)
@@ -1,3 +1,6 @@
+# mod_import_cycle covers this error in module mode.
+env GO111MODULE=off
+
 ! go build selfimport
 stderr -count=1 'import cycle not allowed'
 
index 6fcc4e02aabd9b676204a5b8df24a1463cf915f3..25aa18cfcb33c0bb5dd8d2874b5777a733d2275d 100644 (file)
@@ -1,44 +1,63 @@
 # Test internal package errors are handled
-go list ./testinternal3
+cd testinternal3
+go list .
 stdout 'testinternal3'
 
 # Test internal cache
-env GOPATH=$WORK/gopath/src/testinternal4
-! go build p
+cd ../testinternal4
+! go build testinternal4/p
 stderr 'internal'
 
 # Test internal packages outside GOROOT are respected
-! go build -v  ./testinternal2
-stderr 'testinternal2(\/|\\)p\.go\:3\:8\: use of internal package .*internal/w not allowed'
+cd ../testinternal2
+! go build -v .
+stderr 'p\.go:3:8: use of internal package .*internal/w not allowed'
 
 [gccgo] skip # gccgo does not have GOROOT
-! go build -v ./testinternal
-stderr 'testinternal(\/|\\)p\.go\:3\:8\: use of internal package net/http/internal not allowed'
+cd ../testinternal
+! go build -v .
+stderr 'p\.go:3:8: use of internal package net/http/internal not allowed'
 
+-- testinternal/go.mod --
+module testinternal
+
+go 1.16
 -- testinternal/p.go --
 package p
 
 import _ "net/http/internal"
+-- testinternal2/go.mod --
+module testinternal2
+
+go 1.16
 -- testinternal2/p.go --
 package p
 
 import _ "./x/y/z/internal/w"
 -- testinternal2/x/y/z/internal/w/w.go --
 package w
+-- testinternal3/go.mod --
+module testinternal3
+
+go 1.16
 -- testinternal3/t.go --
 package t
 
 import _ "internal/does-not-exist"
--- testinternal4/src/p/p.go --
+-- testinternal4/go.mod --
+module testinternal4
+
+go 1.16
+-- testinternal4/p/p.go --
 package p
 
 import (
-       _ "q/internal/x"
-       _ "q/j"
+       _ "testinternal4/q/internal/x"
+       _ "testinternal4/q/j"
 )
--- testinternal4/src/q/internal/x/x.go --
+-- testinternal4/q/internal/x/x.go --
 package x
--- testinternal4/src/q/j/j.go --
+-- testinternal4/q/j/j.go --
 package j
 
-import _ "q/internal/x"
+import _ "testinternal4/q/internal/x"
index 857f364e817430f1869b8899f0a414eef7e43af0..ae99c60d99fb193db206d574eac13fd50f291d5f 100644 (file)
@@ -8,7 +8,7 @@
 
 # Install some commands to compare mtimes
 env GOBIN=$WORK/tmp/bin
-go install now mtime before
+go install m/now m/mtime m/before
 
 # Initial builds
 go test -c -test.bench=XXX errors
@@ -34,6 +34,10 @@ exec $GOBIN/mtime errors2.test
 cp stdout errors2_mod_time.txt
 exec $GOBIN/before start_time.txt errors2_mod_time.txt
 
+-- go.mod --
+module m
+
+go 1.16
 -- now/now.go --
 // Writes time.Now() to a file
 package main
@@ -122,4 +126,4 @@ func main() {
                fmt.Fprintf(os.Stderr, "time in %v (%v) is not before time in %v (%v)", os.Args[1], t1, os.Args[2], t2)
                os.Exit(1)
        }
-}
\ No newline at end of file
+}
index daa544d3f053a5d878b308e63cfbf761e992eebc..f1de1e4c7129af961d25c5c8190b186354cef612 100644 (file)
@@ -4,7 +4,11 @@ go build -o linkx$GOEXE -ldflags -X=my.pkg.Text=linkXworked my.pkg/main
 exec ./linkx$GOEXE
 stderr '^linkXworked$'
 
--- my.pkg/main/main.go --
+-- go.mod --
+module my.pkg
+
+go 1.16
+-- main/main.go --
 package main
 
 import "my.pkg"
@@ -12,7 +16,7 @@ import "my.pkg"
 func main() {
        println(pkg.Text)
 }
--- my.pkg/pkg.go --
+-- pkg.go --
 package pkg
 
 var Text = "unset"
index 200d13760ee1a0779ad4917b62ce76dc752bf694..7aa77aea42ad3b8bbcd3046845ffcd37a021163e 100644 (file)
@@ -5,6 +5,10 @@
 go build -n
 ! stderr '[/\\]\$WORK'
 
+-- go.mod --
+module m
+
+go 1.16
 -- main.go --
 package main
 
index 3fd7739fbb94bb714e1b83625fb9380ed4980411..b61d7522740d34447f64f75056a8cd15f9bffbbf 100644 (file)
@@ -16,6 +16,10 @@ stderr 'no Go files in '
 ! go build ./exclude/empty
 stderr 'no Go files in '
 
+-- go.mod --
+module m
+
+go 1.16
 -- empty/test/test_test.go --
 package p
 -- empty/testxtest/test_test.go --
index e5a4852346c41ff28301daa4696e5753500c4bc8..ced7cf82a6ef8d2c5cbbde8dda7eb35bebcb0e5f 100644 (file)
@@ -5,7 +5,7 @@
 [windows] env NONEXE=''
 
 env GOBIN=$WORK/tmp/bin
-go install isarchive &
+go install m/isarchive &
 
 go build x.go
 exists -exec x$GOEXE
@@ -55,6 +55,10 @@ exec $GOBIN/isarchive myatomic.a
 ! go build -o whatever cmd/gofmt sync/atomic
 stderr 'multiple packages'
 
+-- go.mod --
+module m
+
+go 1.16
 -- x.go --
 package main
 
@@ -84,4 +88,4 @@ func main() {
                fmt.Fprintf(os.Stderr, "file %s exists but is not an archive\n", os.Args[1])
                os.Exit(1)
        }
-}
\ No newline at end of file
+}
index f36e90fea606702f27675105fee3352f9f5b65cd..6a600cfb0a8c5761f59d73141b79b731bffdeef3 100644 (file)
@@ -1,6 +1,9 @@
 # Tests issue #18778
+[short] skip
 
 cd pkgs
+
+env GO111MODULE=off
 go build ./...
 ! stdout .
 go test ./...
@@ -9,6 +12,10 @@ go list ./...
 stdout 'pkgs$'
 stdout 'pkgs/a'
 
+-- pkgs/go.mod --
+module pkgs
+
+go 1.16
 -- pkgs/a.go --
 package x
 -- pkgs/a_test.go --
@@ -26,4 +33,4 @@ package a_test
 import "testing"
 
 func TestA(t *testing.T) {
-}
\ No newline at end of file
+}
index 996d87d96129d13f8086f10e917ff831ec34df35..dba80c29ad2412538f27a9d434755242aedb92f1 100644 (file)
@@ -2,16 +2,13 @@
 [!linux] [!darwin] skip
 [!cgo] skip
 
-go build -n testdep/p2
-! go build -buildmode=plugin testdep/p2
+go build -n testdep
+! go build -buildmode=plugin testdep
 stderr '-buildmode=plugin requires exactly one main package'
 
--- testdep/p1/p1.go --
-package p1
--- testdep/p1/p1_test.go --
-package p1
-
-import _ "testdep/p2"
--- testdep/p2/p2.go --
-package p2
+-- go.mod --
+module testdep
 
+go 1.16
+-- testdep.go --
+package p
index 54dd59772ad2f004c8112dc7dcd6f0c521db8137..8693a80a08e67539a7e331870cd846cb045d57a8 100644 (file)
@@ -1,14 +1,18 @@
 # Named explicitly, test-only packages should be reported as
 # unbuildable/uninstallable, even if there is a wildcard also matching.
-! go build testonly testonly...
+! go build m/testonly m/testonly...
 stderr 'no non-test Go files in'
 ! go install ./testonly
 stderr 'no non-test Go files in'
 
 # Named through a wildcard, the test-only packages should be silently ignored.
-go build testonly...
+go build m/testonly...
 go install ./testonly...
 
+-- go.mod --
+module m
+
+go 1.16
 -- testonly/t_test.go --
 package testonly
 -- testonly2/t.go --
index 726ecd75b97795d7359a65fab0df54c2ece44076..f430ff2c3eb888d596b848f5f95ee06d50fe446d 100644 (file)
@@ -1,4 +1,5 @@
 # Build
+env GO111MODULE=off
 go build vend/x
 ! stdout .
 ! stderr .
index e6561069405a085ce73a5db12f5f21f63590573e..7aaa713e24412c1966b003e3f774888cd9df7dcb 100644 (file)
@@ -6,7 +6,11 @@
 ! go build cgoasm
 stderr 'package using cgo has Go assembly file'
 
--- cgoasm/p.go --
+-- go.mod --
+module cgoasm
+
+go 1.16
+-- p.go --
 package p
 
 /*
@@ -15,7 +19,7 @@ package p
 import "C"
 
 func F() {}
--- cgoasm/p.s --
+-- p.s --
 TEXT asm(SB),$0
        RET
 
index 358284ffec0dee40d2b23c902ef163203480c418..6bf3beb8e4f79e704364bc25406a3c4f929f84ce 100644 (file)
@@ -1,58 +1,57 @@
 [!cgo] skip
 [short] skip
 
-mkdir x
-cp x.go.txt x/x.go
+cp x.go.txt x.go
 
 # Only allow //go:cgo_ldflag .* in cgo-generated code
-[gc] cp x_gc.go.txt x/x.go
+[gc] cp x_gc.go.txt x.go
 [gc] ! go build x
 [gc] stderr '//go:cgo_ldflag .* only allowed in cgo-generated code'
 
 # Ignore _* files
-rm x/x.go
-! go build x
+rm x.go
+! go build .
 stderr 'no Go files'
-cp cgo_yy.go.txt x/_cgo_yy.go
-! go build x
+cp cgo_yy.go.txt _cgo_yy.go
+! go build .
 stderr 'no Go files' #_* files are ignored...
 
-[gc] ! go build x/_cgo_yy.go # ... but if forced, the comment is rejected
+[gc] ! go build _cgo_yy.go # ... but if forced, the comment is rejected
 # Actually, today there is a separate issue that _ files named
 # on the command line are ignored. Once that is fixed,
 # we want to see the cgo_ldflag error.
 [gc] stderr '//go:cgo_ldflag only allowed in cgo-generated code|no Go files'
 
-rm x/_cgo_yy.go
+rm _cgo_yy.go
 
 # Reject #cgo CFLAGS: -fplugin=foo.so
-cp x.go.txt x/x.go
-cp y_fplugin.go.txt x/y.go
+cp x.go.txt x.go
+cp y_fplugin.go.txt y.go
 ! go build x
 stderr 'invalid flag in #cgo CFLAGS: -fplugin=foo.so'
 
 # Reject #cgo CFLAGS: -lbar -fplugin=foo.so
-cp y_lbar_fplugin.go.txt x/y.go
+cp y_lbar_fplugin.go.txt y.go
 ! go build x
 stderr 'invalid flag in #cgo CFLAGS: -fplugin=foo.so'
 
 # Reject #cgo pkg-config: -foo
-cp y_pkgconfig_dash_foo.txt x/y.go
+cp y_pkgconfig_dash_foo.txt y.go
 ! go build x
 stderr 'invalid pkg-config package name: -foo'
 
 # Reject #cgo pkg-config: @foo
-cp y_pkgconfig_at_foo.txt x/y.go
+cp y_pkgconfig_at_foo.txt y.go
 ! go build x
 stderr 'invalid pkg-config package name: @foo'
 
 # Reject #cgo CFLAGS: @foo
-cp y_cflags_at_foo.txt x/y.go
+cp y_cflags_at_foo.txt y.go
 ! go build x
 stderr 'invalid flag in #cgo CFLAGS: @foo'
 
 # Reject #cgo CFLAGS: -D
-cp y_cflags_dash_d.txt x/y.go
+cp y_cflags_dash_d.txt y.go
 ! go build x
 stderr 'invalid flag in #cgo CFLAGS: -D without argument'
 
@@ -60,21 +59,25 @@ stderr 'invalid flag in #cgo CFLAGS: -D without argument'
 # before the check is applied. There's no such rewrite for -D.
 
 # Reject #cgo CFLAGS: -D @foo
-cp y_cflags_dash_d_space_at_foo.txt x/y.go
+cp y_cflags_dash_d_space_at_foo.txt y.go
 ! go build x
 stderr 'invalid flag in #cgo CFLAGS: -D @foo'
 
 # Reject #cgo CFLAGS -D@foo
-cp y_cflags_dash_d_at_foo.txt x/y.go
+cp y_cflags_dash_d_at_foo.txt y.go
 ! go build x
 stderr 'invalid flag in #cgo CFLAGS: -D@foo'
 
 # Check for CFLAGS in commands
 env CGO_CFLAGS=-D@foo
-cp y_no_cflags.txt x/y.go
+cp y_no_cflags.txt y.go
 go build -n x
 stderr '-D@foo'
 
+-- go.mod --
+module x
+
+go 1.16
 -- x_gc.go.txt --
 package x
 
@@ -123,4 +126,4 @@ package x
 import "C"
 -- y_no_cflags.txt --
 package x
-import "C"
\ No newline at end of file
+import "C"
index e5fa84fdbb6cef9f9e356f10d778802b94c55f7b..bd4777c821cd4a3bdc25177b7e5d3fab0348b2b7 100644 (file)
@@ -4,7 +4,11 @@
 go list -race -deps foo
 stdout syscall
 
--- foo/foo.go --
+-- go.mod --
+module foo
+
+go 1.16
+-- foo.go --
 package foo
 
 // #include <stdio.h>
index 5241c7f0dffff928632085569dc71c31a4453157..57f76d6c02890ebfba0202e2c8a08a690c20bdd8 100644 (file)
@@ -8,7 +8,11 @@ go tool cover -func=$WORK/cover.out
 stdout '\tg\t*100.0%' # Check g is 100% covered.
 ! stdout '\tf\t*[0-9]' # Check for no coverage on the assembly function
 
--- coverasm/p.go --
+-- go.mod --
+module coverasm
+
+go 1.16
+-- p.go --
 package p
 
 func f()
@@ -16,10 +20,10 @@ func f()
 func g() {
        println("g")
 }
--- coverasm/p.s --
+-- p.s --
 // empty asm file,
 // so go test doesn't complain about declaration of f in p.go.
--- coverasm/p_test.go --
+-- p_test.go --
 package p
 
 import "testing"
index 6fac4f87ea48fc732be1a63d1a0b240a85341e02..e7d5250468cd01e8444338f7add92ea39825f100 100644 (file)
@@ -1,9 +1,13 @@
 [short] skip
-go test -cover ./coverblank
+go test -cover coverblank
 stdout 'coverage: 100.0% of statements'
 
 
--- coverblank/a.go --
+-- go.mod --
+module coverblank
+
+go 1.16
+-- a.go --
 package coverblank
 
 func _() {
@@ -20,7 +24,7 @@ func (x X) _() {
        println("unreachable")
 }
 
--- coverblank/a_test.go --
+-- a_test.go --
 package coverblank
 
 import "testing"
index fdd0191ee0e154dd371871a15e4e4c3b123a7c5c..9cf78f71e9fac21484fc1bb1ef68e40fc99c4c45 100644 (file)
@@ -8,7 +8,11 @@ go test -short -cover cgocover
 stdout  'coverage:.*[1-9][0-9.]+%'
 ! stderr '[^0-9]0\.0%'
 
--- cgocover/p.go --
+-- go.mod --
+module cgocover
+
+go 1.16
+-- p.go --
 package p
 
 /*
@@ -28,7 +32,7 @@ func F() {
        }
        C.f()
 }
--- cgocover/p_test.go --
+-- p_test.go --
 package p
 
 import "testing"
index 483813bd6afb37dce580d69b830c449d02165d2b..c53b979f9fcfaee7ec85d67b53ce5647be994eb9 100644 (file)
@@ -9,9 +9,13 @@ go test -short -cover cgocover4
 stdout  'coverage:.*[1-9][0-9.]+%'
 ! stderr '[^0-9]0\.0%'
 
--- cgocover4/notcgo.go --
+-- go.mod --
+module cgocover4
+
+go 1.16
+-- notcgo.go --
 package p
--- cgocover4/p.go --
+-- p.go --
 package p
 
 /*
@@ -31,7 +35,7 @@ func F() {
        }
        C.f()
 }
--- cgocover4/x_test.go --
+-- x_test.go --
 package p_test
 
 import (
@@ -41,4 +45,4 @@ import (
 
 func TestF(t *testing.T) {
        F()
-}
\ No newline at end of file
+}
index 92fc1ebddabd0963a608a3a515422af7cba87b7b..b501ab02a557ffed85919d43d73c42192a3b2162 100644 (file)
@@ -10,7 +10,11 @@ go test -short -cover cgocover3
 stdout  'coverage:.*[1-9][0-9.]+%'
 ! stderr '[^0-9]0\.0%'
 
--- cgocover3/p.go --
+-- go.mod --
+module cgocover3
+
+go 1.16
+-- p.go --
 package p
 
 /*
@@ -30,9 +34,9 @@ func F() {
        }
        C.f()
 }
--- cgocover3/p_test.go --
+-- p_test.go --
 package p
--- cgocover3/x_test.go --
+-- x_test.go --
 package p_test
 
 import (
@@ -42,4 +46,4 @@ import (
 
 func TestF(t *testing.T) {
        F()
-}
\ No newline at end of file
+}
index edf8112728f22c78f772c31e59099572412c3070..79cc08c4811a65a8699eb5949d5bf422b2ef81b4 100644 (file)
@@ -8,7 +8,11 @@ go test -short -cover cgocover2
 stdout  'coverage:.*[1-9][0-9.]+%'
 ! stderr '[^0-9]0\.0%'
 
--- cgocover2/p.go --
+-- go.mod --
+module cgocover2
+
+go 1.16
+-- p.go --
 package p
 
 /*
@@ -28,7 +32,7 @@ func F() {
        }
        C.f()
 }
--- cgocover2/x_test.go --
+-- x_test.go --
 package p_test
 
 import (
@@ -38,4 +42,4 @@ import (
 
 func TestF(t *testing.T) {
        F()
-}
\ No newline at end of file
+}
index 61793cec4917527d8b99dea5764542f5dccc3371..8950f8d088e747e13de82f0dce86a630217eab48 100644 (file)
@@ -6,18 +6,22 @@
 go test -c -o $WORK/coverdep -coverprofile=$WORK/no/such/dir/cover.out coverdep
 exists -exec $WORK/coverdep
 
--- coverdep/p.go --
+-- go.mod --
+module coverdep
+
+go 1.16
+-- p.go --
 package p
 
 import _ "coverdep/p1"
 
 func F() {
 }
--- coverdep/p1/p1.go --
+-- p1/p1.go --
 package p1
 
 import _ "errors"
--- coverdep/p_test.go --
+-- p_test.go --
 package p
 
 import "testing"
index 20b0c15d184c27f71898db7fef2bdabb1d593bf2..36ea6e00b3ef92654667ba19a1d08d1ab160a24a 100644 (file)
@@ -7,11 +7,15 @@
 go test -short -cover coverdep2/p1
 stdout 'coverage: 100.0% of statements' # expect 100.0% coverage
 
--- coverdep2/p1/p.go --
+-- go.mod --
+module coverdep2
+
+go 1.16
+-- p1/p.go --
 package p1
 
 func F() int { return 1 }
--- coverdep2/p1/p_test.go --
+-- p1/p_test.go --
 package p1_test
 
 import (
@@ -22,7 +26,7 @@ import (
 func Test(t *testing.T) {
        p2.F()
 }
--- coverdep2/p2/p2.go --
+-- p2/p2.go --
 package p2
 
 import "coverdep2/p1"
index e07be22d6cf3e27092657c12c29913b8ee8bde9b..d492e42e2a9265f66a6a96a4698b231d39032760 100644 (file)
@@ -1,22 +1,26 @@
 [short] skip
 [gccgo] skip # gccgo has no cover tool
 
-go test -coverpkg=coverdot1,coverdot2 coverdot2
+go test -coverpkg=coverdot/a,coverdot/b coverdot/b
 ! stderr '[^0-9]0\.0%'
 ! stdout '[^0-9]0\.0%'
 
--- coverdot1/p.go --
-package coverdot1
+-- go.mod --
+module coverdot
+
+go 1.16
+-- a/a.go --
+package a
 
 func F() {}
--- coverdot2/p.go --
-package coverdot2
+-- b/b.go --
+package b
 
-import . "coverdot1"
+import . "coverdot/a"
 
 func G() { F() }
--- coverdot2/p_test.go --
-package coverdot2
+-- b/b_test.go --
+package b
 
 import "testing"
 
index 6ba0f08a2b470dbcd1dd732e990340887879788c..4abdf1137aac4d6dd4d905feb8eb49cfeab97ed5 100644 (file)
@@ -5,8 +5,8 @@
 
 # Get errors from a go test into stderr.txt
 ! go test coverbad
-stderr 'coverbad[\\/]p\.go:4' # look for error at coverbad/p.go:4
-[cgo] stderr 'coverbad[\\/]p1\.go:6' # look for error at coverbad/p.go:6
+stderr 'p\.go:4' # look for error at coverbad/p.go:4
+[cgo] stderr 'p1\.go:6' # look for error at coverbad/p.go:6
 ! stderr $WORK # make sure temporary directory isn't in error
 
 cp stderr $WORK/stderr.txt
@@ -24,13 +24,17 @@ wait # for go run above
 
 cmp $WORK/stderr.txt $WORK/stderr2.txt
 
--- coverbad/p.go --
+-- go.mod --
+module coverbad
+
+go 1.16
+-- p.go --
 package p
 
 func f() {
        g()
 }
--- coverbad/p1.go --
+-- p1.go --
 package p
 
 import "C"
@@ -38,13 +42,15 @@ import "C"
 func h() {
        j()
 }
--- coverbad/p_test.go --
+-- p_test.go --
 package p
 
 import "testing"
 
 func Test(t *testing.T) {}
 -- clean_charpos.go --
+// +build ignore
+
 package main
 
 import (
@@ -66,4 +72,4 @@ func main() {
        if err != nil {
                log.Fatal(err)
        }
-}
\ No newline at end of file
+}
index 83eef0c8a8bb733da5c838dd144bed1e6cd0e13a..eb6de6778a9bf35e98ba7be6320270644b04610c 100644 (file)
@@ -5,15 +5,19 @@ stderr 'not an importable package' # check that import main was detected
 ! go test -n -cover importmain/test
 stderr 'not an importable package' # check that import main was detected
 
--- importmain/ismain/main.go --
+-- go.mod --
+module importmain
+
+go 1.16
+-- ismain/main.go --
 package main
 
 import _ "importmain/test"
 
 func main() {}
--- importmain/test/test.go --
+-- test/test.go --
 package test
--- importmain/test/test_test.go --
+-- test/test_test.go --
 package test_test
 
 import "testing"
index 0b7f2d70a242d8f0ddb69096f69f166d22959d0f..ec0850c00374529a3babf7a018395a6f56ab5a53 100644 (file)
@@ -1,12 +1,16 @@
 [gccgo] skip
 
-# If coverpkg=sleepy... expands by package loading
+# If coverpkg=m/sleepy... expands by package loading
 # (as opposed to pattern matching on deps)
 # then it will try to load sleepybad, which does not compile,
 # and the test command will fail.
-! go list sleepy...
-go test -c -n -coverprofile=$TMPDIR/cover.out -coverpkg=sleepy... -run=^$ sleepy1
+! go list m/sleepy...
+go test -c -n -coverprofile=$TMPDIR/cover.out -coverpkg=m/sleepy... -run=^$ m/sleepy1
 
+-- go.mod --
+module m
+
+go 1.16
 -- sleepy1/p_test.go --
 package p
 
index 314ea6bead1c7a06311f4568a7133e0df65dc496..4f3c9ca2f270143dfd40fea5760921793a859766 100644 (file)
@@ -5,6 +5,10 @@ stdout 'pkg2   \S+     coverage: 0.0% of statements \[no tests to run\]'
 stdout 'pkg3   \S+     coverage: 100.0% of statements'
 stdout 'pkg4   \S+     coverage: \[no statements\]'
 
+-- go.mod --
+module m
+
+go 1.16
 -- pkg1/a.go --
 package pkg1
 
index 769c03ea837923fe9559e8a20eeed305ecb78e25..433af9ab738177aa8967f5ed8561c1bc00836e15 100644 (file)
@@ -3,22 +3,26 @@
 
 go test -short -cover -covermode=atomic -coverpkg=coverdep/p1 coverdep
 
--- coverdep/p.go --
+-- go.mod --
+module coverdep
+
+go 1.16
+-- p.go --
 package p
 
 import _ "coverdep/p1"
 
 func F() {
 }
--- coverdep/p1/p1.go --
+-- p1/p1.go --
 package p1
 
 import _ "errors"
--- coverdep/p_test.go --
+-- p_test.go --
 package p
 
 import "testing"
 
 func Test(t *testing.T) {
        F()
-}
\ No newline at end of file
+}
index 59a2f5786bc0359533d007b9f166c73aee13939a..4d31573d5643a0ea48f9488dbf8c1c4aa4a9c759 100644 (file)
@@ -3,7 +3,11 @@
 go generate gencycle
 stdout 'hello world' # check go generate gencycle ran the generator
 
--- gencycle/gencycle.go --
+-- go.mod --
+module gencycle
+
+go 1.16
+-- gencycle.go --
 //go:generate echo hello world
 
 package gencycle
index 62aa9dd9ba70815ab6935177c1e00b3b19afbb4b..e18e62ccf34fa8877beac479f1998b0916438637 100644 (file)
@@ -54,6 +54,10 @@ func main() {
        fmt.Println()
 }
 
+-- go.mod --
+module m
+
+go 1.16
 -- nogo/foo.txt --
 Text file in a directory without go files.
 Go generate should ignore this directory.
@@ -196,4 +200,4 @@ import "bar"
 
 package importerr
 import "moo"
-//go:generate echo Success c
\ No newline at end of file
+//go:generate echo Success c
index 743fbb3ea4980ba4ead28352ba9fbfeb93ee9e28..cda25e12b0e6ea0a2f3ef7a0165fcfca5e8b7df0 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 go get -u rsc.io/pdf/...
-exists $GOPATH/bin/pdfpasswd$GOEXE
\ No newline at end of file
+exists $GOPATH/bin/pdfpasswd$GOEXE
index be5c8dd5cab9724adaeb5b0a1e30f7260e0e3a9b..baac91686868a66a83d51d206993a7df8ca728cb 100644 (file)
@@ -2,7 +2,8 @@
 
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 go get -v -t github.com/rsc/go-get-issue-8181/a github.com/rsc/go-get-issue-8181/b
 go list ...
-stdout 'x/build/gerrit'
\ No newline at end of file
+stdout 'x/build/gerrit'
index c2e9db35ec4be9606347530bf66d3fd837d17fe5..918784869b312a10b2f0535f2eff8b12a3c7fcb0 100644 (file)
@@ -3,6 +3,7 @@
 
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 # go-get-issue-9357.appspot.com is running
 # the code at github.com/rsc/go-get-issue-9357,
@@ -16,4 +17,4 @@ rm $GOPATH/src/go-get-issue-9357.appspot.com
 go get go-get-issue-9357.appspot.com
 
 rm $GOPATH/src/go-get-issue-9357.appspot.com
-go get -u go-get-issue-9357.appspot.com
\ No newline at end of file
+go get -u go-get-issue-9357.appspot.com
index 0396e1b278e9b72a52bf78989da417c4f164442c..dbaf46ced363df24a3771014225cd42948878a54 100644 (file)
@@ -1,9 +1,10 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 # Tests Issues #9797 and #19769
 
 mkdir $WORK/tmp/src/rsc.io
 env GOPATH=$WORK/tmp
 cd $WORK/tmp/src/rsc.io
-go get ./pprof_mac_fix
\ No newline at end of file
+go get ./pprof_mac_fix
index 49f1a174d06d530ae5647743143f95217837edbb..929435ad70c1036d6a2ab2137a2b529589d20bd2 100644 (file)
@@ -1,4 +1,5 @@
 [!net] skip
+env GO111MODULE=off
 
 # Issue 4186. go get cannot be used to download packages to $GOROOT.
 # Test that without GOPATH set, go get should fail.
@@ -49,4 +50,4 @@ stderr '\$GOPATH not set'
 env GOPATH=
 env GOROOT=$WORK/home/go/
 ! go get -d github.com/golang/example/hello
-stderr '\$GOPATH not set'
\ No newline at end of file
+stderr '\$GOPATH not set'
index c0439fb0378075db9662c91550f8255388112038..a4a6fd428f7c2fde2a5ed5689e3dd083f04c863a 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 ! go get -d insecure.go-get-issue-15410.appspot.com/pkg/p
-go get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p
\ No newline at end of file
+go get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p
index 792c86815120992800bf35c46625995f3f155582..4511c98c568458884a97af5e3c441a47f9d0ff62 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 # Clone the repo via HTTP manually.
 exec git clone -q http://github.com/golang/example github.com/golang/example
@@ -8,4 +9,4 @@ exec git clone -q http://github.com/golang/example github.com/golang/example
 # Update with -insecure should succeed.
 # We need -f to ignore import comments.
 ! go get -d -u -f github.com/golang/example/hello
-go get -d -u -f -insecure github.com/golang/example/hello
\ No newline at end of file
+go get -d -u -f -insecure github.com/golang/example/hello
index 82bb0d5ba5c842a11057686f93061ed6e2ae2a39..ff20d4ba04e64c804c5e707eea85a6e6a5836d69 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 # This used to fail with errors about internal packages
-go get github.com/rsc/go-get-issue-11960/...
\ No newline at end of file
+go get github.com/rsc/go-get-issue-11960/...
index da7704dee536fa45c4b638ea9888b981fccc9ef2..9d6b7dde0196653caa333d7dcd48162a7bca32d9 100644 (file)
@@ -2,7 +2,8 @@
 
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 env GOPATH=$WORK/tmp/gopath
 go get github.com/rsc/go-get-issue-11307
-go get -u github.com/rsc/go-get-issue-11307 # was failing
\ No newline at end of file
+go get -u github.com/rsc/go-get-issue-11307 # was failing
similarity index 97%
rename from src/cmd/go/testdata/script/mod_get_legacy.txt
rename to src/cmd/go/testdata/script/get_legacy.txt
index 28a820e97b795fc7f2d69ea88cd8ddd4740f959b..938d42868af714d44405898a14c605083aa1cc6d 100644 (file)
@@ -5,6 +5,7 @@
 
 [short] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 env GOPATH=$WORK/tmp/d1
 go get vcs-test.golang.org/git/modlegacy1-old.git/p1
@@ -54,4 +55,4 @@ rm $GOPATH
 go get github.com/rsc/vgotest5 github.com/myitcv/vgo_example_compat github.com/rsc/vgotest4
 
 rm $GOPATH
-go get github.com/rsc/vgotest5 github.com/rsc/vgotest4 github.com/myitcv/vgo_example_compat
\ No newline at end of file
+go get github.com/rsc/vgotest5 github.com/rsc/vgotest4 github.com/myitcv/vgo_example_compat
index 8b34c9596cb674ecd694e56d4f74290114d544d4..16a560afcac9b00690fe0e26451c7b9c1c196b47 100644 (file)
@@ -3,5 +3,6 @@
 [!net] skip
 [!exec:git] skip
 [!race] skip
+env GO111MODULE=off
 
-go get -race github.com/rsc/go-get-issue-9224-cmd
\ No newline at end of file
+go get -race github.com/rsc/go-get-issue-9224-cmd
index 7437c30e777b4cd352e0b0019fd66a91aed6a5de..a3f38ddbab3886b51ece548991200d11167e331d 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 go get golang.org/x/tour/content...
-go get -t golang.org/x/tour/content...
\ No newline at end of file
+go get -t golang.org/x/tour/content...
index df889c49b0acd916fdd1357e5d629f30dd7682d3..9afce6a443babc7ffe5c43d780b72f851ad4be1f 100644 (file)
@@ -4,6 +4,7 @@
 
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 # Rewind
 go get github.com/rsc/go-get-issue-9224-cmd
@@ -21,4 +22,4 @@ exec git reset --hard HEAD~
 cd $GOPATH/src
 
 # (Again with -d -u) Run get
-go get -d -u 'github.com/rsc/go-get-issue-9224-cmd'
\ No newline at end of file
+go get -d -u 'github.com/rsc/go-get-issue-9224-cmd'
index 85c2e24bc81e1d25b4c3aa69f06caf9d182c7a13..b00adea70b22a4d7ed1a8f9d3741487bc5227414 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 # Clone the repo via HTTPS manually.
 exec git clone -q https://github.com/golang/example github.com/golang/example
@@ -10,4 +11,4 @@ cd github.com/golang/example
 exec git remote set-url origin xyz://github.com/golang/example
 exec git config --local url.https://github.com/.insteadOf xyz://github.com/
 
-go get -d -u -f github.com/golang/example/hello
\ No newline at end of file
+go get -d -u -f github.com/golang/example/hello
index bfa47a2a4cc07f6e3c23305148237ca3db7e7adf..4e66004014a6c842ffbe6fc5dbbb1dcb3e479e39 100644 (file)
@@ -2,6 +2,7 @@
 
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 go get github.com/tmwh/go-get-issue-14450/a
 ! go get -u .../
@@ -12,4 +13,4 @@ exists github.com/tmwh/go-get-issue-14450/b
 exists github.com/tmwh/go-get-issue-14450-b-dependency/c
 exists github.com/tmwh/go-get-issue-14450-b-dependency/d
 
-! exists github.com/tmwh/go-get-issue-14450-c-dependency/e
\ No newline at end of file
+! exists github.com/tmwh/go-get-issue-14450-c-dependency/e
index e2404cc8d9bc195504765b456358851199d9b119..8dc84fc7274a41ca444c8feb2785ece1621adc4a 100644 (file)
@@ -1,4 +1,5 @@
 # Test that the Version Control error message includes the correct directory
+env GO111MODULE=off
 ! go get -u foo
 stderr gopath(\\\\|/)src(\\\\|/)foo
 
index a6f0a70c48c0d9c9d9b64f248ca5d1ade6556098..4ebb8a26b6dd3047872f6f8ccd566ce09fd50ab3 100644 (file)
@@ -1,4 +1,5 @@
 [short] skip
+env GO111MODULE=off
 
 cd $GOPATH/src/v
 go run m.go
@@ -91,4 +92,4 @@ func TestNothing(t *testing.T) {
 }
 -- v/vendor/vendor.org/p/p.go --
 package p
-const C = 1
\ No newline at end of file
+const C = 1
index 5096195c7008bdf43a882e2c35bce113b0c31c1e..22e6048e96b95eff11e1c0bd1d3eca54d0f1036f 100644 (file)
@@ -1,4 +1,5 @@
 [!net] skip
+env GO111MODULE=off
 
 # Issue 17119: Test more duplicate load errors.
 ! go build dupload
index fa1fcd67a474f34c796fd134caaf56b81490a19c..5a2b46030f12ab80d9023fa2dd956a3db5bd4c19 100644 (file)
@@ -3,7 +3,11 @@ env CGO_ENABLED=0
 ! go install cgotest
 stderr 'build constraints exclude all Go files'
 
--- cgotest/m.go --
+-- go.mod --
+module cgotest
+
+go 1.16
+-- m.go --
 package cgotest
 
 import "C"
index e1e9ec7bdfd8b4ab39bdd29d51c23adb221c9319..aa145249c57b7d917dac35bcf0878dbf8dab9058 100644 (file)
@@ -2,7 +2,11 @@ env GOBIN=.
 ! go install
 stderr 'cannot install, GOBIN must be an absolute path'
 
+-- go.mod --
+module triv
+
+go 1.16
 -- triv.go --
 package main
 
-func main() {}
\ No newline at end of file
+func main() {}
index 995162172e8666c831181b42aab2e488c7931825..2039d9e7f2ece442866c9936e01ccfcda59c7a58 100644 (file)
@@ -3,6 +3,7 @@
 
 [!net] skip
 
+env GO111MODULE=off
 env GOPATH=$WORK/gopath1${:}$WORK/gopath2
 
 mkdir $WORK/gopath1/src/test
@@ -16,4 +17,4 @@ stderr 'no install location for.*gopath2.src.test: hidden by .*gopath1.src.test'
 -- main.go --
 package main
 
-func main() {}
\ No newline at end of file
+func main() {}
index 46b0ef4200e0746776ea699d61db290ca2106756..d4f0b87537c62113d8d21e146302236e7d331f20 100644 (file)
 cc -c -o syso/objTestImpl.syso syso/src/objTestImpl.c
 go build -ldflags='-linkmode=external' ./cmd/main.go
 
+-- go.mod --
+module m
+
+go 1.16
 -- syso/objTest.s --
 #include "textflag.h"
 
@@ -36,7 +40,7 @@ void objTestImpl() { /* Empty */ }
 -- cmd/main.go --
 package main
 
-import "syso"
+import "m/syso"
 
 func main() {
        syso.ObjTest()
index 73f44b63a0758557286c27c7f51c7a899449e7c8..181a202989e3c6472b2b8fead1be2eab23c30472 100644 (file)
@@ -8,30 +8,34 @@ stderr 'case-insensitive import collision'
 
 # List files explicitly on command line, to encounter case-checking
 # logic even on case-insensitive filesystems.
-cp example/b/file.go example/b/FILE.go  # no-op on case-insensitive filesystems
-! go list example/b/file.go example/b/FILE.go
+cp b/file.go b/FILE.go  # no-op on case-insensitive filesystems
+! go list b/file.go b/FILE.go
 stderr 'case-insensitive file name collision'
 
-mkdir example/a/Pkg  # no-op on case-insensitive filesystems
-cp example/a/pkg/pkg.go example/a/Pkg/pkg.go  # no-op on case-insensitive filesystems
+mkdir a/Pkg  # no-op on case-insensitive filesystems
+cp a/pkg/pkg.go a/Pkg/pkg.go  # no-op on case-insensitive filesystems
 ! go list example/a/pkg example/a/Pkg
 
 # Test that the path reported with an indirect import is correct.
-cp example/b/file.go example/b/FILE.go
+cp b/file.go b/FILE.go
 [case-sensitive] ! go build example/c
 [case-sensitive] stderr '^package example/c\n\timports example/b: case-insensitive file name collision: "FILE.go" and "file.go"$'
 
--- example/a/a.go --
+-- go.mod --
+module example
+
+go 1.16
+-- a/a.go --
 package p
 import (
        _ "example/a/pkg"
        _ "example/a/Pkg"
 )
--- example/a/pkg/pkg.go --
+-- a/pkg/pkg.go --
 package pkg
--- example/b/file.go --
+-- b/file.go --
 package b
--- example/c/c.go --
+-- c/c.go --
 package c
 
 import _ "example/b"
index ebd497b7e55927ed831c70579fda042d93a193c7..30c68dd77fd7866002dc11dba618b98828746501 100644 (file)
@@ -1,4 +1,5 @@
 # Setup
+env GO111MODULE=off
 mkdir $WORK/tmp/testdata/src/xtestonly
 cp f.go $WORK/tmp/testdata/src/xtestonly/f.go
 cp f_test.go $WORK/tmp/testdata/src/xtestonly/f_test.go
index 20c85b64533aed9c6bf7c65e20f944913477a557..f74ca86f37b9b927b660b7144bade5c0d075468c 100644 (file)
@@ -1,4 +1,5 @@
 [!symlink] skip
+env GO111MODULE=off
 
 mkdir $WORK/tmp/src
 symlink $WORK/tmp/src/dir1 -> $WORK/tmp
index e538072b33435e2a2d32fab6936ae75cb0a3c9f1..f756a56a3ff7907fbe8003c615826c9286baa5ad 100644 (file)
@@ -1,4 +1,5 @@
 [!symlink] skip
+env GO111MODULE=off
 
 mkdir $WORK/tmp/gopath/src/dir1/internal/v
 cp p.go $WORK/tmp/gopath/src/dir1/p.go
@@ -23,4 +24,4 @@ import _ `dir1/internal/v`
 
 func main() {}
 -- v.go --
-package v
\ No newline at end of file
+package v
index 68b7fd948b17301c6bd1fabbca098dc93d29184f..8e63a5a2594be02b38a5ceaf0ac6928b3d406400 100644 (file)
@@ -1,4 +1,5 @@
 [!symlink] skip
+env GO111MODULE=off
 
 mkdir $WORK/tmp/gopath/src/dir1/vendor/v
 cp p.go $WORK/tmp/gopath/src/dir1/p.go
@@ -24,4 +25,4 @@ import _ `v`
 
 func main () {}
 -- v.go --
-package v
\ No newline at end of file
+package v
index 98921614a920aa10b1ec15eb171a424fa664fc61..19f21382503c0e34602f3530569df3a906f6ccb9 100644 (file)
@@ -1,4 +1,5 @@
 [!symlink] skip
+env GO111MODULE=off
 
 mkdir $WORK/tmp/gopath/src/x/y/_vendor/src/x
 symlink $WORK/tmp/gopath/src/x/y/_vendor/src/x/y -> ../../..
@@ -17,4 +18,4 @@ package w
 
 import "x/y/z"
 -- z.go --
-package z
\ No newline at end of file
+package z
index 862b7a8fbb6ef0e7d8f26e726cae6544cf50ae13..954897c663c8744c26f908f6983519333606bc89 100644 (file)
@@ -1,21 +1,23 @@
 [short] skip
 
-cd $WORK
-
 # Test
-go test './gopath/src/testlist/...' -list=Test
+go test -list=Test
 stdout TestSimple
 
 # Benchmark
-go test './gopath/src/testlist/...' -list=Benchmark
+go test -list=Benchmark
 stdout BenchmarkSimple
 
 # Examples
-go test './gopath/src/testlist/...' -list=Example
+go test -list=Example
 stdout ExampleSimple
 stdout ExampleWithEmptyOutput
 
--- testlist/bench_test.go --
+-- go.mod --
+module m
+
+go 1.16
+-- bench_test.go --
 package testlist
 
 import (
@@ -30,7 +32,7 @@ func BenchmarkSimplefunc(b *testing.B) {
                _ = fmt.Sprint("Test for bench")
        }
 }
--- testlist/example_test.go --
+-- example_test.go --
 package testlist
 
 import (
@@ -52,7 +54,7 @@ func ExampleWithEmptyOutput() {
 func ExampleNoOutput() {
        _ = fmt.Sprint("Test with no output")
 }
--- testlist/test_test.go --
+-- test_test.go --
 package testlist
 
 import (
@@ -62,4 +64,4 @@ import (
 
 func TestSimple(t *testing.T) {
        _ = fmt.Sprint("Test simple")
-}
\ No newline at end of file
+}
index 74ca315a72aa7d08228aca6d927fca81512e6568..02b1088297025857f00394e075116fde918ad49e 100644 (file)
@@ -1,13 +1,17 @@
 # Test that wildcards don't look in useless directories.
 
 # First make sure that badpkg fails the list of '...'.
-! go list ...
+! go list ./...
 stderr badpkg
 
-# Check that the list of 'm...' succeeds. That implies badpkg was skipped.
-go list m...
+# Check that the list of './goodpkg...' succeeds. That implies badpkg was skipped.
+go list ./goodpkg...
 
--- m/x.go --
-package m
+-- go.mod --
+module m
+
+go 1.16
+-- goodpkg/x.go --
+package goodpkg
 -- badpkg/x.go --
-pkg badpkg
\ No newline at end of file
+pkg badpkg
index b3065490de73717462f102f8e3268ee529a11e46..d088ee40f3996e1001b85cb532e3456a1fc22cf4 100644 (file)
@@ -10,17 +10,21 @@ stdout golang.org/fake/d
 d
 d.test
 d_test [d.test]
--- d/d.go --
+-- go.mod --
+module d
+
+go 1.16
+-- d.go --
 package d
 
 import "net/http"
 
 const d = http.MethodGet
 func Get() string { return d; }
--- d/d2.go --
--- d/d_test.go --
+-- d2.go --
+-- d_test.go --
 package d_test
 
 import "testing"
 import "golang.org/fake/d"
-func TestD(t *testing.T) { d.Get(); }
\ No newline at end of file
+func TestD(t *testing.T) { d.Get(); }
index 03fba13c7703f2011027fefd880d5b03485f2c14..ea2b4d7cdeef908e178d496294a161a070c1f894 100644 (file)
@@ -1,11 +1,14 @@
-cd $GOPATH
-go run hello
+go run m/hello
 stderr 'hello, world'
 
-cd src/hello
+cd hello
 go run .
 stderr 'hello, world'
 
+-- go.mod --
+module m
+
+go 1.16
 -- hello/hello.go --
 package main
 
index 8544281db9f4cf9d701f061ae60aa3b7f130778d..46cac06bf44c0a1e3a63c77a27e8366452ebc098 100644 (file)
@@ -1,4 +1,5 @@
 # Run
+env GO111MODULE=off
 cd vend/hello
 go run hello.go
 stdout 'hello, world'
index 1e20c4eb6114d86d080beeeb0dcdc155908257e9..e281379ebd94cc86f34b5e0151cc4ef9b8156f7a 100644 (file)
@@ -5,7 +5,11 @@
 ! stderr ^ok
 stdout FAIL.*benchfatal
 
--- benchfatal/x_test.go --
+-- go.mod --
+module benchfatal
+
+go 1.16
+-- x_test.go --
 package benchfatal
 
 import "testing"
index affab6b806968171da4f741e315bf925781a8dd3..6b424c1bd89392c363d1468eda2aa0590baae79d 100644 (file)
@@ -10,7 +10,11 @@ stdout '^pkg: bench'
 ! stdout 'pkg:.*pkg: '
 ! stderr 'pkg:.*pkg:'
 
--- bench/x_test.go --
+-- go.mod --
+module bench
+
+go 1.16
+-- x_test.go --
 package bench
 
 import "testing"
index 2ae448a566559af6b9440f1acc86701e2970f99a..8d13634c8c4321f877f7459be74cbba2736f7e58 100644 (file)
@@ -5,13 +5,17 @@
 stderr 'undefined: g'
 stderr 'undefined: j'
 
--- coverbad/p.go --
+-- go.mod --
+module coverbad
+
+go 1.16
+-- p.go --
 package p
 
 func f() {
        g()
 }
--- coverbad/p1.go --
+-- p1.go --
 package p
 
 import "C"
@@ -19,7 +23,7 @@ import "C"
 func h() {
        j()
 }
--- coverbad/p_test.go --
+-- p_test.go --
 package p
 
 import "testing"
index 5a19f6590ff25ac777bbb9937baae4701abad044..06ae16ffd2a9aa7ed216a17bbbe3893349b8e69a 100644 (file)
@@ -4,6 +4,10 @@ go test -timeout=0 -run=TestNoDeadline
 go test -timeout=1m -run=TestDeadlineWithinMinute
 go test -timeout=1m -run=TestSubtestDeadlineWithinMinute
 
+-- go.mod --
+module m
+
+go 1.16
 -- deadline_test.go --
 package testing_test
 
index f2c512e791a4342c88ddf9a841a7f4dcfa7d4d00..5ebbecd53def0ccd584cafc01055da59b5d75509 100644 (file)
@@ -23,6 +23,10 @@ go test -cover -coverpkg=. -race
 cd $GOPATH/src/empty/testxtest
 go test -cover -coverpkg=. -race
 
+-- empty/go.mod --
+module empty
+
+go 1.16
 -- empty/pkg/pkg.go --
 package p
 -- empty/pkgtest/pkg.go --
index 59219e33660183e665e9a7d956afc020a4260de5..984f4349f57fcaa02bd24026fece0e9bf26e1c09 100644 (file)
@@ -5,7 +5,11 @@
 stdout '(?s)--- PASS.*--- FAIL.*'
 stdout 'panic: test executed panic\(nil\) or runtime\.Goexit'
 
--- examplegoexit/example_test.go --
+-- go.mod --
+module examplegoexit
+
+go 1.16
+-- example_test.go --
 package main
 
 import (
index c66c1213a428c03ca8de5e03a2cf34805a7653a5..6c60f3d2abe57564a9699e48a6afe42c4a611b10 100644 (file)
@@ -1,9 +1,20 @@
+env GO111MODULE=off
 ! go test testdep/p1
 stderr 'package testdep/p1 \(test\)\n\timports testdep/p2\n\timports testdep/p3: build constraints exclude all Go files ' # check for full import stack
+! go vet testdep/p1
+stderr 'package testdep/p1 \(test\)\n\timports testdep/p2\n\timports testdep/p3: build constraints exclude all Go files ' # check for full import stack
 
+env GO111MODULE=on
+cd testdep
+! go test testdep/p1
+stderr 'package testdep/p1 \(test\)\n\timports testdep/p2\n\timports testdep/p3: build constraints exclude all Go files ' # check for full import stack
 ! go vet testdep/p1
 stderr 'package testdep/p1 \(test\)\n\timports testdep/p2\n\timports testdep/p3: build constraints exclude all Go files ' # check for full import stack
 
+-- testdep/go.mod --
+module testdep
+
+go 1.16
 -- testdep/p1/p1.go --
 package p1
 -- testdep/p1/p1_test.go --
index 1bd530514cf496c785bdb10ab45f4529cdf922b8..cd5b0b9d7a5293269c6bfe5f09d66e80f7ed678a 100644 (file)
@@ -3,23 +3,23 @@
 
 env GOCACHE=$WORK/tmp
 
-# Run go test -json on errors empty/pkg and skipper
+# Run go test -json on errors m/empty/pkg and m/skipper
 # It would be nice to test that the output is interlaced
 # but it seems to be impossible to do that in a short test
 # that isn't also flaky. Just check that we get JSON output.
-go test -json -short -v errors empty/pkg skipper
+go test -json -short -v errors m/empty/pkg m/skipper
 
 # Check errors for run action
 stdout '"Package":"errors"'
 stdout '"Action":"run","Package":"errors"'
 
-# Check empty/pkg for output and skip actions
-stdout '"Action":"output","Package":"empty/pkg","Output":".*no test files'
-stdout '"Action":"skip","Package":"empty/pkg"'
+# Check m/empty/pkg for output and skip actions
+stdout '"Action":"output","Package":"m/empty/pkg","Output":".*no test files'
+stdout '"Action":"skip","Package":"m/empty/pkg"'
 
 # Check skipper for output and skip actions
-stdout '"Action":"output","Package":"skipper","Test":"Test","Output":"--- SKIP:'
-stdout '"Action":"skip","Package":"skipper","Test":"Test"'
+stdout '"Action":"output","Package":"m/skipper","Test":"Test","Output":"--- SKIP:'
+stdout '"Action":"skip","Package":"m/skipper","Test":"Test"'
 
 # Run go test -json on errors and check it's cached
 go test -json -short -v errors
@@ -36,6 +36,10 @@ stdout '"Package":"errors"'
 stdout '"Action":"run"'
 stdout '\{"Action":"pass","Package":"errors"\}'
 
+-- go.mod --
+module m
+
+go 1.16
 -- skipper/skip_test.go --
 package skipper
 
index 1e68dabec0c4b4f0629ea7fae698a2f4d7bb8f44..f32d4fc3b528c8a8a8f3ac1bf2ca1ab849898c52 100644 (file)
@@ -4,7 +4,11 @@ env GOCACHE=$WORK/tmp
 go test -v multimain
 stdout -count=2 notwithstanding # check tests ran twice
 
--- multimain/multimain_test.go --
+-- go.mod --
+module multimain
+
+go 1.16
+-- multimain_test.go --
 package multimain_test
 
 import "testing"
index 92cb690dcc720ac0b7b7091b7ea6a30a15f94b95..e1c96438c85793ab9527d0c2e00f2f1ba8c1f705 100644 (file)
@@ -6,9 +6,13 @@
 ! stderr '(?m)^ok.*\[no tests to run\]'
 stdout 'FAIL'
 
--- syntaxerror/x.go --
+-- go.mod --
+module syntaxerror
+
+go 1.16
+-- x.go --
 package p
--- syntaxerror/x_test.go --
+-- x_test.go --
 package p
 
 func f() (x.y, z int) {
index 66daa310fa32141786866f71ecb3232b18d0681c..53ac755902fb471035f480d9b478d011d7b1909c 100644 (file)
@@ -1,7 +1,11 @@
 go test -v norunexample
 stdout 'File with non-runnable example was built.'
 
--- norunexample/example_test.go --
+-- go.mod --
+module norunexample
+
+go 1.16
+-- example_test.go --
 package pkg_test
 
 import "os"
@@ -13,7 +17,7 @@ func init() {
 func Example_test() {
        // This test will not be run, it has no "Output:" comment.
 }
--- norunexample/test_test.go --
+-- test_test.go --
 package pkg
 
 import (
index d75bcff934fd7eec4f18b93d02bf00b5037ee005..2d624d1da6bb61db145abf9e05567d676606f22d 100644 (file)
@@ -3,7 +3,11 @@
 go test testnorun
 stdout 'testnorun\t\[no test files\]'
 
--- testnorun/p.go --
+-- go.mod --
+module testnorun
+
+go 1.16
+-- p.go --
 package p
 
 func init() {
index 5d15189e195722bd68035a760ade8c5744a5a6b2..2ffea4609256861b9a786e0dd7746707649d84e9 100644 (file)
@@ -13,7 +13,11 @@ stdout 'FAIL: BenchmarkRace'
 ! stdout 'PASS'
 ! stderr 'PASS'
 
--- testrace/race_test.go --
+-- go.mod --
+module testrace
+
+go 1.16
+-- race_test.go --
 package testrace
 
 import "testing"
index bff9502ac716b6212e8ed16f35d80f766563024f..eacc882091a7c2acc35e747652e69caaa3380b28 100644 (file)
@@ -10,7 +10,11 @@ stderr '-covermode must be "atomic", not "set", when -race is enabled'
 ! stdout PASS
 ! stderr PASS
 
--- testrace/race_test.go --
+-- go.mod --
+module testrace
+
+go 1.16
+-- race_test.go --
 package testrace
 
 import "testing"
index 66dc19ebb6c8161710489b6f383fc1053ae1a76c..d28809bfdc30bdad43e0121f3237db01d3cc5ffc 100644 (file)
@@ -8,6 +8,10 @@ go install -race -pkgdir=$WORKDIR/tmp/pkg std
 go test -race -pkgdir=$WORKDIR/tmp/pkg -i -v empty/pkg
 ! stderr .
 
--- empty/pkg/pkg.go --
+-- go.mod --
+module empty
+
+go 1.16
+-- pkg/pkg.go --
 package p
 
index feddc8f9220e05ab1207685cbf6cea87bd8f1aa1..82f00f20862565c322c7bafe6368e9bb4302bfc5 100644 (file)
@@ -5,7 +5,7 @@
 [!darwin] ! stale cmd/cgo  # The darwin builders are spuriously stale; see #33598.
 
 env GOBIN=$WORK/bin
-go install mtime sametime
+go install m/mtime m/sametime
 
 go tool -n cgo
 cp stdout cgopath.txt
@@ -21,6 +21,10 @@ exec $GOBIN/mtime cgopath.txt # get the mtime of the file whose name is in cgopa
 cp stdout cgotime_after.txt
 exec $GOBIN/sametime cgotime_before.txt cgotime_after.txt
 
+-- go.mod --
+module m
+
+go 1.16
 -- mtime/mtime.go --
 package main
 
index a616195caba9184b448f248680b5d3b494e94d2a..2f33080a00474e3cd7c3c0b656de7a76b775b07c 100644 (file)
@@ -35,7 +35,11 @@ stdout -count=1 '^    z_test.go:18: LOG: XX running N=1$'
 # a large number, and the last iteration count prints right before the results.
 stdout -count=2 '^    x_test.go:15: LOG: Y running N=[1-9]\d{4,}\nBenchmarkX/Y\s+\d+'
 
--- testregexp/x_test.go --
+-- go.mod --
+module testregexp
+
+go 1.16
+-- x_test.go --
 package x
 
 import "testing"
@@ -53,7 +57,7 @@ func BenchmarkX(b *testing.B) {
                b.Logf("LOG: Y running N=%d", b.N)
        })
 }
--- testregexp/z_test.go --
+-- z_test.go --
 package x
 
 import "testing"
index 0d212b4924cd7a625b32ee7c0cc73f8b3ca98627..938a875b55555e01954454931f067fdebdb56188 100644 (file)
@@ -1,4 +1,5 @@
 # Relative imports in go test
+env GO111MODULE=off # relative import not supported in module mode
 
 # Run tests outside GOPATH.
 env GOPATH=$WORK/tmp
@@ -27,4 +28,4 @@ func TestF(t *testing.T) {
        if F() != p1.F() {
                t.Fatal(F())
        }
-}
\ No newline at end of file
+}
index dafa04ef0259317c6b176eee19d79f207cda1a3b..b2716d8403c9cebfbcafd48ecf015762d7da1db3 100644 (file)
@@ -1,4 +1,5 @@
 # Relative imports in go test -i
+env GO111MODULE=off # relative import not supported in module mode
 
 # Run tests outside GOPATH.
 env GOPATH=$WORK/tmp
@@ -28,4 +29,4 @@ func TestF(t *testing.T) {
        if F() != p1.F() {
                t.Fatal(F())
        }
-}
\ No newline at end of file
+}
index 29fa805b4347236c3468a67a08e23e067cfbd93a..44ff6e2b39533acb14204d2bf8a4e60964283bee 100644 (file)
@@ -1,10 +1,21 @@
 # Test that the error message for a syntax error in a test go file
 # says FAIL.
 
+env GO111MODULE=off
 ! go test syntaxerror
 stderr 'x_test.go:' # check that the error is diagnosed
 stdout 'FAIL' # check that go test says FAIL
 
+env GO111MODULE=on
+cd syntaxerror
+! go test syntaxerror
+stderr 'x_test.go:' # check that the error is diagnosed
+stdout 'FAIL' # check that go test says FAIL
+
+-- syntaxerror/go.mod --
+module syntaxerror
+
+go 1.16
 -- syntaxerror/x.go --
 package p
 -- syntaxerror/x_test.go --
index d72d6728270387f42073895fe5d600d2742711b6..c6a88b6fedee2b74ca87ed3f59ad88aa7c828dde 100644 (file)
@@ -1,9 +1,19 @@
-# Test
+# In GOPATH mode, vendored packages can replace std packages.
+env GO111MODULE=off
 cd vend/hello
 go test -v
 stdout TestMsgInternal
 stdout TestMsgExternal
 
+# In module mode, they cannot.
+env GO111MODULE=on
+! go test -mod=vendor
+stderr 'undefined: strings.Msg'
+
+-- vend/hello/go.mod --
+module vend/hello
+
+go 1.16
 -- vend/hello/hello.go --
 package main
 
index af26b4de7931ad20931b133255c6d7c6c311aef6..5af26b54f9141bb189bbf15b55edef6fa09c0919 100644 (file)
@@ -17,20 +17,24 @@ go test -vet=off p1.go
 stdout '\[no test files\]'
 
 # Test issue #22890
-go test vetcycle
-stdout 'vetcycle.*\[no test files\]'
+go test m/vetcycle
+stdout 'm/vetcycle.*\[no test files\]'
 
 # Test with ...
-! go test vetfail/...
+! go test ./vetfail/...
 stderr 'Printf format %d'
-stdout 'ok\s+vetfail/p2'
+stdout 'ok\s+m/vetfail/p2'
 
 # Check there's no diagnosis of a bad build constraint in vetxonly mode.
 # Use -a so that we need to recompute the vet-specific export data for
 # vetfail/p1.
-go test -a vetfail/p2
+go test -a m/vetfail/p2
 ! stderr 'invalid.*constraint'
 
+-- go.mod --
+module m
+
+go 1.16
 -- p1_test.go --
 package p
 
@@ -74,7 +78,7 @@ func F() {
 -- vetfail/p2/p2.go --
 package p2
 
-import _ "vetfail/p1"
+import _ "m/vetfail/p1"
 
 func F() {
 }
index a6cb9347093afc32505aff98fa3c6abba35a4603..08e67a429e0a899abc7c1db925d2dcbc3dc27bc4 100644 (file)
@@ -2,13 +2,16 @@
 
 [short] skip
 
-cd profiling
 ! go test -cpuprofile cpu.pprof -memprofile mem.pprof -timeout 1ms
 grep . cpu.pprof
 grep . mem.pprof
 
--- profiling/timeout_test.go --
+-- go.mod --
+module profiling
+
+go 1.16
+-- timeout_test.go --
 package timeouttest_test
 import "testing"
 import "time"
-func TestSleep(t *testing.T) { time.Sleep(time.Second) }
\ No newline at end of file
+func TestSleep(t *testing.T) { time.Sleep(time.Second) }
index 01bafb733b58c98878735143a762e876895f123d..8e150dbfc2571d685c3e9f5cee93dd8c190e710a 100644 (file)
@@ -4,11 +4,15 @@ go test xtestonly
 ! stdout '^ok.*\[no tests to run\]'
 stdout '^ok'
 
--- xtestonly/f.go --
+-- go.mod --
+module xtestonly
+
+go 1.16
+-- f.go --
 package xtestonly
 
 func F() int { return 42 }
--- xtestonly/f_test.go --
+-- f_test.go --
 package xtestonly_test
 
 import (
index 4939de080c5025afdc80b0779105d8a880d90e76..839320e4e8a105916acff09f94e12a0a5c23b349 100644 (file)
@@ -3,7 +3,11 @@
 
 go test -race testrace
 
--- testrace/race_test.go --
+-- go.mod --
+module testrace
+
+go 1.16
+-- race_test.go --
 package testrace
 
 import "testing"
index 746a34a7443831924e964139222e30030a18de47..da52f9acf2dca2ac4cb45b9aaece72563354c481 100644 (file)
@@ -1,4 +1,5 @@
 [!windows] [short] stop 'this test only applies to Windows'
+env GO111MODULE=off
 
 go build run_go.go
 exec ./run_go$GOEXE $GOPATH $GOPATH/src/vend/hello
index 35419f36f19206b9130184158afaf710793bec70..df4c27df816fe1b4064d900dfa23abaeb713e137 100644 (file)
@@ -1,4 +1,5 @@
 # Imports
+env GO111MODULE=off
 go list -f  '{{.ImportPath}} {{.Imports}}' 'vend/...' 'vend/vendor/...' 'vend/x/vendor/...'
 cmp stdout want_vendor_imports.txt
 
index aba62697848424e3b0e02337295cc9b4db98ee1d..73bf5956400ce8b28dd115cfeb02d5c65121d335 100644 (file)
@@ -1,7 +1,18 @@
 # Wrong import path
+env GO111MODULE=off
 ! go build vend/x/invalid
 stderr 'must be imported as foo'
 
+env GO111MODULE=
+cd vend/x/invalid
+! go build vend/x/invalid
+stderr 'must be imported as foo'
+
+-- vend/x/invalid/go.mod --
+module vend/x/invalid
+
+go 1.16
+
 -- vend/x/invalid/invalid.go --
 package invalid
 
index 49eb235ba5a05db3e1b722841931d03af731ef5e..ac95c6d3dae1181993f8dbdbe8c2aee1ee91a2f8 100644 (file)
@@ -1,5 +1,6 @@
 # Tests issue #12156, a former index out of range panic.
 
+env GO111MODULE=off
 env GOPATH=$WORK/gopath/src/testvendor2 # vendor/x is directly in $GOPATH, not in $GOPATH/src
 cd $WORK/gopath/src/testvendor2/src/p
 
index d97c6518b4005cc593e6324d647999c686dfcc50..cdab33c0892bff21c93c41a17d155c711be0eb16 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 go get github.com/rsc/go-get-issue-11864
 
@@ -13,4 +14,4 @@ go list -f '{{join .XTestImports "\n"}}' github.com/rsc/go-get-issue-11864/vendo
 stdout 'go-get-issue-11864/vendor/vendor.org/tx2'
 
 go list -f '{{join .XTestImports "\n"}}' github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3
-stdout 'go-get-issue-11864/vendor/vendor.org/tx3'
\ No newline at end of file
+stdout 'go-get-issue-11864/vendor/vendor.org/tx3'
index 220b92f80b188abed2f4e78321ab15e258be89b1..bc8cf0ab3826c4ac7c03d046be810c30a298a9b6 100644 (file)
@@ -1,3 +1,4 @@
+env GO111MODULE=off
 ! go build p
 stderr 'must be imported as x'
 
index f11d790e6f2d2a79d295d085d129da0b4be3fc9e..cfb43bf3433e3d3f882c628a0f80aa635e504020 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 go get github.com/rsc/go-get-issue-11864
 
@@ -16,4 +17,4 @@ go test github.com/rsc/go-get-issue-11864
 go test github.com/rsc/go-get-issue-11864/t
 
 # external tests should observe internal test exports (golang.org/issue/11977)
-go test github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2
\ No newline at end of file
+go test github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2
index 4e5e066d6bab8ad89cb7649584fa1e6716b83a7c..7801e6944d22f2221dd857cdd32803616a313b80 100644 (file)
@@ -1,5 +1,6 @@
 [!net] skip
 [!exec:git] skip
+env GO111MODULE=off
 
 cd $GOPATH
 
index 73fe2958fc175578535ee291dec2645834d23cf5..6573ae3ebdffeaef50e901dd7fe3a4393653ecbb 100644 (file)
@@ -1,29 +1,33 @@
 # Package with external tests
-! go vet vetpkg
+! go vet m/vetpkg
 stderr 'Printf'
 
 # With tags
-! go vet -tags tagtest vetpkg
+! go vet -tags tagtest m/vetpkg
 stderr 'c\.go.*Printf'
 
 # With flags on
-! go vet -printf vetpkg
+! go vet -printf m/vetpkg
 stderr 'Printf'
 
 # With flags off
-go vet -printf=false vetpkg
+go vet -printf=false m/vetpkg
 ! stderr .
 
 # With only test files (tests issue #23395)
-go vet onlytest
+go vet m/onlytest
 ! stderr .
 
 # With only cgo files (tests issue #24193)
 [!cgo] skip
 [short] skip
-go vet onlycgo
+go vet m/onlycgo
 ! stderr .
 
+-- go.mod --
+module m
+
+go 1.16
 -- vetpkg/a_test.go --
 package p_test
 -- vetpkg/b.go --
@@ -55,4 +59,4 @@ package p
 
 import "C"
 
-func F() {}
\ No newline at end of file
+func F() {}