@@ -785,42 +785,43 @@ func (t *tester) registerTests() {
785
785
t .registerRaceTests ()
786
786
}
787
787
788
+ const cgoHeading = "Testing cgo"
788
789
if t .cgoEnabled && ! t .iOS () {
789
790
// Disabled on iOS. golang.org/issue/15919
790
- t .registerTest ("cgo_teststdio" , "" , & goTest {pkg : "cmd/cgo/internal/teststdio" , timeout : 5 * time .Minute })
791
- t .registerTest ("cgo_testlife" , "" , & goTest {pkg : "cmd/cgo/internal/testlife" , timeout : 5 * time .Minute })
791
+ t .registerTest ("cgo_teststdio" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/teststdio" , timeout : 5 * time .Minute })
792
+ t .registerTest ("cgo_testlife" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testlife" , timeout : 5 * time .Minute })
792
793
if goos != "android" {
793
- t .registerTest ("cgo_testfortran" , "" , & goTest {pkg : "cmd/cgo/internal/testfortran" , timeout : 5 * time .Minute })
794
+ t .registerTest ("cgo_testfortran" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testfortran" , timeout : 5 * time .Minute })
794
795
}
795
796
}
796
797
if t .cgoEnabled {
797
- t .registerCgoTests ()
798
+ t .registerCgoTests (cgoHeading )
798
799
}
799
800
800
801
// Don't run these tests with $GO_GCFLAGS because most of them
801
802
// assume that they can run "go install" with no -gcflags and not
802
803
// recompile the entire standard library. If make.bash ran with
803
804
// special -gcflags, that's not true.
804
805
if t .cgoEnabled && gogcflags == "" {
805
- t .registerTest ("cgo_testgodefs" , "" , & goTest {pkg : "cmd/cgo/internal/testgodefs" , timeout : 5 * time .Minute })
806
+ t .registerTest ("cgo_testgodefs" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testgodefs" , timeout : 5 * time .Minute })
806
807
807
- t .registerTest ("cgo_testso" , "" , & goTest {pkg : "cmd/cgo/internal/testso" , timeout : 600 * time .Second })
808
- t .registerTest ("cgo_testsovar" , "" , & goTest {pkg : "cmd/cgo/internal/testsovar" , timeout : 600 * time .Second })
808
+ t .registerTest ("cgo_testso" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testso" , timeout : 600 * time .Second })
809
+ t .registerTest ("cgo_testsovar" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testsovar" , timeout : 600 * time .Second })
809
810
if t .supportedBuildmode ("c-archive" ) {
810
- t .registerTest ("cgo_testcarchive" , "" , & goTest {pkg : "cmd/cgo/internal/testcarchive" , timeout : 5 * time .Minute })
811
+ t .registerTest ("cgo_testcarchive" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testcarchive" , timeout : 5 * time .Minute })
811
812
}
812
813
if t .supportedBuildmode ("c-shared" ) {
813
- t .registerTest ("cgo_testcshared" , "" , & goTest {pkg : "cmd/cgo/internal/testcshared" , timeout : 5 * time .Minute })
814
+ t .registerTest ("cgo_testcshared" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testcshared" , timeout : 5 * time .Minute })
814
815
}
815
816
if t .supportedBuildmode ("shared" ) {
816
- t .registerTest ("cgo_testshared" , "" , & goTest {pkg : "cmd/cgo/internal/testshared" , timeout : 600 * time .Second })
817
+ t .registerTest ("cgo_testshared" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testshared" , timeout : 600 * time .Second })
817
818
}
818
819
if t .supportedBuildmode ("plugin" ) {
819
- t .registerTest ("cgo_testplugin" , "" , & goTest {pkg : "cmd/cgo/internal/testplugin" , timeout : 600 * time .Second })
820
+ t .registerTest ("cgo_testplugin" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testplugin" , timeout : 600 * time .Second })
820
821
}
821
- t .registerTest ("cgo_testsanitizers" , "" , & goTest {pkg : "cmd/cgo/internal/testsanitizers" , timeout : 5 * time .Minute })
822
+ t .registerTest ("cgo_testsanitizers" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testsanitizers" , timeout : 5 * time .Minute })
822
823
if t .hasBash () && goos != "android" && ! t .iOS () && gohostos != "windows" {
823
- t .registerTest ("cgo_errors" , "" , & goTest {pkg : "cmd/cgo/internal/testerrors" , timeout : 5 * time .Minute })
824
+ t .registerTest ("cgo_errors" , cgoHeading , & goTest {pkg : "cmd/cgo/internal/testerrors" , timeout : 5 * time .Minute })
824
825
}
825
826
}
826
827
@@ -853,17 +854,20 @@ func (t *tester) registerTests() {
853
854
// To help developers avoid trybot-only failures, we try to run on typical developer machines
854
855
// which is darwin,linux,windows/amd64 and darwin/arm64.
855
856
if goos == "darwin" || ((goos == "linux" || goos == "windows" ) && goarch == "amd64" ) {
856
- t .registerTest ("api" , "" , & goTest {pkg : "cmd/api" , timeout : 5 * time .Minute , testFlags : []string {"-check" }})
857
+ t .registerTest ("api" , "API check " , & goTest {pkg : "cmd/api" , timeout : 5 * time .Minute , testFlags : []string {"-check" }})
857
858
}
858
859
}
859
860
860
861
// addTest adds an arbitrary test callback to the test list.
861
862
//
862
- // name must uniquely identify the test.
863
+ // name must uniquely identify the test and heading must be non-empty .
863
864
func (t * tester ) addTest (name , heading string , fn func (* distTest ) error ) {
864
865
if t .testNames [name ] {
865
866
panic ("duplicate registered test name " + name )
866
867
}
868
+ if heading == "" {
869
+ panic ("empty heading" )
870
+ }
867
871
if t .testNames == nil {
868
872
t .testNames = make (map [string ]bool )
869
873
}
@@ -889,7 +893,7 @@ func (rtPreFunc) isRegisterTestOpt() {}
889
893
890
894
// registerTest registers a test that runs the given goTest.
891
895
//
892
- // If heading is "", it uses test.pkg as the heading.
896
+ // name must uniquely identify the test and heading must be non-empty .
893
897
func (t * tester ) registerTest (name , heading string , test * goTest , opts ... registerTestOpt ) {
894
898
var preFunc func (* distTest ) bool
895
899
for _ , opt := range opts {
@@ -898,12 +902,6 @@ func (t *tester) registerTest(name, heading string, test *goTest, opts ...regist
898
902
preFunc = opt .pre
899
903
}
900
904
}
901
- if heading == "" {
902
- if test .pkg == "" {
903
- panic ("either heading or test.pkg must be set" )
904
- }
905
- heading = test .pkg
906
- }
907
905
t .addTest (name , heading , func (dt * distTest ) error {
908
906
if preFunc != nil && ! preFunc (dt ) {
909
907
return nil
@@ -1050,7 +1048,7 @@ func (t *tester) supportedBuildmode(mode string) bool {
1050
1048
return buildModeSupported ("gc" , mode , goos , goarch )
1051
1049
}
1052
1050
1053
- func (t * tester ) registerCgoTests () {
1051
+ func (t * tester ) registerCgoTests (heading string ) {
1054
1052
cgoTest := func (name string , subdir , linkmode , buildmode string , opts ... registerTestOpt ) * goTest {
1055
1053
gt := & goTest {
1056
1054
pkg : "cmd/cgo/internal/" + subdir ,
@@ -1078,7 +1076,7 @@ func (t *tester) registerCgoTests() {
1078
1076
gt .tags = append (gt .tags , "static" )
1079
1077
}
1080
1078
1081
- t .registerTest ("cgo:" + name , "cmd/cgo/internal/test" , gt , opts ... )
1079
+ t .registerTest ("cgo:" + name , heading , gt , opts ... )
1082
1080
return gt
1083
1081
}
1084
1082
@@ -1236,7 +1234,7 @@ func (t *tester) runPending(nextTest *distTest) {
1236
1234
}
1237
1235
w := worklist [ended ]
1238
1236
dt := w .dt
1239
- if dt . heading != "" && t .lastHeading != dt .heading {
1237
+ if t .lastHeading != dt .heading {
1240
1238
t .lastHeading = dt .heading
1241
1239
t .out (dt .heading )
1242
1240
}
@@ -1263,7 +1261,7 @@ func (t *tester) runPending(nextTest *distTest) {
1263
1261
}
1264
1262
1265
1263
if dt := nextTest ; dt != nil {
1266
- if dt . heading != "" && t .lastHeading != dt .heading {
1264
+ if t .lastHeading != dt .heading {
1267
1265
t .lastHeading = dt .heading
1268
1266
t .out (dt .heading )
1269
1267
}
0 commit comments