[release-branch.go1.19] cmd/go: avoid running slow tests on non-longtest 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 #58937.

Change-Id: I0000f0084b262beeec3eca3e9b8a45d61fab4313
Reviewed-on: https://go-review.googlesource.com/c/go/+/474137
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 9f532dd0de)
Reviewed-on: https://go-review.googlesource.com/c/go/+/474581
This commit is contained in:
Bryan C. Mills 2023-03-07 15:12:29 -05:00 committed by Carlos Amedee
parent 20c96a7ddc
commit fbf4c04f82
1 changed files with 41 additions and 36 deletions

View File

@ -62,14 +62,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)
}
}
@ -1080,7 +1076,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()
@ -1091,7 +1087,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()
@ -1104,7 +1100,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()
@ -1114,7 +1110,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()
@ -1197,7 +1193,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()
@ -1418,7 +1415,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()
@ -1435,7 +1432,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()
@ -1457,7 +1454,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()
@ -1468,7 +1465,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()
@ -1479,7 +1476,7 @@ func TestGoTestDashOWritesBinary(t *testing.T) {
func TestGoTestDashIDashOWritesBinary(t *testing.T) {
skipIfGccgo(t, "gccgo has no standard packages")
tooSlow(t)
tooSlow(t, "links a test binary")
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
@ -1495,7 +1492,7 @@ func TestGoTestDashIDashOWritesBinary(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()
@ -1564,7 +1561,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")
}
@ -1582,7 +1579,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")
}
@ -1667,7 +1664,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()
@ -1819,7 +1816,7 @@ func TestImportLocal(t *testing.T) {
func TestGoInstallPkgdir(t *testing.T) {
skipIfGccgo(t, "gccgo has no standard packages")
tooSlow(t)
tooSlow(t, "installs archives in GOROOT")
tg := testgo(t)
tg.parallel()
@ -1836,7 +1833,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()
@ -1856,7 +1853,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()
@ -2058,7 +2055,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)
}
@ -2351,10 +2348,11 @@ func TestUpxCompression(t *testing.T) {
}
func TestCacheListStale(t *testing.T) {
tooSlow(t)
tooSlow(t, "links a binary")
if godebug.Get("gocacheverify") == "1" {
t.Skip("GODEBUG gocacheverify")
}
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
@ -2373,7 +2371,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 godebug.Get("gocacheverify") == "1" {
t.Skip("GODEBUG gocacheverify")
@ -2406,10 +2404,11 @@ func TestIssue22588(t *testing.T) {
}
func TestIssue22531(t *testing.T) {
tooSlow(t)
tooSlow(t, "links binaries")
if godebug.Get("gocacheverify") == "1" {
t.Skip("GODEBUG gocacheverify")
}
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
@ -2435,10 +2434,11 @@ func TestIssue22531(t *testing.T) {
}
func TestIssue22596(t *testing.T) {
tooSlow(t)
tooSlow(t, "links binaries")
if godebug.Get("gocacheverify") == "1" {
t.Skip("GODEBUG gocacheverify")
}
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
@ -2464,7 +2464,7 @@ func TestIssue22596(t *testing.T) {
}
func TestTestCache(t *testing.T) {
tooSlow(t)
tooSlow(t, "links and runs test binaries")
if godebug.Get("gocacheverify") == "1" {
t.Skip("GODEBUG gocacheverify")
@ -2571,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()
@ -2611,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()
@ -2652,7 +2654,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()
@ -2753,7 +2756,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()
@ -2784,7 +2788,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()
@ -2837,7 +2841,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()
@ -2884,7 +2888,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()