Skip to content

Commit 86a0e67

Browse files
jcajkaianlancetaylor
authored andcommitted
cmd/go: call flag.Parse to properly initialize test environment variables
Executing tests in src/cmd/go/internal/modfetch/codehost/git_test.go in enviroment witout outside connectivity in to the internet results in tests failure: 2018/07/13 14:31:14 git clone --mirror https://vcs-test.golang.org/git/gitrepo1 /tmp/gitrepo-test-996701800/gitrepo2 in : exit status 128: Cloning into bare repository '/tmp/gitrepo-test-996701800/gitrepo2'... fatal: unable to access 'https://vcs-test.golang.org/git/gitrepo1/': Could not resolve host: vcs-test.golang.org FAIL cmd/go/internal/modfetch/codehost 0.307s Fixes #26007 Change-Id: Ia39d8b3215c920dad6c0c58ffabb0b2ab39bb55c Reviewed-on: https://go-review.googlesource.com/123735 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 28502b5 commit 86a0e67

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/cmd/go/internal/modfetch/codehost/git_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package codehost
77
import (
88
"archive/zip"
99
"bytes"
10+
"flag"
1011
"fmt"
1112
"internal/testenv"
1213
"io/ioutil"
@@ -22,6 +23,9 @@ import (
2223
)
2324

2425
func TestMain(m *testing.M) {
26+
// needed for initializing the test environment variables as testing.Short
27+
// and HasExternalNetwork
28+
flag.Parse()
2529
os.Exit(testMain(m))
2630
}
2731

0 commit comments

Comments
 (0)