Skip to content

Commit c546321

Browse files
committed
cmd/api: skip TestIssue29837 when -short is set
TestIssue29837 takes a long time to run, ~150s on my laptop and ~40s on CI builders. While here, warm up the go list cache in parallel, which reduces the test time by ~10%. Change-Id: Ib8d45b086453ee03e6c9f3f070d6f6b0d324bfd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/502095 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Quim Muntal <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 9fc8436 commit c546321

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/cmd/api/api_test.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,7 @@ func BenchmarkAll(b *testing.B) {
209209
}
210210
}
211211

212-
func TestIssue21181(t *testing.T) {
213-
if testing.Short() {
214-
t.Skip("skipping with -short")
215-
}
216-
if *flagCheck {
217-
// slow, not worth repeating in -check
218-
t.Skip("skipping with -check set")
219-
}
220-
testenv.MustHaveGoBuild(t)
221-
212+
var warmupCache = sync.OnceFunc(func() {
222213
// Warm up the import cache in parallel.
223214
var wg sync.WaitGroup
224215
for _, context := range contexts {
@@ -230,6 +221,19 @@ func TestIssue21181(t *testing.T) {
230221
}()
231222
}
232223
wg.Wait()
224+
})
225+
226+
func TestIssue21181(t *testing.T) {
227+
if testing.Short() {
228+
t.Skip("skipping with -short")
229+
}
230+
if *flagCheck {
231+
// slow, not worth repeating in -check
232+
t.Skip("skipping with -check set")
233+
}
234+
testenv.MustHaveGoBuild(t)
235+
236+
warmupCache()
233237

234238
for _, context := range contexts {
235239
w := NewWalker(context, "testdata/src/issue21181")
@@ -243,11 +247,17 @@ func TestIssue21181(t *testing.T) {
243247
}
244248

245249
func TestIssue29837(t *testing.T) {
250+
if testing.Short() {
251+
t.Skip("skipping with -short")
252+
}
246253
if *flagCheck {
247254
// slow, not worth repeating in -check
248255
t.Skip("skipping with -check set")
249256
}
250257
testenv.MustHaveGoBuild(t)
258+
259+
warmupCache()
260+
251261
for _, context := range contexts {
252262
w := NewWalker(context, "testdata/src/issue29837")
253263
_, err := w.ImportFrom("p", "", 0)

0 commit comments

Comments
 (0)