From c5463218a228b082661df3f5f1ba0492a4d3df18 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 9 Jun 2023 17:41:36 +0200 Subject: [PATCH] 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 Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Quim Muntal Reviewed-by: Dmitri Shuralyov --- src/cmd/api/api_test.go | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/cmd/api/api_test.go b/src/cmd/api/api_test.go index 53ae6fd2c8..a5ac49ce2d 100644 --- a/src/cmd/api/api_test.go +++ b/src/cmd/api/api_test.go @@ -209,16 +209,7 @@ func BenchmarkAll(b *testing.B) { } } -func TestIssue21181(t *testing.T) { - if testing.Short() { - t.Skip("skipping with -short") - } - if *flagCheck { - // slow, not worth repeating in -check - t.Skip("skipping with -check set") - } - testenv.MustHaveGoBuild(t) - +var warmupCache = sync.OnceFunc(func() { // Warm up the import cache in parallel. var wg sync.WaitGroup for _, context := range contexts { @@ -230,6 +221,19 @@ func TestIssue21181(t *testing.T) { }() } wg.Wait() +}) + +func TestIssue21181(t *testing.T) { + if testing.Short() { + t.Skip("skipping with -short") + } + if *flagCheck { + // slow, not worth repeating in -check + t.Skip("skipping with -check set") + } + testenv.MustHaveGoBuild(t) + + warmupCache() for _, context := range contexts { w := NewWalker(context, "testdata/src/issue21181") @@ -243,11 +247,17 @@ func TestIssue21181(t *testing.T) { } func TestIssue29837(t *testing.T) { + if testing.Short() { + t.Skip("skipping with -short") + } if *flagCheck { // slow, not worth repeating in -check t.Skip("skipping with -check set") } testenv.MustHaveGoBuild(t) + + warmupCache() + for _, context := range contexts { w := NewWalker(context, "testdata/src/issue29837") _, err := w.ImportFrom("p", "", 0)