Commit 5f320f96 authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go/internal/modfetch: fix GOSUMDB test failures

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: default avatarJay Conrod <jayconrod@google.com>
parent db2bf154
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"testing" "testing"
"time" "time"
"cmd/go/internal/cfg"
"cmd/go/internal/modfetch/codehost" "cmd/go/internal/modfetch/codehost"
) )
...@@ -26,6 +27,12 @@ func TestMain(m *testing.M) { ...@@ -26,6 +27,12 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int { func testMain(m *testing.M) int {
SetProxy("direct") 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-") dir, err := ioutil.TempDir("", "gitrepo-test-")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
......
...@@ -60,7 +60,7 @@ func dbDial() (dbName string, db *sumweb.Conn, err error) { ...@@ -60,7 +60,7 @@ func dbDial() (dbName string, db *sumweb.Conn, err error) {
// $GOSUMDB can be "key" or "key url", // $GOSUMDB can be "key" or "key url",
// and the key can be a full verifier key // and the key can be a full verifier key
// or a host on our list of known keys. // 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 len(key) >= 1 {
if k := knownGOSUMDB[key[0]]; k != "" { if k := knownGOSUMDB[key[0]]; k != "" {
key[0] = k key[0] = k
......
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