tempdir string
ran bool
inParallel bool
- hasNet bool
stdout, stderr bytes.Buffer
execDir string // dir for tg.run
}
if tg.ran {
tg.t.Fatal("internal testsuite error: call to parallel after run")
}
- if tg.hasNet {
- tg.t.Fatal("internal testsuite error: call to parallel after acquireNet")
- }
for _, e := range tg.env {
if strings.HasPrefix(e, "GOROOT=") || strings.HasPrefix(e, "GOPATH=") || strings.HasPrefix(e, "GOBIN=") {
val := e[strings.Index(e, "=")+1:]
tg.t.Parallel()
}
-// acquireNet skips t if the network is unavailable, and otherwise acquires a
-// netTestSem token for t to be released at the end of the test.
-//
-// t.Parallel must not be called after acquireNet.
-func (tg *testgoData) acquireNet() {
- tg.t.Helper()
- if tg.hasNet {
- return
- }
-
- testenv.MustHaveExternalNetwork(tg.t)
- if netTestSem != nil {
- netTestSem <- struct{}{}
- tg.t.Cleanup(func() { <-netTestSem })
- }
- tg.setenv("TESTGONETWORK", "")
- tg.hasNet = true
-}
-
// pwd returns the current directory.
func (tg *testgoData) pwd() string {
tg.t.Helper()