Commit dccd5da0 authored by Russ Cox's avatar Russ Cox

cmd/go: cut 'go test -short cmd/go' time by about half

Was 50 seconds on unloaded Mac laptop; now 27.
Still longer than I would like, but every little bit helps.

For #26473.

Change-Id: Id4be016ee1555cbc3512eca0ae10236d7f06bd02
Reviewed-on: https://go-review.googlesource.com/c/go/+/177398
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 0c47e24d
...@@ -1898,6 +1898,7 @@ func TestGoListTest(t *testing.T) { ...@@ -1898,6 +1898,7 @@ func TestGoListTest(t *testing.T) {
} }
func TestGoListCompiledCgo(t *testing.T) { func TestGoListCompiledCgo(t *testing.T) {
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.parallel() tg.parallel()
...@@ -2537,6 +2538,7 @@ func TestCoverageRuns(t *testing.T) { ...@@ -2537,6 +2538,7 @@ func TestCoverageRuns(t *testing.T) {
func TestCoverageDotImport(t *testing.T) { func TestCoverageDotImport(t *testing.T) {
skipIfGccgo(t, "gccgo has no cover tool") skipIfGccgo(t, "gccgo has no cover tool")
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.parallel() tg.parallel()
...@@ -2716,6 +2718,7 @@ func TestCoverageFunc(t *testing.T) { ...@@ -2716,6 +2718,7 @@ func TestCoverageFunc(t *testing.T) {
// Issue 24588. // Issue 24588.
func TestCoverageDashC(t *testing.T) { func TestCoverageDashC(t *testing.T) {
skipIfGccgo(t, "gccgo has no cover tool") skipIfGccgo(t, "gccgo has no cover tool")
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.parallel() tg.parallel()
...@@ -3391,6 +3394,7 @@ func TestVetWithOnlyCgoFiles(t *testing.T) { ...@@ -3391,6 +3394,7 @@ func TestVetWithOnlyCgoFiles(t *testing.T) {
if !canCgo { if !canCgo {
t.Skip("skipping because cgo not enabled") t.Skip("skipping because cgo not enabled")
} }
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
...@@ -5654,6 +5658,7 @@ func TestTestSkipVetAfterFailedBuild(t *testing.T) { ...@@ -5654,6 +5658,7 @@ func TestTestSkipVetAfterFailedBuild(t *testing.T) {
} }
func TestTestVetRebuild(t *testing.T) { func TestTestVetRebuild(t *testing.T) {
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.parallel() tg.parallel()
...@@ -5933,6 +5938,7 @@ func TestBadCgoDirectives(t *testing.T) { ...@@ -5933,6 +5938,7 @@ func TestBadCgoDirectives(t *testing.T) {
if !canCgo { if !canCgo {
t.Skip("no cgo") t.Skip("no cgo")
} }
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
...@@ -6047,6 +6053,7 @@ func TestTwoPkgConfigs(t *testing.T) { ...@@ -6047,6 +6053,7 @@ func TestTwoPkgConfigs(t *testing.T) {
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" { if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
t.Skipf("no shell scripts on %s", runtime.GOOS) t.Skipf("no shell scripts on %s", runtime.GOOS)
} }
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.parallel() tg.parallel()
...@@ -6077,6 +6084,8 @@ func TestCgoCache(t *testing.T) { ...@@ -6077,6 +6084,8 @@ func TestCgoCache(t *testing.T) {
if !canCgo { if !canCgo {
t.Skip("no cgo") t.Skip("no cgo")
} }
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.parallel() tg.parallel()
...@@ -6127,6 +6136,7 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) { ...@@ -6127,6 +6136,7 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) {
if !canCgo { if !canCgo {
t.Skip("skipping because cgo not enabled") t.Skip("skipping because cgo not enabled")
} }
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
...@@ -6216,6 +6226,7 @@ func TestGoTestWithoutTests(t *testing.T) { ...@@ -6216,6 +6226,7 @@ func TestGoTestWithoutTests(t *testing.T) {
// Issue 25579. // Issue 25579.
func TestGoBuildDashODevNull(t *testing.T) { func TestGoBuildDashODevNull(t *testing.T) {
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.parallel() tg.parallel()
...@@ -6228,6 +6239,7 @@ func TestGoBuildDashODevNull(t *testing.T) { ...@@ -6228,6 +6239,7 @@ func TestGoBuildDashODevNull(t *testing.T) {
// Issue 25093. // Issue 25093.
func TestCoverpkgTestOnly(t *testing.T) { func TestCoverpkgTestOnly(t *testing.T) {
skipIfGccgo(t, "gccgo has no cover tool") skipIfGccgo(t, "gccgo has no cover tool")
tooSlow(t)
tg := testgo(t) tg := testgo(t)
defer tg.cleanup() defer tg.cleanup()
tg.parallel() tg.parallel()
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
# Set GOCACHE to a clean directory to ensure that 'go build' has work to report. # Set GOCACHE to a clean directory to ensure that 'go build' has work to report.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
......
env GO111MODULE=off env GO111MODULE=off
[short] skip # rebuilds std for mips
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
......
env GO111MODULE=off env GO111MODULE=off
[!gc] skip [!gc] skip
[short] skip # clears cache, rebuilds too much
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
......
env GO111MODULE=off env GO111MODULE=off
[short] skip # rebuilds all of std
# Set up fresh GOCACHE. # Set up fresh GOCACHE.
env GOCACHE=$WORK/gocache env GOCACHE=$WORK/gocache
......
[short] skip
env -r GOROOT_REGEXP=$GOROOT env -r GOROOT_REGEXP=$GOROOT
env -r WORK_REGEXP=$WORK env -r WORK_REGEXP=$WORK
env GOROOT GOROOT_REGEXP WORK WORK_REGEXP env GOROOT GOROOT_REGEXP WORK WORK_REGEXP
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
# This test tests that we can link in-package syso files that provides symbols # This test tests that we can link in-package syso files that provides symbols
# for cgo. See issue 29253. # for cgo. See issue 29253.
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
# go clean -testcache # go clean -testcache
# should work (see golang.org/issue/29757). # should work (see golang.org/issue/29757).
......
env GO111MODULE=off env GO111MODULE=off
[!gc] skip 'using -gcflags and -ldflags' [!gc] skip 'using -gcflags and -ldflags'
[short] skip
# -gcflags=-e applies to named packages, not dependencies # -gcflags=-e applies to named packages, not dependencies
go build -n -v -gcflags=-e z1 z2 go build -n -v -gcflags=-e z1 z2
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
[!exec:git] skip [!exec:git] skip
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
# Paths containing windows short names should be rejected before attempting to fetch. # Paths containing windows short names should be rejected before attempting to fetch.
! go get example.com/longna~1.dir/thing ! go get example.com/longna~1.dir/thing
......
env GO111MODULE=off env GO111MODULE=off
[!exec:git] skip [!exec:git] skip
[short] skip
# Construct a repository that imports a non-ASCII path. # Construct a repository that imports a non-ASCII path.
cd $WORK/_origin/example.com/unicode cd $WORK/_origin/example.com/unicode
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
# 'go install' with no arguments should clean up after go build # 'go install' with no arguments should clean up after go build
cd mycmd cd mycmd
......
env GO111MODULE=off env GO111MODULE=off
[!short] skip # rebuilds std for alternate architecture
cd mycmd cd mycmd
go build mycmd go build mycmd
......
env GO111MODULE=off env GO111MODULE=off
[short] skip
# This test matches mod_list_bad_import, but in GOPATH mode. # This test matches mod_list_bad_import, but in GOPATH mode.
# Please keep them in sync. # Please keep them in sync.
......
...@@ -12,6 +12,7 @@ stdout '^false \[\]' ...@@ -12,6 +12,7 @@ stdout '^false \[\]'
# should be identical. "go build" derives action IDs (which are used as cache # should be identical. "go build" derives action IDs (which are used as cache
# keys) from dependencies' action IDs. "go list -find" won't know what the # keys) from dependencies' action IDs. "go list -find" won't know what the
# dependencies are, so it's can't construct the same action IDs. # dependencies are, so it's can't construct the same action IDs.
[short] skip
go list -find -compiled net go list -find -compiled net
go list -find -compiled -x net go list -find -compiled -x net
! stderr 'cgo' ! stderr 'cgo'
......
env GO111MODULE=off env GO111MODULE=off
[!gc] skip [!gc] skip
[short] skip
# Listing GOROOT should only find standard packages. # Listing GOROOT should only find standard packages.
cd $GOROOT/src cd $GOROOT/src
go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' ./... go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' ./...
! stdout . ! stdout .
# TODO: ignore _/blah/go/src in output
# Standard packages should include cmd, but not cmd/vendor. # Standard packages should include cmd, but not cmd/vendor.
go list ./... go list ./...
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
go get -m rsc.io/fortune/v2 go get -m rsc.io/fortune/v2
......
# go doc should find module documentation # go doc should find module documentation
env GO111MODULE=on env GO111MODULE=on
[short] skip
go doc y go doc y
stdout 'Package y is.*alphabet' stdout 'Package y is.*alphabet'
......
...@@ -10,6 +10,7 @@ exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod ...@@ -10,6 +10,7 @@ exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
# download of an invalid path should report the error # download of an invalid path should report the error
[short] skip
! go mod download this.domain.is.invalid/somemodule@v1.0.0 ! go mod download this.domain.is.invalid/somemodule@v1.0.0
stderr 'this.domain.is.invalid' stderr 'this.domain.is.invalid'
! go mod download -json this.domain.is.invalid/somemodule@v1.0.0 ! go mod download -json this.domain.is.invalid/somemodule@v1.0.0
......
[short] skip
# Allow (cached) downloads for -mod=readonly. # Allow (cached) downloads for -mod=readonly.
env GO111MODULE=on env GO111MODULE=on
env GOPATH=$WORK/gopath1 env GOPATH=$WORK/gopath1
......
env GO111MODULE=on env GO111MODULE=on
env GOPROXY=$GOPROXY/quiet env GOPROXY=$GOPROXY/quiet
[short] skip
# @commit should resolve # @commit should resolve
# golang.org/x/text/language@commit should not resolve with -m, # golang.org/x/text/language@commit should not resolve with -m,
# because that's not a module path. # because that's not a module path.
! go get -m golang.org/x/text/language@14c0d48 ! go get -d -m golang.org/x/text/language@14c0d48
# ... but it should work without -m. # ... but it should work without -m.
# because of -d, the compiler should not run # because of -d, the compiler should not run
...@@ -13,12 +14,13 @@ go get -d -x golang.org/x/text/language@14c0d48 ...@@ -13,12 +14,13 @@ go get -d -x golang.org/x/text/language@14c0d48
! stderr 'compile|cp|gccgo .*language\.a$' ! stderr 'compile|cp|gccgo .*language\.a$'
# go get should skip build with no Go files in root # go get should skip build with no Go files in root
go get golang.org/x/text@14c0d48 go get -d golang.org/x/text@14c0d48
# ... and go get should skip build with -m # ... and go get should skip build with -m
go get -m golang.org/x/text@14c0d48 go get -m golang.org/x/text@14c0d48
# dropping -d, we should see a build. # dropping -d, we should see a build.
[short] skip
go get -x golang.org/x/text/language@14c0d48 go get -x golang.org/x/text/language@14c0d48
stderr 'compile|cp|gccgo .*language\.a$' stderr 'compile|cp|gccgo .*language\.a$'
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# downgrade sampler should downgrade quote # downgrade sampler should downgrade quote
go get rsc.io/sampler@v1.0.0 go get rsc.io/sampler@v1.0.0
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# get -u should not upgrade anything, since the package # get -u should not upgrade anything, since the package
# in the current directory doesn't import anything. # in the current directory doesn't import anything.
......
# Test 'go get' with a local module with a name that is not valid for network lookup. # Test 'go get' with a local module with a name that is not valid for network lookup.
[short] skip
env GO111MODULE=on env GO111MODULE=on
go mod edit -fmt go mod edit -fmt
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# @patch and @latest within the main module refer to the current version. # @patch and @latest within the main module refer to the current version.
# The main module won't be upgraded, but missing dependencies will be added. # The main module won't be upgraded, but missing dependencies will be added.
......
env GO111MODULE=on env GO111MODULE=on
env GOPROXY=$GOPROXY/quiet env GOPROXY=$GOPROXY/quiet
[short] skip
# A 'go get' that worked at a previous version should continue to work at that version, # A 'go get' that worked at a previous version should continue to work at that version,
# even if the package was subsequently moved into a submodule. # even if the package was subsequently moved into a submodule.
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# If a pattern doesn't match any modules in the build list, # If a pattern doesn't match any modules in the build list,
# and -m is used, an error should be reported. # and -m is used, an error should be reported.
......
...@@ -6,30 +6,30 @@ stdout 'rsc.io/quote v1.5.1' ...@@ -6,30 +6,30 @@ stdout 'rsc.io/quote v1.5.1'
grep 'rsc.io/quote v1.5.1$' go.mod grep 'rsc.io/quote v1.5.1$' go.mod
# get -m -u should update all dependencies # get -m -u should update all dependencies
go get -m -u go get -d -m -u
grep 'rsc.io/quote v1.5.2$' go.mod grep 'rsc.io/quote v1.5.2$' go.mod
grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod
# get -u rsc.io/sampler should update only sampler's dependencies # get -u rsc.io/sampler should update only sampler's dependencies
cp go.mod-v1.5.1 go.mod cp go.mod-v1.5.1 go.mod
go get -u rsc.io/sampler go get -d -u rsc.io/sampler
grep 'rsc.io/quote v1.5.1$' go.mod grep 'rsc.io/quote v1.5.1$' go.mod
grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod
# move to a pseudo-version after any tags # move to a pseudo-version after any tags
go get -m rsc.io/quote@dd9747d go get -d -m rsc.io/quote@dd9747d
grep 'rsc.io/quote v0.0.0-20180628003336-dd9747d19b04' go.mod grep 'rsc.io/quote v0.0.0-20180628003336-dd9747d19b04' go.mod
# get -u should not jump off newer pseudo-version to earlier tag # get -u should not jump off newer pseudo-version to earlier tag
go get -m -u go get -d -m -u
grep 'rsc.io/quote v0.0.0-20180628003336-dd9747d19b04' go.mod grep 'rsc.io/quote v0.0.0-20180628003336-dd9747d19b04' go.mod
# move to earlier pseudo-version # move to earlier pseudo-version
go get -m rsc.io/quote@e7a685a342 go get -d -m rsc.io/quote@e7a685a342
grep 'rsc.io/quote v0.0.0-20180214005133-e7a685a342c0' go.mod grep 'rsc.io/quote v0.0.0-20180214005133-e7a685a342c0' go.mod
# get -u should jump off earlier pseudo-version to newer tag # get -u should jump off earlier pseudo-version to newer tag
go get -m -u go get -d -m -u
grep 'rsc.io/quote v1.5.2' go.mod grep 'rsc.io/quote v1.5.2' go.mod
-- go.mod -- -- go.mod --
......
[short] skip
# go/build's Import should find modules by invoking the go command # go/build's Import should find modules by invoking the go command
go build -o $WORK/testimport.exe ./testimport go build -o $WORK/testimport.exe ./testimport
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# golang.org/x/internal should be importable from other golang.org/x modules. # golang.org/x/internal should be importable from other golang.org/x modules.
rm go.mod rm go.mod
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# list {{.Dir}} shows main module and go.mod but not not-yet-downloaded dependency dir. # list {{.Dir}} shows main module and go.mod but not not-yet-downloaded dependency dir.
go list -m -f '{{.Path}} {{.Main}} {{.GoMod}} {{.Dir}}' all go list -m -f '{{.Path}} {{.Main}} {{.GoMod}} {{.Dir}}' all
......
[short] skip
# go list with path to directory should work # go list with path to directory should work
env GO111MODULE=off env GO111MODULE=off
......
...@@ -2,6 +2,7 @@ env GO111MODULE=on ...@@ -2,6 +2,7 @@ env GO111MODULE=on
env GOPROXY=off env GOPROXY=off
[!gc] skip [!gc] skip
[short] skip
# Outside of GOROOT, our vendored packages should be reported as part of the standard library. # Outside of GOROOT, our vendored packages should be reported as part of the standard library.
go list -f '{{if .Standard}}{{.ImportPath}}{{end}}' std cmd go list -f '{{if .Standard}}{{.ImportPath}}{{end}}' std cmd
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# This script tests commands in module mode outside of any module. # This script tests commands in module mode outside of any module.
# #
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
cd m cd m
...@@ -29,10 +30,6 @@ stdout 'cmd/pprof: \[\.\.\.\]' ...@@ -29,10 +30,6 @@ stdout 'cmd/pprof: \[\.\.\.\]'
stderr -count=1 '^go: warning: "./xyz..." matched no packages$' stderr -count=1 '^go: warning: "./xyz..." matched no packages$'
env CGO_ENABLED=0
go list -f '{{.ImportPath}}: {{.Match}}' all ... example.com/m/... ./... ./xyz...
! stdout example.com/m/useC
# 'go list ./...' should not try to resolve the main module. # 'go list ./...' should not try to resolve the main module.
cd ../empty cd ../empty
go list -deps ./... go list -deps ./...
...@@ -40,6 +37,12 @@ go list -deps ./... ...@@ -40,6 +37,12 @@ go list -deps ./...
! stderr 'finding' ! stderr 'finding'
stderr -count=1 '^go: warning: "./..." matched no packages' stderr -count=1 '^go: warning: "./..." matched no packages'
# disabling cgo should drop useC
[short] skip
env CGO_ENABLED=0
go list -f '{{.ImportPath}}: {{.Match}}' all ... example.com/m/... ./... ./xyz...
! stdout example.com/m/useC
-- m/go.mod -- -- m/go.mod --
module example.com/m module example.com/m
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# -mod=readonly must not resolve missing modules nor update go.mod # -mod=readonly must not resolve missing modules nor update go.mod
# #
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
cp go.mod go.mod.orig cp go.mod go.mod.orig
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# TODO(bcmills): Convert the 'go test' calls below to 'go list -test' once 'go # TODO(bcmills): Convert the 'go test' calls below to 'go list -test' once 'go
# list' is more sensitive to package loading errors. # list' is more sensitive to package loading errors.
...@@ -6,8 +7,8 @@ env GO111MODULE=on ...@@ -6,8 +7,8 @@ env GO111MODULE=on
# A test in the module's root package should work. # A test in the module's root package should work.
cd a/ cd a/
cp go.mod.empty go.mod cp go.mod.empty go.mod
go test go list -test
stdout PASS ! stderr error
cp go.mod.empty go.mod cp go.mod.empty go.mod
go list -deps go list -deps
...@@ -33,27 +34,27 @@ go list -test all ...@@ -33,27 +34,27 @@ go list -test all
stdout '^testing' stdout '^testing'
cp go.mod.empty go.mod cp go.mod.empty go.mod
go test go list -test
stdout PASS ! stderr error
# A test with the "_test" suffix in the module root should also work. # A test with the "_test" suffix in the module root should also work.
cd ../b/ cd ../b/
go test go list -test
stdout PASS ! stderr error
# A test with the "_test" suffix of a *package* with a "_test" suffix should # A test with the "_test" suffix of a *package* with a "_test" suffix should
# even work (not that you should ever do that). # even work (not that you should ever do that).
cd ../c_test cd ../c_test
go test go list -test
stdout PASS ! stderr error
cd ../d_test cd ../d_test
go test go list -test
stdout PASS ! stderr error
cd ../e cd ../e
go test go list -test
stdout PASS ! stderr error
-- a/go.mod.empty -- -- a/go.mod.empty --
module example.com/user/a module example.com/user/a
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# golang.org/issue/30166: 'go mod tidy' should not crash if a replaced module is # golang.org/issue/30166: 'go mod tidy' should not crash if a replaced module is
# involved in a cycle. # involved in a cycle.
......
env GO111MODULE=on env GO111MODULE=on
# go.sum should list directly used modules and dependencies # go.sum should list directly used modules and dependencies
go get rsc.io/quote@v1.5.2 go get -d rsc.io/quote@v1.5.2
go mod tidy go mod tidy
grep rsc.io/sampler go.sum grep rsc.io/sampler go.sum
# go.sum should not normally lose old entries # go.sum should not normally lose old entries
go get rsc.io/quote@v1.0.0 go get -d rsc.io/quote@v1.0.0
grep 'rsc.io/quote v1.0.0' go.sum grep 'rsc.io/quote v1.0.0' go.sum
grep 'rsc.io/quote v1.5.2' go.sum grep 'rsc.io/quote v1.5.2' go.sum
grep rsc.io/sampler go.sum grep rsc.io/sampler go.sum
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# Initially, we are at v1.0.0 for all dependencies. # Initially, we are at v1.0.0 for all dependencies.
cp go.mod go.mod.orig cp go.mod go.mod.orig
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# Initially, we are at v1.0.0 for all dependencies. # Initially, we are at v1.0.0 for all dependencies.
cp go.mod go.mod.orig cp go.mod go.mod.orig
...@@ -11,7 +12,7 @@ stdout '^patch.example.com/indirect v1.0.0' ...@@ -11,7 +12,7 @@ stdout '^patch.example.com/indirect v1.0.0'
# of the package in the current directory, pulling in transitive dependencies # of the package in the current directory, pulling in transitive dependencies
# and also patching those. # and also patching those.
cp go.mod.orig go.mod cp go.mod.orig go.mod
go get -u=patch go get -d -u=patch
go list -m all go list -m all
stdout '^patch.example.com/direct v1.0.1' stdout '^patch.example.com/direct v1.0.1'
stdout '^patch.example.com/indirect v1.0.1' stdout '^patch.example.com/indirect v1.0.1'
...@@ -19,7 +20,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0' ...@@ -19,7 +20,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0'
# 'get all@patch' should be equivalent to 'get -u=patch all' # 'get all@patch' should be equivalent to 'get -u=patch all'
cp go.mod.orig go.mod cp go.mod.orig go.mod
go get all@patch go get -d all@patch
go list -m all go list -m all
stdout '^patch.example.com/direct v1.0.1' stdout '^patch.example.com/direct v1.0.1'
stdout '^patch.example.com/indirect v1.0.1' stdout '^patch.example.com/indirect v1.0.1'
...@@ -28,7 +29,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0' ...@@ -28,7 +29,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0'
# Requesting the direct dependency with -u=patch but without an explicit version # Requesting the direct dependency with -u=patch but without an explicit version
# should patch-update it and its dependencies. # should patch-update it and its dependencies.
cp go.mod.orig go.mod cp go.mod.orig go.mod
go get -u=patch patch.example.com/direct go get -d -u=patch patch.example.com/direct
go list -m all go list -m all
stdout '^patch.example.com/direct v1.0.1' stdout '^patch.example.com/direct v1.0.1'
stdout '^patch.example.com/indirect v1.0.1' stdout '^patch.example.com/indirect v1.0.1'
...@@ -36,7 +37,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0' ...@@ -36,7 +37,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0'
# Requesting only the indirect dependency should not update the direct one. # Requesting only the indirect dependency should not update the direct one.
cp go.mod.orig go.mod cp go.mod.orig go.mod
go get -u=patch patch.example.com/indirect go get -d -u=patch patch.example.com/indirect
go list -m all go list -m all
stdout '^patch.example.com/direct v1.0.0' stdout '^patch.example.com/direct v1.0.0'
stdout '^patch.example.com/indirect v1.0.1' stdout '^patch.example.com/indirect v1.0.1'
...@@ -45,7 +46,7 @@ stdout '^patch.example.com/indirect v1.0.1' ...@@ -45,7 +46,7 @@ stdout '^patch.example.com/indirect v1.0.1'
# @patch should apply only to the specific module, # @patch should apply only to the specific module,
# but the result must reflect its upgraded requirements. # but the result must reflect its upgraded requirements.
cp go.mod.orig go.mod cp go.mod.orig go.mod
go get patch.example.com/direct@patch go get -d patch.example.com/direct@patch
go list -m all go list -m all
stdout '^patch.example.com/direct v1.0.1' stdout '^patch.example.com/direct v1.0.1'
stdout '^patch.example.com/indirect v1.0.0' stdout '^patch.example.com/indirect v1.0.0'
...@@ -53,7 +54,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0' ...@@ -53,7 +54,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0'
# An explicit @patch should override a general -u. # An explicit @patch should override a general -u.
cp go.mod.orig go.mod cp go.mod.orig go.mod
go get -u patch.example.com/direct@patch go get -d -u patch.example.com/direct@patch
go list -m all go list -m all
stdout '^patch.example.com/direct v1.0.1' stdout '^patch.example.com/direct v1.0.1'
stdout '^patch.example.com/indirect v1.1.0' stdout '^patch.example.com/indirect v1.1.0'
...@@ -61,7 +62,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0' ...@@ -61,7 +62,7 @@ stdout '^patch.example.com/depofdirectpatch v1.0.0'
# An explicit @latest should override a general -u=patch. # An explicit @latest should override a general -u=patch.
cp go.mod.orig go.mod cp go.mod.orig go.mod
go get -u=patch patch.example.com/direct@latest go get -d -u=patch patch.example.com/direct@latest
go list -m all go list -m all
stdout '^patch.example.com/direct v1.1.0' stdout '^patch.example.com/direct v1.1.0'
stdout '^patch.example.com/indirect v1.0.1' stdout '^patch.example.com/indirect v1.0.1'
...@@ -73,7 +74,7 @@ cp go.mod.orig go.mod ...@@ -73,7 +74,7 @@ cp go.mod.orig go.mod
stderr 'cannot use pattern .* with explicit version' stderr 'cannot use pattern .* with explicit version'
# However, standard-library packages without explicit versions are fine. # However, standard-library packages without explicit versions are fine.
go get -u=patch -d cmd/go go get -d -u=patch -d cmd/go
-- go.mod -- -- go.mod --
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# initial conditions: using sampler v1.3.0, not listed in go.mod. # initial conditions: using sampler v1.3.0, not listed in go.mod.
go list -deps go list -deps
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# With good go.sum, verify succeeds by avoiding download. # With good go.sum, verify succeeds by avoiding download.
cp go.sum.good go.sum cp go.sum.good go.sum
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
go list -test all go list -test all
stdout rsc.io/quote stdout rsc.io/quote
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
# Check for correct naming of temporary executable # Check for correct naming of temporary executable
#Test for single file specified #Test for single file specified
......
# Test that go.sum does not get updated when -mod=readonly flag is set # Test that go.sum does not get updated when -mod=readonly flag is set
env GO111MODULE=on env GO111MODULE=on
go get rsc.io/quote go get -d rsc.io/quote
go mod tidy go mod tidy
# go.sum != dirty; -mod=readonly # go.sum != dirty; -mod=readonly
go build -mod=readonly go list -mod=readonly
# dirty up go.sum by removing it. # dirty up go.sum by removing it.
rm go.sum rm go.sum
# go.sum == dirty; -mod=readonly # go.sum == dirty; -mod=readonly
! go build -mod=readonly ! go list -mod=readonly
stderr 'go: updates to go.sum needed, disabled by -mod=readonly' stderr 'go: updates to go.sum needed, disabled by -mod=readonly'
......
...@@ -4,61 +4,68 @@ env GO111MODULE=on ...@@ -4,61 +4,68 @@ env GO111MODULE=on
# A TestMain should be able to access testing flags if it calls flag.Parse # A TestMain should be able to access testing flags if it calls flag.Parse
# without needing to use testing.Init. # without needing to use testing.Init.
go test testmain_flag_test.go
# Test code can use the name 'testing' without colliding with generated # Test code can use the name 'testing' without colliding with generated
# testinginit code. # testinginit code.
go test testing_collision_test.go
# Tests running under 'go test' should observe that testing.Init is called # Tests running under 'go test' should observe that testing.Init is called
# before any user package initialization code runs. # before any user package initialization code runs.
go test ./testinitflag go test
stdout TestMain
stdout TestInit
stdout TestExt
-- go.mod --
module m
-- testmain_flag_test.go -- -- init_test.go --
package testmain_flag_test package testinitflag
import ( import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"testing" Testing "testing"
) )
func TestMain(m *testing.M) { func testFlagsInitialized() bool {
flag.Parse()
found := false found := false
flag.VisitAll(func(f *flag.Flag) { flag.VisitAll(func(f *flag.Flag) {
if f.Name == "test.count" { if f.Name == "test.count" {
found = true found = true
} }
}) })
if !found { return found
}
var testing int
var testingInitAtInitialization = testFlagsInitialized()
func TestInit(t *Testing.T) {
if !testingInitAtInitialization {
t.Fatal("testing.Init not called before package initialization")
}
fmt.Printf("TestInit\n")
}
func TestMain(m *Testing.M) {
fmt.Printf("TestMain\n")
flag.Parse()
if !testFlagsInitialized() {
fmt.Println("testing flags not registered") fmt.Println("testing flags not registered")
os.Exit(1) os.Exit(1)
} }
os.Exit(m.Run()) os.Exit(m.Run())
} }
func TestX(t *testing.T) {} -- external_test.go --
package testinitflag_test
-- testing_collision_test.go --
package testing_collision_test
import testing2 "testing"
var testing = 3
func TestX(t *testing2.T) {}
-- go.mod --
module m
-- testinitflag/init.go --
package testinitflag
import "flag" import (
"flag"
"fmt"
Testing "testing"
)
func TestFlagsInitialized() bool { func testFlagsInitialized() bool {
found := false found := false
flag.VisitAll(func(f *flag.Flag) { flag.VisitAll(func(f *flag.Flag) {
if f.Name == "test.count" { if f.Name == "test.count" {
...@@ -68,30 +75,11 @@ func TestFlagsInitialized() bool { ...@@ -68,30 +75,11 @@ func TestFlagsInitialized() bool {
return found return found
} }
-- testinitflag/init_test.go -- var testing int
package testinitflag var testingInitAtInitialization = testFlagsInitialized()
import "testing"
var testingInitAtInitialization = TestFlagsInitialized()
func TestInit(t *testing.T) {
if !testingInitAtInitialization {
t.Fatal("testing.Init not called before package initialization")
}
}
-- testinitflag/external_test.go --
package testinitflag_test
import (
"testing"
"m/testinitflag"
)
var testingInitAtInitialization = testinitflag.TestFlagsInitialized()
func TestInitExternal(t *testing.T) { func TestExt(t *Testing.T) {
fmt.Printf("TestExt\n")
if !testingInitAtInitialization { if !testingInitAtInitialization {
t.Fatal("testing.Init not called before package initialization") t.Fatal("testing.Init not called before package initialization")
} }
......
[short] skip
env GO111MODULE=off env GO111MODULE=off
cd a cd a
......
env GO111MODULE=on env GO111MODULE=on
[short] skip
go build -o fortune.exe rsc.io/fortune go build -o fortune.exe rsc.io/fortune
go version fortune.exe go version fortune.exe
stdout '^fortune.exe: .+' stdout '^fortune.exe: .+'
......
...@@ -2,8 +2,7 @@ env GO111MODULE=off ...@@ -2,8 +2,7 @@ env GO111MODULE=off
# Issue 27665. Verify that "go vet" analyzes non-Go files. # Issue 27665. Verify that "go vet" analyzes non-Go files.
env GOOS=linux [!amd64] skip
env GOARCH=amd64
! go vet -asmdecl a ! go vet -asmdecl a
stderr 'f: invalid MOVW of x' stderr 'f: invalid MOVW of x'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment