Skip to content

Commit 9f532dd

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
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. Fixes #58918. Fixes #58919. 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]>
1 parent eaf5938 commit 9f532dd

File tree

1 file changed

+40
-36
lines changed

1 file changed

+40
-36
lines changed

src/cmd/go/go_test.go

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,10 @@ var exeSuffix string = func() string {
6969
return ""
7070
}()
7171

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

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

10861082
// Issue 4104.
10871083
func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
1088-
tooSlow(t)
1084+
tooSlow(t, "links and runs a test")
10891085
tg := testgo(t)
10901086
defer tg.cleanup()
10911087
tg.parallel()
@@ -1096,7 +1092,7 @@ func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
10961092
}
10971093

10981094
func TestGoListHasAConsistentOrder(t *testing.T) {
1099-
tooSlow(t)
1095+
tooSlow(t, "walks all of GOROOT/src twice")
11001096
tg := testgo(t)
11011097
defer tg.cleanup()
11021098
tg.parallel()
@@ -1109,7 +1105,7 @@ func TestGoListHasAConsistentOrder(t *testing.T) {
11091105
}
11101106

11111107
func TestGoListStdDoesNotIncludeCommands(t *testing.T) {
1112-
tooSlow(t)
1108+
tooSlow(t, "walks all of GOROOT/src")
11131109
tg := testgo(t)
11141110
defer tg.cleanup()
11151111
tg.parallel()
@@ -1119,7 +1115,7 @@ func TestGoListStdDoesNotIncludeCommands(t *testing.T) {
11191115

11201116
func TestGoListCmdOnlyShowsCommands(t *testing.T) {
11211117
skipIfGccgo(t, "gccgo does not have GOROOT")
1122-
tooSlow(t)
1118+
tooSlow(t, "walks all of GOROOT/src/cmd")
11231119
tg := testgo(t)
11241120
defer tg.cleanup()
11251121
tg.parallel()
@@ -1202,7 +1198,8 @@ func TestGoListTest(t *testing.T) {
12021198
}
12031199

12041200
func TestGoListCompiledCgo(t *testing.T) {
1205-
tooSlow(t)
1201+
tooSlow(t, "compiles cgo files")
1202+
12061203
tg := testgo(t)
12071204
defer tg.cleanup()
12081205
tg.parallel()
@@ -1423,7 +1420,7 @@ func TestDefaultGOPATHPrintedSearchList(t *testing.T) {
14231420

14241421
func TestLdflagsArgumentsWithSpacesIssue3941(t *testing.T) {
14251422
skipIfGccgo(t, "gccgo does not support -ldflags -X")
1426-
tooSlow(t)
1423+
tooSlow(t, "compiles and links a binary")
14271424
tg := testgo(t)
14281425
defer tg.cleanup()
14291426
tg.parallel()
@@ -1440,7 +1437,7 @@ func TestLdFlagsLongArgumentsIssue42295(t *testing.T) {
14401437
// Test the extremely long command line arguments that contain '\n' characters
14411438
// get encoded and passed correctly.
14421439
skipIfGccgo(t, "gccgo does not support -ldflags -X")
1443-
tooSlow(t)
1440+
tooSlow(t, "compiles and links a binary")
14441441
tg := testgo(t)
14451442
defer tg.cleanup()
14461443
tg.parallel()
@@ -1462,7 +1459,7 @@ func TestLdFlagsLongArgumentsIssue42295(t *testing.T) {
14621459

14631460
func TestGoTestDashCDashOControlsBinaryLocation(t *testing.T) {
14641461
skipIfGccgo(t, "gccgo has no standard packages")
1465-
tooSlow(t)
1462+
tooSlow(t, "compiles and links a test binary")
14661463
tg := testgo(t)
14671464
defer tg.cleanup()
14681465
tg.parallel()
@@ -1473,7 +1470,7 @@ func TestGoTestDashCDashOControlsBinaryLocation(t *testing.T) {
14731470

14741471
func TestGoTestDashOWritesBinary(t *testing.T) {
14751472
skipIfGccgo(t, "gccgo has no standard packages")
1476-
tooSlow(t)
1473+
tooSlow(t, "compiles and runs a test binary")
14771474
tg := testgo(t)
14781475
defer tg.cleanup()
14791476
tg.parallel()
@@ -1484,7 +1481,7 @@ func TestGoTestDashOWritesBinary(t *testing.T) {
14841481

14851482
// Issue 4515.
14861483
func TestInstallWithTags(t *testing.T) {
1487-
tooSlow(t)
1484+
tooSlow(t, "compiles and links binaries")
14881485
tg := testgo(t)
14891486
defer tg.cleanup()
14901487
tg.parallel()
@@ -1553,7 +1550,7 @@ func TestCgoShowsFullPathNames(t *testing.T) {
15531550
}
15541551

15551552
func TestCgoHandlesWlORIGIN(t *testing.T) {
1556-
tooSlow(t)
1553+
tooSlow(t, "compiles cgo files")
15571554
if !canCgo {
15581555
t.Skip("skipping because cgo not enabled")
15591556
}
@@ -1571,7 +1568,7 @@ func TestCgoHandlesWlORIGIN(t *testing.T) {
15711568
}
15721569

15731570
func TestCgoPkgConfig(t *testing.T) {
1574-
tooSlow(t)
1571+
tooSlow(t, "compiles cgo files")
15751572
if !canCgo {
15761573
t.Skip("skipping because cgo not enabled")
15771574
}
@@ -1672,7 +1669,7 @@ func TestListTemplateContextFunction(t *testing.T) {
16721669
// accessed by a non-local import (found in a GOPATH/GOROOT).
16731670
// See golang.org/issue/17475.
16741671
func TestImportLocal(t *testing.T) {
1675-
tooSlow(t)
1672+
tooSlow(t, "builds a lot of sequential packages")
16761673

16771674
tg := testgo(t)
16781675
tg.parallel()
@@ -1830,7 +1827,7 @@ func TestGoInstallPkgdir(t *testing.T) {
18301827
// for the install.
18311828
t.Skip("skipping because cgo not enabled")
18321829
}
1833-
tooSlow(t)
1830+
tooSlow(t, "builds a package with cgo dependencies")
18341831

18351832
tg := testgo(t)
18361833
tg.parallel()
@@ -1845,7 +1842,7 @@ func TestGoInstallPkgdir(t *testing.T) {
18451842

18461843
// For issue 14337.
18471844
func TestParallelTest(t *testing.T) {
1848-
tooSlow(t)
1845+
tooSlow(t, "links and runs test binaries")
18491846
tg := testgo(t)
18501847
tg.parallel()
18511848
defer tg.cleanup()
@@ -1865,7 +1862,7 @@ func TestParallelTest(t *testing.T) {
18651862
}
18661863

18671864
func TestBinaryOnlyPackages(t *testing.T) {
1868-
tooSlow(t)
1865+
tooSlow(t, "compiles several packages sequentially")
18691866

18701867
tg := testgo(t)
18711868
defer tg.cleanup()
@@ -2067,7 +2064,7 @@ func TestFFLAGS(t *testing.T) {
20672064
// This is really a cmd/link issue but this is a convenient place to test it.
20682065
func TestDuplicateGlobalAsmSymbols(t *testing.T) {
20692066
skipIfGccgo(t, "gccgo does not use cmd/asm")
2070-
tooSlow(t)
2067+
tooSlow(t, "links a binary with cgo dependencies")
20712068
if runtime.GOARCH != "386" && runtime.GOARCH != "amd64" {
20722069
t.Skipf("skipping test on %s", runtime.GOARCH)
20732070
}
@@ -2366,10 +2363,11 @@ func TestUpxCompression(t *testing.T) {
23662363
var gocacheverify = godebug.New("gocacheverify")
23672364

23682365
func TestCacheListStale(t *testing.T) {
2369-
tooSlow(t)
2366+
tooSlow(t, "links a binary")
23702367
if gocacheverify.Value() == "1" {
23712368
t.Skip("GODEBUG gocacheverify")
23722369
}
2370+
23732371
tg := testgo(t)
23742372
defer tg.cleanup()
23752373
tg.parallel()
@@ -2388,8 +2386,7 @@ func TestCacheListStale(t *testing.T) {
23882386
}
23892387

23902388
func TestCacheCoverage(t *testing.T) {
2391-
tooSlow(t)
2392-
2389+
tooSlow(t, "links and runs a test binary with coverage enabled")
23932390
if gocacheverify.Value() == "1" {
23942391
t.Skip("GODEBUG gocacheverify")
23952392
}
@@ -2423,10 +2420,11 @@ func TestIssue22588(t *testing.T) {
24232420
}
24242421

24252422
func TestIssue22531(t *testing.T) {
2426-
tooSlow(t)
2423+
tooSlow(t, "links binaries")
24272424
if gocacheverify.Value() == "1" {
24282425
t.Skip("GODEBUG gocacheverify")
24292426
}
2427+
24302428
tg := testgo(t)
24312429
defer tg.cleanup()
24322430
tg.parallel()
@@ -2452,10 +2450,11 @@ func TestIssue22531(t *testing.T) {
24522450
}
24532451

24542452
func TestIssue22596(t *testing.T) {
2455-
tooSlow(t)
2453+
tooSlow(t, "links binaries")
24562454
if gocacheverify.Value() == "1" {
24572455
t.Skip("GODEBUG gocacheverify")
24582456
}
2457+
24592458
tg := testgo(t)
24602459
defer tg.cleanup()
24612460
tg.parallel()
@@ -2481,7 +2480,7 @@ func TestIssue22596(t *testing.T) {
24812480
}
24822481

24832482
func TestTestCache(t *testing.T) {
2484-
tooSlow(t)
2483+
tooSlow(t, "links and runs test binaries")
24852484

24862485
if gocacheverify.Value() == "1" {
24872486
t.Skip("GODEBUG gocacheverify")
@@ -2588,7 +2587,8 @@ func TestTestSkipVetAfterFailedBuild(t *testing.T) {
25882587
}
25892588

25902589
func TestTestVetRebuild(t *testing.T) {
2591-
tooSlow(t)
2590+
tooSlow(t, "links and runs test binaries")
2591+
25922592
tg := testgo(t)
25932593
defer tg.cleanup()
25942594
tg.parallel()
@@ -2628,7 +2628,8 @@ func TestTestVetRebuild(t *testing.T) {
26282628
}
26292629

26302630
func TestInstallDeps(t *testing.T) {
2631-
tooSlow(t)
2631+
tooSlow(t, "links a binary")
2632+
26322633
tg := testgo(t)
26332634
defer tg.cleanup()
26342635
tg.parallel()
@@ -2659,7 +2660,8 @@ func TestInstallDeps(t *testing.T) {
26592660

26602661
// Issue 22986.
26612662
func TestImportPath(t *testing.T) {
2662-
tooSlow(t)
2663+
tooSlow(t, "links and runs a test binary")
2664+
26632665
tg := testgo(t)
26642666
defer tg.cleanup()
26652667
tg.parallel()
@@ -2760,7 +2762,8 @@ func TestTwoPkgConfigs(t *testing.T) {
27602762
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
27612763
t.Skipf("no shell scripts on %s", runtime.GOOS)
27622764
}
2763-
tooSlow(t)
2765+
tooSlow(t, "builds a package with cgo dependencies")
2766+
27642767
tg := testgo(t)
27652768
defer tg.cleanup()
27662769
tg.parallel()
@@ -2791,7 +2794,7 @@ func TestCgoCache(t *testing.T) {
27912794
if !canCgo {
27922795
t.Skip("no cgo")
27932796
}
2794-
tooSlow(t)
2797+
tooSlow(t, "builds a package with cgo dependencies")
27952798

27962799
tg := testgo(t)
27972800
defer tg.cleanup()
@@ -2844,7 +2847,7 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) {
28442847
if !canCgo {
28452848
t.Skip("skipping because cgo not enabled")
28462849
}
2847-
tooSlow(t)
2850+
tooSlow(t, "builds a package with cgo dependencies")
28482851

28492852
tg := testgo(t)
28502853
defer tg.cleanup()
@@ -2891,7 +2894,8 @@ func TestLinkerTmpDirIsDeleted(t *testing.T) {
28912894
// Issue 25093.
28922895
func TestCoverpkgTestOnly(t *testing.T) {
28932896
skipIfGccgo(t, "gccgo has no cover tool")
2894-
tooSlow(t)
2897+
tooSlow(t, "links and runs a test binary with coverage enabled")
2898+
28952899
tg := testgo(t)
28962900
defer tg.cleanup()
28972901
tg.parallel()

0 commit comments

Comments
 (0)