Skip to content

Commit

Permalink
[release-branch.go1.20] cmd/go: avoid running slow tests on non-longt…
Browse files Browse the repository at this point in the history
…est builders

Also annotate calls to tooSlow with specific reasons.

This will somewhat reduce test coverage on the 'darwin' builders until
we have darwin 'longtest' builders (#35678,#49055), but still seems
worthwhile to avoid alert fatigue from tests that really shouldn't be
running in the short configurations.

Updates #58918.
Updates #58919.
Fixes #58938.

Change-Id: I0000f0084b262beeec3eca3e9b8a45d61fab4313
Reviewed-on: https://go-review.googlesource.com/c/go/+/474137
Reviewed-by: Ian Lance Taylor <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
Run-TryBot: Bryan Mills <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
(cherry picked from commit 9f532dd)
Reviewed-on: https://go-review.googlesource.com/c/go/+/474580
  • Loading branch information
Bryan C. Mills authored and cagedmantis committed Mar 9, 2023
1 parent 4df95d5 commit b852f39
Showing 1 changed file with 40 additions and 36 deletions.
76 changes: 40 additions & 36 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@ var exeSuffix string = func() string {
return ""
}()

func tooSlow(t *testing.T) {
func tooSlow(t *testing.T, reason string) {
if testing.Short() {
// In -short mode; skip test, except run it on the {darwin,linux,windows}/amd64 builders.
if testenv.Builder() != "" && runtime.GOARCH == "amd64" && (runtime.GOOS == "linux" || runtime.GOOS == "darwin" || runtime.GOOS == "windows") {
return
}
t.Helper()
t.Skip("skipping test in -short mode")
t.Skipf("skipping test in -short mode: %s", reason)
}
}

Expand Down Expand Up @@ -1085,7 +1081,7 @@ func TestPackageMainTestCompilerFlags(t *testing.T) {

// Issue 4104.
func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
tooSlow(t)
tooSlow(t, "links and runs a test")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -1096,7 +1092,7 @@ func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
}

func TestGoListHasAConsistentOrder(t *testing.T) {
tooSlow(t)
tooSlow(t, "walks all of GOROOT/src twice")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -1109,7 +1105,7 @@ func TestGoListHasAConsistentOrder(t *testing.T) {
}

func TestGoListStdDoesNotIncludeCommands(t *testing.T) {
tooSlow(t)
tooSlow(t, "walks all of GOROOT/src")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -1119,7 +1115,7 @@ func TestGoListStdDoesNotIncludeCommands(t *testing.T) {

func TestGoListCmdOnlyShowsCommands(t *testing.T) {
skipIfGccgo(t, "gccgo does not have GOROOT")
tooSlow(t)
tooSlow(t, "walks all of GOROOT/src/cmd")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand Down Expand Up @@ -1202,7 +1198,8 @@ func TestGoListTest(t *testing.T) {
}

func TestGoListCompiledCgo(t *testing.T) {
tooSlow(t)
tooSlow(t, "compiles cgo files")

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand Down Expand Up @@ -1423,7 +1420,7 @@ func TestDefaultGOPATHPrintedSearchList(t *testing.T) {

func TestLdflagsArgumentsWithSpacesIssue3941(t *testing.T) {
skipIfGccgo(t, "gccgo does not support -ldflags -X")
tooSlow(t)
tooSlow(t, "compiles and links a binary")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -1440,7 +1437,7 @@ func TestLdFlagsLongArgumentsIssue42295(t *testing.T) {
// Test the extremely long command line arguments that contain '\n' characters
// get encoded and passed correctly.
skipIfGccgo(t, "gccgo does not support -ldflags -X")
tooSlow(t)
tooSlow(t, "compiles and links a binary")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -1462,7 +1459,7 @@ func TestLdFlagsLongArgumentsIssue42295(t *testing.T) {

func TestGoTestDashCDashOControlsBinaryLocation(t *testing.T) {
skipIfGccgo(t, "gccgo has no standard packages")
tooSlow(t)
tooSlow(t, "compiles and links a test binary")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -1473,7 +1470,7 @@ func TestGoTestDashCDashOControlsBinaryLocation(t *testing.T) {

func TestGoTestDashOWritesBinary(t *testing.T) {
skipIfGccgo(t, "gccgo has no standard packages")
tooSlow(t)
tooSlow(t, "compiles and runs a test binary")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -1484,7 +1481,7 @@ func TestGoTestDashOWritesBinary(t *testing.T) {

// Issue 4515.
func TestInstallWithTags(t *testing.T) {
tooSlow(t)
tooSlow(t, "compiles and links binaries")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand Down Expand Up @@ -1553,7 +1550,7 @@ func TestCgoShowsFullPathNames(t *testing.T) {
}

func TestCgoHandlesWlORIGIN(t *testing.T) {
tooSlow(t)
tooSlow(t, "compiles cgo files")
if !canCgo {
t.Skip("skipping because cgo not enabled")
}
Expand All @@ -1571,7 +1568,7 @@ func TestCgoHandlesWlORIGIN(t *testing.T) {
}

func TestCgoPkgConfig(t *testing.T) {
tooSlow(t)
tooSlow(t, "compiles cgo files")
if !canCgo {
t.Skip("skipping because cgo not enabled")
}
Expand Down Expand Up @@ -1656,7 +1653,7 @@ func TestListTemplateContextFunction(t *testing.T) {
// accessed by a non-local import (found in a GOPATH/GOROOT).
// See golang.org/issue/17475.
func TestImportLocal(t *testing.T) {
tooSlow(t)
tooSlow(t, "builds a lot of sequential packages")

tg := testgo(t)
tg.parallel()
Expand Down Expand Up @@ -1814,7 +1811,7 @@ func TestGoInstallPkgdir(t *testing.T) {
// for the install.
t.Skip("skipping because cgo not enabled")
}
tooSlow(t)
tooSlow(t, "builds a package with cgo dependencies")

tg := testgo(t)
tg.parallel()
Expand All @@ -1829,7 +1826,7 @@ func TestGoInstallPkgdir(t *testing.T) {

// For issue 14337.
func TestParallelTest(t *testing.T) {
tooSlow(t)
tooSlow(t, "links and runs test binaries")
tg := testgo(t)
tg.parallel()
defer tg.cleanup()
Expand All @@ -1849,7 +1846,7 @@ func TestParallelTest(t *testing.T) {
}

func TestBinaryOnlyPackages(t *testing.T) {
tooSlow(t)
tooSlow(t, "compiles several packages sequentially")

tg := testgo(t)
defer tg.cleanup()
Expand Down Expand Up @@ -2051,7 +2048,7 @@ func TestFFLAGS(t *testing.T) {
// This is really a cmd/link issue but this is a convenient place to test it.
func TestDuplicateGlobalAsmSymbols(t *testing.T) {
skipIfGccgo(t, "gccgo does not use cmd/asm")
tooSlow(t)
tooSlow(t, "links a binary with cgo dependencies")
if runtime.GOARCH != "386" && runtime.GOARCH != "amd64" {
t.Skipf("skipping test on %s", runtime.GOARCH)
}
Expand Down Expand Up @@ -2350,10 +2347,11 @@ func TestUpxCompression(t *testing.T) {
var gocacheverify = godebug.New("gocacheverify")

func TestCacheListStale(t *testing.T) {
tooSlow(t)
tooSlow(t, "links a binary")
if gocacheverify.Value() == "1" {
t.Skip("GODEBUG gocacheverify")
}

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -2372,8 +2370,7 @@ func TestCacheListStale(t *testing.T) {
}

func TestCacheCoverage(t *testing.T) {
tooSlow(t)

tooSlow(t, "links and runs a test binary with coverage enabled")
if gocacheverify.Value() == "1" {
t.Skip("GODEBUG gocacheverify")
}
Expand Down Expand Up @@ -2407,10 +2404,11 @@ func TestIssue22588(t *testing.T) {
}

func TestIssue22531(t *testing.T) {
tooSlow(t)
tooSlow(t, "links binaries")
if gocacheverify.Value() == "1" {
t.Skip("GODEBUG gocacheverify")
}

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -2436,10 +2434,11 @@ func TestIssue22531(t *testing.T) {
}

func TestIssue22596(t *testing.T) {
tooSlow(t)
tooSlow(t, "links binaries")
if gocacheverify.Value() == "1" {
t.Skip("GODEBUG gocacheverify")
}

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand All @@ -2465,7 +2464,7 @@ func TestIssue22596(t *testing.T) {
}

func TestTestCache(t *testing.T) {
tooSlow(t)
tooSlow(t, "links and runs test binaries")

if gocacheverify.Value() == "1" {
t.Skip("GODEBUG gocacheverify")
Expand Down Expand Up @@ -2572,7 +2571,8 @@ func TestTestSkipVetAfterFailedBuild(t *testing.T) {
}

func TestTestVetRebuild(t *testing.T) {
tooSlow(t)
tooSlow(t, "links and runs test binaries")

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand Down Expand Up @@ -2612,7 +2612,8 @@ func TestTestVetRebuild(t *testing.T) {
}

func TestInstallDeps(t *testing.T) {
tooSlow(t)
tooSlow(t, "links a binary")

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand Down Expand Up @@ -2643,7 +2644,8 @@ func TestInstallDeps(t *testing.T) {

// Issue 22986.
func TestImportPath(t *testing.T) {
tooSlow(t)
tooSlow(t, "links and runs a test binary")

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand Down Expand Up @@ -2744,7 +2746,8 @@ func TestTwoPkgConfigs(t *testing.T) {
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
t.Skipf("no shell scripts on %s", runtime.GOOS)
}
tooSlow(t)
tooSlow(t, "builds a package with cgo dependencies")

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand Down Expand Up @@ -2775,7 +2778,7 @@ func TestCgoCache(t *testing.T) {
if !canCgo {
t.Skip("no cgo")
}
tooSlow(t)
tooSlow(t, "builds a package with cgo dependencies")

tg := testgo(t)
defer tg.cleanup()
Expand Down Expand Up @@ -2828,7 +2831,7 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) {
if !canCgo {
t.Skip("skipping because cgo not enabled")
}
tooSlow(t)
tooSlow(t, "builds a package with cgo dependencies")

tg := testgo(t)
defer tg.cleanup()
Expand Down Expand Up @@ -2875,7 +2878,8 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) {
// Issue 25093.
func TestCoverpkgTestOnly(t *testing.T) {
skipIfGccgo(t, "gccgo has no cover tool")
tooSlow(t)
tooSlow(t, "links and runs a test binary with coverage enabled")

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
Expand Down

0 comments on commit b852f39

Please sign in to comment.