aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeschi Kreinick <heschi@google.com>2019-05-24 14:32:38 -0400
committerHeschi Kreinick <heschi@google.com>2019-05-24 18:48:02 +0000
commitd487f80763e23959f9c7535d03cf4a1573d6c4a5 (patch)
treefc3fa80184fcb64530f2114e4b516bf1aea87a90
parent2c0ae70061356820330c96810d9483beb9a6da8e (diff)
downloadgolang-x-tools-d487f80763e23959f9c7535d03cf4a1573d6c4a5.tar.gz
all: GOSUMDB=off for tests that use fake modules
Users of packagestest will create modules that don't exist on the Internet and can change. There's no point in checking sum.golang.org for them under any circumstances. Similarly for the various goimports tests. Fixes golang/go#32216. Change-Id: Id9a6b660564cb744530bf9d209fca19008fb9c4f Reviewed-on: https://go-review.googlesource.com/c/tools/+/178722 Reviewed-by: Ian Cottrell <iancottrell@google.com>
-rw-r--r--go/packages/packagestest/modules.go4
-rw-r--r--internal/imports/fix.go5
-rw-r--r--internal/imports/fix_test.go1
-rw-r--r--internal/imports/mod_test.go1
4 files changed, 8 insertions, 3 deletions
diff --git a/go/packages/packagestest/modules.go b/go/packages/packagestest/modules.go
index 2e06612c1..6d46d9ba7 100644
--- a/go/packages/packagestest/modules.go
+++ b/go/packages/packagestest/modules.go
@@ -116,7 +116,9 @@ func (modules) Finalize(exported *Exported) error {
exported.Config.Env = append(exported.Config.Env,
"GO111MODULE=on",
"GOPATH="+filepath.Join(exported.temp, "modcache"),
- "GOPROXY="+proxyDirToURL(proxyDir))
+ "GOPROXY="+proxyDirToURL(proxyDir),
+ "GOSUMDB=off",
+ )
// Run go mod download to recreate the mod cache dir with all the extra
// stuff in cache. All the files created by Export should be recreated.
diff --git a/internal/imports/fix.go b/internal/imports/fix.go
index 3af3a1429..7a465b7d6 100644
--- a/internal/imports/fix.go
+++ b/internal/imports/fix.go
@@ -506,8 +506,8 @@ type ProcessEnv struct {
// If non-empty, these will be used instead of the
// process-wide values.
- GOPATH, GOROOT, GO111MODULE, GOPROXY, GOFLAGS string
- WorkingDir string
+ GOPATH, GOROOT, GO111MODULE, GOPROXY, GOFLAGS, GOSUMDB string
+ WorkingDir string
// If true, use go/packages regardless of the environment.
ForceGoPackages bool
@@ -527,6 +527,7 @@ func (e *ProcessEnv) env() []string {
add("GO111MODULE", e.GO111MODULE)
add("GOPROXY", e.GOPROXY)
add("GOFLAGS", e.GOFLAGS)
+ add("GOSUMDB", e.GOSUMDB)
if e.WorkingDir != "" {
add("PWD", e.WorkingDir)
}
diff --git a/internal/imports/fix_test.go b/internal/imports/fix_test.go
index 4f106969d..3a8445a20 100644
--- a/internal/imports/fix_test.go
+++ b/internal/imports/fix_test.go
@@ -1572,6 +1572,7 @@ func (c testConfig) test(t *testing.T, fn func(*goimportTest)) {
GOROOT: env["GOROOT"],
GOPATH: env["GOPATH"],
GO111MODULE: env["GO111MODULE"],
+ GOSUMDB: env["GOSUMDB"],
WorkingDir: exported.Config.Dir,
ForceGoPackages: forceGoPackages,
Debug: *testDebug,
diff --git a/internal/imports/mod_test.go b/internal/imports/mod_test.go
index cda414706..590b1c89d 100644
--- a/internal/imports/mod_test.go
+++ b/internal/imports/mod_test.go
@@ -520,6 +520,7 @@ func setup(t *testing.T, main, wd string) *modTest {
GOPATH: filepath.Join(dir, "gopath"),
GO111MODULE: "on",
GOPROXY: proxyDirToURL(proxyDir),
+ GOSUMDB: "off",
WorkingDir: filepath.Join(mainDir, wd),
}