]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modfetch: fix GOSUMDB test failures
authorBryan C. Mills <bcmills@google.com>
Fri, 10 May 2019 19:26:56 +0000 (15:26 -0400)
committerBryan C. Mills <bcmills@google.com>
Mon, 13 May 2019 17:15:46 +0000 (17:15 +0000)
Use cfg.GOSUMDB consistently instead of re-resolving it from the environment.

Set cfg.GOSUMDB to 'off' explicitly in coderepo_test, since it may
include modules that cannot be fetched using a released version of the
'go' command.

Fixes #31964

Change-Id: I17cae9e0c6aa1168ba534e6da4e3652800ac81e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/176538
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/modfetch/coderepo_test.go
src/cmd/go/internal/modfetch/sumdb.go

index fcea6a0c1b02041bad9e6c9d9437e3c0ab0ee39a..724602233c5510eac843064e441a28ca071e6bca 100644 (file)
@@ -16,6 +16,7 @@ import (
        "testing"
        "time"
 
+       "cmd/go/internal/cfg"
        "cmd/go/internal/modfetch/codehost"
 )
 
@@ -26,6 +27,12 @@ func TestMain(m *testing.M) {
 func testMain(m *testing.M) int {
        SetProxy("direct")
 
+       // The sum database is populated using a released version of the go command,
+       // but this test may include fixes for additional modules that previously
+       // could not be fetched. Since this test isn't executing any of the resolved
+       // code, bypass the sum database.
+       cfg.GOSUMDB = "off"
+
        dir, err := ioutil.TempDir("", "gitrepo-test-")
        if err != nil {
                log.Fatal(err)
index ebfb95b7160fe2ed83f1011ac022525fa7f80b74..0af7219914a318bd3bc2aa5c637ab5fad7acc87b 100644 (file)
@@ -60,7 +60,7 @@ func dbDial() (dbName string, db *sumweb.Conn, err error) {
        // $GOSUMDB can be "key" or "key url",
        // and the key can be a full verifier key
        // or a host on our list of known keys.
-       key := strings.Fields(cfg.Getenv("GOSUMDB"))
+       key := strings.Fields(cfg.GOSUMDB)
        if len(key) >= 1 {
                if k := knownGOSUMDB[key[0]]; k != "" {
                        key[0] = k