1
0
mirror of https://github.com/golang/go synced 2024-11-17 02:34:46 -07:00

cmd/dist: put cgo tests under a "Testing cgo" heading

Currently the cgo tests mostly use their package name as a heading,
which means we get a large number of test sections that each have a
single test package in them.

Unify them all under "Testing cgo" to reduce output noise.

This leaves just the cmd/api test without a heading, so we give it a
heading and require that all tests have a heading.

Change-Id: I24cd9a96eb35bbc3ff9335ca8a382ec2426306c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/494497
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
Austin Clements 2023-05-11 15:12:45 -04:00
parent 65306bcdae
commit 3cf8e8e5e6

50
src/cmd/dist/test.go vendored
View File

@ -785,16 +785,17 @@ func (t *tester) registerTests() {
t.registerRaceTests() t.registerRaceTests()
} }
const cgoHeading = "Testing cgo"
if t.cgoEnabled && !t.iOS() { if t.cgoEnabled && !t.iOS() {
// Disabled on iOS. golang.org/issue/15919 // Disabled on iOS. golang.org/issue/15919
t.registerTest("cgo_teststdio", "", &goTest{pkg: "cmd/cgo/internal/teststdio", timeout: 5 * time.Minute}) t.registerTest("cgo_teststdio", cgoHeading, &goTest{pkg: "cmd/cgo/internal/teststdio", timeout: 5 * time.Minute})
t.registerTest("cgo_testlife", "", &goTest{pkg: "cmd/cgo/internal/testlife", timeout: 5 * time.Minute}) t.registerTest("cgo_testlife", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testlife", timeout: 5 * time.Minute})
if goos != "android" { if goos != "android" {
t.registerTest("cgo_testfortran", "", &goTest{pkg: "cmd/cgo/internal/testfortran", timeout: 5 * time.Minute}) t.registerTest("cgo_testfortran", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testfortran", timeout: 5 * time.Minute})
} }
} }
if t.cgoEnabled { if t.cgoEnabled {
t.registerCgoTests() t.registerCgoTests(cgoHeading)
} }
// Don't run these tests with $GO_GCFLAGS because most of them // Don't run these tests with $GO_GCFLAGS because most of them
@ -802,25 +803,25 @@ func (t *tester) registerTests() {
// recompile the entire standard library. If make.bash ran with // recompile the entire standard library. If make.bash ran with
// special -gcflags, that's not true. // special -gcflags, that's not true.
if t.cgoEnabled && gogcflags == "" { if t.cgoEnabled && gogcflags == "" {
t.registerTest("cgo_testgodefs", "", &goTest{pkg: "cmd/cgo/internal/testgodefs", timeout: 5 * time.Minute}) t.registerTest("cgo_testgodefs", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testgodefs", timeout: 5 * time.Minute})
t.registerTest("cgo_testso", "", &goTest{pkg: "cmd/cgo/internal/testso", timeout: 600 * time.Second}) t.registerTest("cgo_testso", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testso", timeout: 600 * time.Second})
t.registerTest("cgo_testsovar", "", &goTest{pkg: "cmd/cgo/internal/testsovar", timeout: 600 * time.Second}) t.registerTest("cgo_testsovar", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testsovar", timeout: 600 * time.Second})
if t.supportedBuildmode("c-archive") { if t.supportedBuildmode("c-archive") {
t.registerTest("cgo_testcarchive", "", &goTest{pkg: "cmd/cgo/internal/testcarchive", timeout: 5 * time.Minute}) t.registerTest("cgo_testcarchive", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testcarchive", timeout: 5 * time.Minute})
} }
if t.supportedBuildmode("c-shared") { if t.supportedBuildmode("c-shared") {
t.registerTest("cgo_testcshared", "", &goTest{pkg: "cmd/cgo/internal/testcshared", timeout: 5 * time.Minute}) t.registerTest("cgo_testcshared", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testcshared", timeout: 5 * time.Minute})
} }
if t.supportedBuildmode("shared") { if t.supportedBuildmode("shared") {
t.registerTest("cgo_testshared", "", &goTest{pkg: "cmd/cgo/internal/testshared", timeout: 600 * time.Second}) t.registerTest("cgo_testshared", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testshared", timeout: 600 * time.Second})
} }
if t.supportedBuildmode("plugin") { if t.supportedBuildmode("plugin") {
t.registerTest("cgo_testplugin", "", &goTest{pkg: "cmd/cgo/internal/testplugin", timeout: 600 * time.Second}) t.registerTest("cgo_testplugin", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testplugin", timeout: 600 * time.Second})
} }
t.registerTest("cgo_testsanitizers", "", &goTest{pkg: "cmd/cgo/internal/testsanitizers", timeout: 5 * time.Minute}) t.registerTest("cgo_testsanitizers", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testsanitizers", timeout: 5 * time.Minute})
if t.hasBash() && goos != "android" && !t.iOS() && gohostos != "windows" { if t.hasBash() && goos != "android" && !t.iOS() && gohostos != "windows" {
t.registerTest("cgo_errors", "", &goTest{pkg: "cmd/cgo/internal/testerrors", timeout: 5 * time.Minute}) t.registerTest("cgo_errors", cgoHeading, &goTest{pkg: "cmd/cgo/internal/testerrors", timeout: 5 * time.Minute})
} }
} }
@ -853,17 +854,20 @@ func (t *tester) registerTests() {
// To help developers avoid trybot-only failures, we try to run on typical developer machines // To help developers avoid trybot-only failures, we try to run on typical developer machines
// which is darwin,linux,windows/amd64 and darwin/arm64. // which is darwin,linux,windows/amd64 and darwin/arm64.
if goos == "darwin" || ((goos == "linux" || goos == "windows") && goarch == "amd64") { if goos == "darwin" || ((goos == "linux" || goos == "windows") && goarch == "amd64") {
t.registerTest("api", "", &goTest{pkg: "cmd/api", timeout: 5 * time.Minute, testFlags: []string{"-check"}}) t.registerTest("api", "API check", &goTest{pkg: "cmd/api", timeout: 5 * time.Minute, testFlags: []string{"-check"}})
} }
} }
// addTest adds an arbitrary test callback to the test list. // addTest adds an arbitrary test callback to the test list.
// //
// name must uniquely identify the test. // name must uniquely identify the test and heading must be non-empty.
func (t *tester) addTest(name, heading string, fn func(*distTest) error) { func (t *tester) addTest(name, heading string, fn func(*distTest) error) {
if t.testNames[name] { if t.testNames[name] {
panic("duplicate registered test name " + name) panic("duplicate registered test name " + name)
} }
if heading == "" {
panic("empty heading")
}
if t.testNames == nil { if t.testNames == nil {
t.testNames = make(map[string]bool) t.testNames = make(map[string]bool)
} }
@ -889,7 +893,7 @@ func (rtPreFunc) isRegisterTestOpt() {}
// registerTest registers a test that runs the given goTest. // registerTest registers a test that runs the given goTest.
// //
// If heading is "", it uses test.pkg as the heading. // name must uniquely identify the test and heading must be non-empty.
func (t *tester) registerTest(name, heading string, test *goTest, opts ...registerTestOpt) { func (t *tester) registerTest(name, heading string, test *goTest, opts ...registerTestOpt) {
var preFunc func(*distTest) bool var preFunc func(*distTest) bool
for _, opt := range opts { for _, opt := range opts {
@ -898,12 +902,6 @@ func (t *tester) registerTest(name, heading string, test *goTest, opts ...regist
preFunc = opt.pre preFunc = opt.pre
} }
} }
if heading == "" {
if test.pkg == "" {
panic("either heading or test.pkg must be set")
}
heading = test.pkg
}
t.addTest(name, heading, func(dt *distTest) error { t.addTest(name, heading, func(dt *distTest) error {
if preFunc != nil && !preFunc(dt) { if preFunc != nil && !preFunc(dt) {
return nil return nil
@ -1050,7 +1048,7 @@ func (t *tester) supportedBuildmode(mode string) bool {
return buildModeSupported("gc", mode, goos, goarch) return buildModeSupported("gc", mode, goos, goarch)
} }
func (t *tester) registerCgoTests() { func (t *tester) registerCgoTests(heading string) {
cgoTest := func(name string, subdir, linkmode, buildmode string, opts ...registerTestOpt) *goTest { cgoTest := func(name string, subdir, linkmode, buildmode string, opts ...registerTestOpt) *goTest {
gt := &goTest{ gt := &goTest{
pkg: "cmd/cgo/internal/" + subdir, pkg: "cmd/cgo/internal/" + subdir,
@ -1078,7 +1076,7 @@ func (t *tester) registerCgoTests() {
gt.tags = append(gt.tags, "static") gt.tags = append(gt.tags, "static")
} }
t.registerTest("cgo:"+name, "cmd/cgo/internal/test", gt, opts...) t.registerTest("cgo:"+name, heading, gt, opts...)
return gt return gt
} }
@ -1236,7 +1234,7 @@ func (t *tester) runPending(nextTest *distTest) {
} }
w := worklist[ended] w := worklist[ended]
dt := w.dt dt := w.dt
if dt.heading != "" && t.lastHeading != dt.heading { if t.lastHeading != dt.heading {
t.lastHeading = dt.heading t.lastHeading = dt.heading
t.out(dt.heading) t.out(dt.heading)
} }
@ -1263,7 +1261,7 @@ func (t *tester) runPending(nextTest *distTest) {
} }
if dt := nextTest; dt != nil { if dt := nextTest; dt != nil {
if dt.heading != "" && t.lastHeading != dt.heading { if t.lastHeading != dt.heading {
t.lastHeading = dt.heading t.lastHeading = dt.heading
t.out(dt.heading) t.out(dt.heading)
} }