aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/script_test.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-03-03 14:48:10 +0000
committerBryan Mills <bcmills@google.com>2023-04-24 15:54:04 +0000
commit33c06ee12a53e293f4a787c1dfde7eb7ddb0be63 (patch)
tree22ef74e2df2a60a2cafc50a06a04ed43e0ac3604 /src/cmd/go/script_test.go
parentc2c787d73e6fadd57ebcc9fb07532332637b9164 (diff)
downloadgo-33c06ee12a53e293f4a787c1dfde7eb7ddb0be63.tar.gz
go-33c06ee12a53e293f4a787c1dfde7eb7ddb0be63.zip
cmd/go: declare net hosts in script tests
Although we aren't precise about enforcing the hosts just yet, we can eventually use the declared hostnames to selectively skip tests (for example, if an external service has an outage while a Go release is being tested). Also relax the constraint to [short] in tests that require only vcs-test.golang.org, which has redirected to an in-process server since around CL 427914. Also enforce that tests that use the network actually use the [net] constraint, by setting TESTGONETWORK=panic in the test environment until the condition is evaluated. For #52545. For #54503. Updates #27494. Change-Id: I13be6b42a9beee97657eb45424882e787ac164c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/473276 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/script_test.go')
-rw-r--r--src/cmd/go/script_test.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go
index 4211fb6121..072a2dfef5 100644
--- a/src/cmd/go/script_test.go
+++ b/src/cmd/go/script_test.go
@@ -210,6 +210,7 @@ func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) {
"GOROOT=" + testGOROOT,
"GOROOT_FINAL=" + testGOROOT_FINAL, // causes spurious rebuilds and breaks the "stale" built-in if not propagated
"GOTRACEBACK=system",
+ "TESTGONETWORK=panic", // allow only local connections by default; the [net] condition resets this
"TESTGO_GOROOT=" + testGOROOT,
"TESTGO_EXE=" + testGo,
"TESTGO_VCSTEST_HOST=" + httpURL.Host,
@@ -232,8 +233,11 @@ func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) {
"GIT_TRACE_CURL_NO_DATA=1",
"GIT_REDACT_COOKIES=o,SSO,GSSO_Uberproxy")
}
- if !testenv.HasExternalNetwork() {
- env = append(env, "TESTGONETWORK=panic", "TESTGOVCS=panic")
+ if testing.Short() {
+ // VCS commands are always somewhat slow: they either require access to external hosts,
+ // or they require our intercepted vcs-test.golang.org to regenerate the repository.
+ // Require all tests that use VCS commands to be skipped in short mode.
+ env = append(env, "TESTGOVCS=panic")
}
if os.Getenv("CGO_ENABLED") != "" || runtime.GOOS != goHostOS || runtime.GOARCH != goHostArch {
// If the actual CGO_ENABLED might not match the cmd/go default, set it