Skip to content

Commit fbf4c04

Browse files
Bryan C. Millscagedmantis
Bryan C. Mills
authored andcommitted
[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 9f532dd) Reviewed-on: https://go-review.googlesource.com/c/go/+/474581
1 parent 20c96a7 commit fbf4c04

File tree

1 file changed

+41
-36
lines changed

1 file changed

+41
-36
lines changed

src/cmd/go/go_test.go

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,10 @@ var exeSuffix string = func() string {
6262
return ""
6363
}()
6464

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

@@ -1080,7 +1076,7 @@ func TestPackageMainTestCompilerFlags(t *testing.T) {
10801076

10811077
// Issue 4104.
10821078
func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
1083-
tooSlow(t)
1079+
tooSlow(t, "links and runs a test")
10841080
tg := testgo(t)
10851081
defer tg.cleanup()
10861082
tg.parallel()
@@ -1091,7 +1087,7 @@ func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
10911087
}
10921088

10931089
func TestGoListHasAConsistentOrder(t *testing.T) {
1094-
tooSlow(t)
1090+
tooSlow(t, "walks all of GOROOT/src twice")
10951091
tg := testgo(t)
10961092
defer tg.cleanup()
10971093
tg.parallel()
@@ -1104,7 +1100,7 @@ func TestGoListHasAConsistentOrder(t *testing.T) {
11041100
}
11051101

11061102
func TestGoListStdDoesNotIncludeCommands(t *testing.T) {
1107-
tooSlow(t)
1103+
tooSlow(t, "walks all of GOROOT/src")
11081104
tg := testgo(t)
11091105
defer tg.cleanup()
11101106
tg.parallel()
@@ -1114,7 +1110,7 @@ func TestGoListStdDoesNotIncludeCommands(t *testing.T) {
11141110

11151111
func TestGoListCmdOnlyShowsCommands(t *testing.T) {
11161112
skipIfGccgo(t, "gccgo does not have GOROOT")
1117-
tooSlow(t)
1113+
tooSlow(t, "walks all of GOROOT/src/cmd")
11181114
tg := testgo(t)
11191115
defer tg.cleanup()
11201116
tg.parallel()
@@ -1197,7 +1193,8 @@ func TestGoListTest(t *testing.T) {
11971193
}
11981194

11991195
func TestGoListCompiledCgo(t *testing.T) {
1200-
tooSlow(t)
1196+
tooSlow(t, "compiles cgo files")
1197+
12011198
tg := testgo(t)
12021199
defer tg.cleanup()
12031200
tg.parallel()
@@ -1418,7 +1415,7 @@ func TestDefaultGOPATHPrintedSearchList(t *testing.T) {
14181415

14191416
func TestLdflagsArgumentsWithSpacesIssue3941(t *testing.T) {
14201417
skipIfGccgo(t, "gccgo does not support -ldflags -X")
1421-
tooSlow(t)
1418+
tooSlow(t, "compiles and links a binary")
14221419
tg := testgo(t)
14231420
defer tg.cleanup()
14241421
tg.parallel()
@@ -1435,7 +1432,7 @@ func TestLdFlagsLongArgumentsIssue42295(t *testing.T) {
14351432
// Test the extremely long command line arguments that contain '\n' characters
14361433
// get encoded and passed correctly.
14371434
skipIfGccgo(t, "gccgo does not support -ldflags -X")
1438-
tooSlow(t)
1435+
tooSlow(t, "compiles and links a binary")
14391436
tg := testgo(t)
14401437
defer tg.cleanup()
14411438
tg.parallel()
@@ -1457,7 +1454,7 @@ func TestLdFlagsLongArgumentsIssue42295(t *testing.T) {
14571454

14581455
func TestGoTestDashCDashOControlsBinaryLocation(t *testing.T) {
14591456
skipIfGccgo(t, "gccgo has no standard packages")
1460-
tooSlow(t)
1457+
tooSlow(t, "compiles and links a test binary")
14611458
tg := testgo(t)
14621459
defer tg.cleanup()
14631460
tg.parallel()
@@ -1468,7 +1465,7 @@ func TestGoTestDashCDashOControlsBinaryLocation(t *testing.T) {
14681465

14691466
func TestGoTestDashOWritesBinary(t *testing.T) {
14701467
skipIfGccgo(t, "gccgo has no standard packages")
1471-
tooSlow(t)
1468+
tooSlow(t, "compiles and runs a test binary")
14721469
tg := testgo(t)
14731470
defer tg.cleanup()
14741471
tg.parallel()
@@ -1479,7 +1476,7 @@ func TestGoTestDashOWritesBinary(t *testing.T) {
14791476

14801477
func TestGoTestDashIDashOWritesBinary(t *testing.T) {
14811478
skipIfGccgo(t, "gccgo has no standard packages")
1482-
tooSlow(t)
1479+
tooSlow(t, "links a test binary")
14831480
tg := testgo(t)
14841481
defer tg.cleanup()
14851482
tg.parallel()
@@ -1495,7 +1492,7 @@ func TestGoTestDashIDashOWritesBinary(t *testing.T) {
14951492

14961493
// Issue 4515.
14971494
func TestInstallWithTags(t *testing.T) {
1498-
tooSlow(t)
1495+
tooSlow(t, "compiles and links binaries")
14991496
tg := testgo(t)
15001497
defer tg.cleanup()
15011498
tg.parallel()
@@ -1564,7 +1561,7 @@ func TestCgoShowsFullPathNames(t *testing.T) {
15641561
}
15651562

15661563
func TestCgoHandlesWlORIGIN(t *testing.T) {
1567-
tooSlow(t)
1564+
tooSlow(t, "compiles cgo files")
15681565
if !canCgo {
15691566
t.Skip("skipping because cgo not enabled")
15701567
}
@@ -1582,7 +1579,7 @@ func TestCgoHandlesWlORIGIN(t *testing.T) {
15821579
}
15831580

15841581
func TestCgoPkgConfig(t *testing.T) {
1585-
tooSlow(t)
1582+
tooSlow(t, "compiles cgo files")
15861583
if !canCgo {
15871584
t.Skip("skipping because cgo not enabled")
15881585
}
@@ -1667,7 +1664,7 @@ func TestListTemplateContextFunction(t *testing.T) {
16671664
// accessed by a non-local import (found in a GOPATH/GOROOT).
16681665
// See golang.org/issue/17475.
16691666
func TestImportLocal(t *testing.T) {
1670-
tooSlow(t)
1667+
tooSlow(t, "builds a lot of sequential packages")
16711668

16721669
tg := testgo(t)
16731670
tg.parallel()
@@ -1819,7 +1816,7 @@ func TestImportLocal(t *testing.T) {
18191816

18201817
func TestGoInstallPkgdir(t *testing.T) {
18211818
skipIfGccgo(t, "gccgo has no standard packages")
1822-
tooSlow(t)
1819+
tooSlow(t, "installs archives in GOROOT")
18231820

18241821
tg := testgo(t)
18251822
tg.parallel()
@@ -1836,7 +1833,7 @@ func TestGoInstallPkgdir(t *testing.T) {
18361833

18371834
// For issue 14337.
18381835
func TestParallelTest(t *testing.T) {
1839-
tooSlow(t)
1836+
tooSlow(t, "links and runs test binaries")
18401837
tg := testgo(t)
18411838
tg.parallel()
18421839
defer tg.cleanup()
@@ -1856,7 +1853,7 @@ func TestParallelTest(t *testing.T) {
18561853
}
18571854

18581855
func TestBinaryOnlyPackages(t *testing.T) {
1859-
tooSlow(t)
1856+
tooSlow(t, "compiles several packages sequentially")
18601857

18611858
tg := testgo(t)
18621859
defer tg.cleanup()
@@ -2058,7 +2055,7 @@ func TestFFLAGS(t *testing.T) {
20582055
// This is really a cmd/link issue but this is a convenient place to test it.
20592056
func TestDuplicateGlobalAsmSymbols(t *testing.T) {
20602057
skipIfGccgo(t, "gccgo does not use cmd/asm")
2061-
tooSlow(t)
2058+
tooSlow(t, "links a binary with cgo dependencies")
20622059
if runtime.GOARCH != "386" && runtime.GOARCH != "amd64" {
20632060
t.Skipf("skipping test on %s", runtime.GOARCH)
20642061
}
@@ -2351,10 +2348,11 @@ func TestUpxCompression(t *testing.T) {
23512348
}
23522349

23532350
func TestCacheListStale(t *testing.T) {
2354-
tooSlow(t)
2351+
tooSlow(t, "links a binary")
23552352
if godebug.Get("gocacheverify") == "1" {
23562353
t.Skip("GODEBUG gocacheverify")
23572354
}
2355+
23582356
tg := testgo(t)
23592357
defer tg.cleanup()
23602358
tg.parallel()
@@ -2373,7 +2371,7 @@ func TestCacheListStale(t *testing.T) {
23732371
}
23742372

23752373
func TestCacheCoverage(t *testing.T) {
2376-
tooSlow(t)
2374+
tooSlow(t, "links and runs a test binary with coverage enabled")
23772375

23782376
if godebug.Get("gocacheverify") == "1" {
23792377
t.Skip("GODEBUG gocacheverify")
@@ -2406,10 +2404,11 @@ func TestIssue22588(t *testing.T) {
24062404
}
24072405

24082406
func TestIssue22531(t *testing.T) {
2409-
tooSlow(t)
2407+
tooSlow(t, "links binaries")
24102408
if godebug.Get("gocacheverify") == "1" {
24112409
t.Skip("GODEBUG gocacheverify")
24122410
}
2411+
24132412
tg := testgo(t)
24142413
defer tg.cleanup()
24152414
tg.parallel()
@@ -2435,10 +2434,11 @@ func TestIssue22531(t *testing.T) {
24352434
}
24362435

24372436
func TestIssue22596(t *testing.T) {
2438-
tooSlow(t)
2437+
tooSlow(t, "links binaries")
24392438
if godebug.Get("gocacheverify") == "1" {
24402439
t.Skip("GODEBUG gocacheverify")
24412440
}
2441+
24422442
tg := testgo(t)
24432443
defer tg.cleanup()
24442444
tg.parallel()
@@ -2464,7 +2464,7 @@ func TestIssue22596(t *testing.T) {
24642464
}
24652465

24662466
func TestTestCache(t *testing.T) {
2467-
tooSlow(t)
2467+
tooSlow(t, "links and runs test binaries")
24682468

24692469
if godebug.Get("gocacheverify") == "1" {
24702470
t.Skip("GODEBUG gocacheverify")
@@ -2571,7 +2571,8 @@ func TestTestSkipVetAfterFailedBuild(t *testing.T) {
25712571
}
25722572

25732573
func TestTestVetRebuild(t *testing.T) {
2574-
tooSlow(t)
2574+
tooSlow(t, "links and runs test binaries")
2575+
25752576
tg := testgo(t)
25762577
defer tg.cleanup()
25772578
tg.parallel()
@@ -2611,7 +2612,8 @@ func TestTestVetRebuild(t *testing.T) {
26112612
}
26122613

26132614
func TestInstallDeps(t *testing.T) {
2614-
tooSlow(t)
2615+
tooSlow(t, "links a binary")
2616+
26152617
tg := testgo(t)
26162618
defer tg.cleanup()
26172619
tg.parallel()
@@ -2652,7 +2654,8 @@ func TestInstallDeps(t *testing.T) {
26522654

26532655
// Issue 22986.
26542656
func TestImportPath(t *testing.T) {
2655-
tooSlow(t)
2657+
tooSlow(t, "links and runs a test binary")
2658+
26562659
tg := testgo(t)
26572660
defer tg.cleanup()
26582661
tg.parallel()
@@ -2753,7 +2756,8 @@ func TestTwoPkgConfigs(t *testing.T) {
27532756
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
27542757
t.Skipf("no shell scripts on %s", runtime.GOOS)
27552758
}
2756-
tooSlow(t)
2759+
tooSlow(t, "builds a package with cgo dependencies")
2760+
27572761
tg := testgo(t)
27582762
defer tg.cleanup()
27592763
tg.parallel()
@@ -2784,7 +2788,7 @@ func TestCgoCache(t *testing.T) {
27842788
if !canCgo {
27852789
t.Skip("no cgo")
27862790
}
2787-
tooSlow(t)
2791+
tooSlow(t, "builds a package with cgo dependencies")
27882792

27892793
tg := testgo(t)
27902794
defer tg.cleanup()
@@ -2837,7 +2841,7 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) {
28372841
if !canCgo {
28382842
t.Skip("skipping because cgo not enabled")
28392843
}
2840-
tooSlow(t)
2844+
tooSlow(t, "builds a package with cgo dependencies")
28412845

28422846
tg := testgo(t)
28432847
defer tg.cleanup()
@@ -2884,7 +2888,8 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) {
28842888
// Issue 25093.
28852889
func TestCoverpkgTestOnly(t *testing.T) {
28862890
skipIfGccgo(t, "gccgo has no cover tool")
2887-
tooSlow(t)
2891+
tooSlow(t, "links and runs a test binary with coverage enabled")
2892+
28882893
tg := testgo(t)
28892894
defer tg.cleanup()
28902895
tg.parallel()

0 commit comments

Comments
 (0)