aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/script_test.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2022-08-17 12:38:27 -0400
committerBryan Mills <bcmills@google.com>2022-10-25 13:22:22 +0000
commit71048daa2f4e0c23b651d56fa157e1a75e098a82 (patch)
tree15e497d83c3e28348bc23246b6ac593822d91dc1 /src/cmd/go/script_test.go
parentd5155f61928a55e570beaa214465bc48ddd2c16c (diff)
downloadgo-71048daa2f4e0c23b651d56fa157e1a75e098a82.tar.gz
go-71048daa2f4e0c23b651d56fa157e1a75e098a82.zip
cmd/go: reroute vcs-test.golang.org HTTPS requests to the test-local server
After this CL, the only test requests that should still reach vcs-test.golang.org are for Subversion repos, which are not yet handled. The interceptor implementation should also allow us to redirect other servers (such as gopkg.in) fairly easily in a followup change if desired. For #27494. Change-Id: I8cb85f3a7edbbf0492662ff5cfa779fb9b407136 Reviewed-on: https://go-review.googlesource.com/c/go/+/427254 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/go/script_test.go')
-rw-r--r--src/cmd/go/script_test.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go
index a2d2cae658..3cbaeff8ad 100644
--- a/src/cmd/go/script_test.go
+++ b/src/cmd/go/script_test.go
@@ -18,6 +18,7 @@ import (
"go/build"
"internal/testenv"
"internal/txtar"
+ "net/url"
"os"
"path/filepath"
"regexp"
@@ -29,7 +30,6 @@ import (
"cmd/go/internal/cfg"
"cmd/go/internal/script"
"cmd/go/internal/script/scripttest"
- "cmd/go/internal/vcs"
"cmd/go/internal/vcweb/vcstest"
)
@@ -49,6 +49,10 @@ func TestScript(t *testing.T) {
t.Fatal(err)
}
})
+ certFile, err := srv.WriteCertificateFile()
+ if err != nil {
+ t.Fatal(err)
+ }
StartProxy()
@@ -79,7 +83,7 @@ func TestScript(t *testing.T) {
t.Cleanup(cancel)
}
- env, err := scriptEnv()
+ env, err := scriptEnv(srv, certFile)
if err != nil {
t.Fatal(err)
}
@@ -175,7 +179,15 @@ func initScriptDirs(t testing.TB, s *script.State) {
must(s.Chdir(gopathSrc))
}
-func scriptEnv() ([]string, error) {
+func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) {
+ httpURL, err := url.Parse(srv.HTTP.URL)
+ if err != nil {
+ return nil, err
+ }
+ httpsURL, err := url.Parse(srv.HTTPS.URL)
+ if err != nil {
+ return nil, err
+ }
version, err := goVersion()
if err != nil {
return nil, err
@@ -199,7 +211,9 @@ func scriptEnv() ([]string, error) {
"GOROOT_FINAL=" + testGOROOT_FINAL, // causes spurious rebuilds and breaks the "stale" built-in if not propagated
"GOTRACEBACK=system",
"TESTGO_GOROOT=" + testGOROOT,
- "TESTGO_VCSTEST_URL=" + vcs.VCSTestRepoURL,
+ "TESTGO_VCSTEST_HOST=" + httpURL.Host,
+ "TESTGO_VCSTEST_TLS_HOST=" + httpsURL.Host,
+ "TESTGO_VCSTEST_CERT=" + srvCertFile,
"GOSUMDB=" + testSumDBVerifierKey,
"GONOPROXY=",
"GONOSUMDB=",