| // Copyright 2023 The Go Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style | |
| // license that can be found in the LICENSE file. | |
| // Package testenv provides information about what functionality | |
| // is available in different testing environments run by the Go team. | |
| // | |
| // It is an internal package because these details are specific | |
| // to the Go team's test setup (on build.golang.org) and not | |
| // fundamental to tests in general. | |
| package testenv | |
| import ( | |
| "runtime" | |
| "testing" | |
| ) | |
| // MustHaveExternalNetwork checks that the current system can use | |
| // external (non-localhost) networks. | |
| // If not, MustHaveExternalNetwork calls t.Skip with an explanation. | |
| func MustHaveExternalNetwork(t testing.TB) { | |
| if runtime.GOOS == "js" || runtime.GOOS == "wasip1" { | |
| t.Helper() | |
| t.Skipf("skipping test: no external network on %s", runtime.GOOS) | |
| } | |
| if testing.Short() { | |
| t.Helper() | |
| t.Skipf("skipping test: no external network in -short mode") | |
| } | |
| } |