Change-Id: I15be25455bff2d364a6910a61beeb5131eebd067
This commit is contained in:
qiulaidongfeng 2024-03-16 10:34:36 +08:00
parent cd1e3c438c
commit 18cffb770f
1 changed files with 37 additions and 36 deletions

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

@ -711,24 +711,6 @@ func (t *tester) registerTests() {
})
}
// Runtime CPU tests.
if !t.compileOnly && t.hasParallelism() {
for i := 1; i <= 4; i *= 2 {
t.registerTest(fmt.Sprintf("GOMAXPROCS=2 runtime -cpu=%d -quick", i),
&goTest{
variant: "cpu" + strconv.Itoa(i),
timeout: 300 * time.Second,
cpu: strconv.Itoa(i),
short: true,
testFlags: []string{"-quick"},
// We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
// creation of first goroutines and first garbage collections in the parallel setting.
env: []string{"GOMAXPROCS=2"},
pkg: "runtime",
})
}
}
// GOEXPERIMENT=rangefunc tests
if !t.compileOnly {
t.registerTest("GOEXPERIMENT=rangefunc go test iter",
@ -864,10 +846,6 @@ func (t *tester) registerTests() {
})
}
if t.raceDetectorSupported() {
t.registerRaceTests()
}
const cgoHeading = "Testing cgo"
if t.cgoEnabled {
t.registerCgoTests(cgoHeading)
@ -883,6 +861,40 @@ func (t *tester) registerTests() {
})
}
// Only run the API check on fast development platforms.
// Every platform checks the API on every GOOS/GOARCH/CGO_ENABLED combination anyway,
// so we really only need to run this check once anywhere to get adequate coverage.
// To help developers avoid trybot-only failures, we try to run on typical developer machines
// which is darwin,linux,windows/amd64 and darwin/arm64.
//
// The same logic applies to the release notes that correspond to each api/next file.
if goos == "darwin" || ((goos == "linux" || goos == "windows") && goarch == "amd64") {
t.registerTest("API release note check", &goTest{variant: "check", pkg: "cmd/relnote", testFlags: []string{"-check"}})
t.registerTest("API check", &goTest{variant: "check", pkg: "cmd/api", timeout: 5 * time.Minute, testFlags: []string{"-check"}})
}
// Runtime CPU tests.
if !t.compileOnly && t.hasParallelism() {
for i := 1; i <= 4; i *= 2 {
t.registerTest(fmt.Sprintf("GOMAXPROCS=2 runtime -cpu=%d -quick", i),
&goTest{
variant: "cpu" + strconv.Itoa(i),
timeout: 300 * time.Second,
cpu: strconv.Itoa(i),
short: true,
testFlags: []string{"-quick"},
// We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
// creation of first goroutines and first garbage collections in the parallel setting.
env: []string{"GOMAXPROCS=2"},
pkg: "runtime",
})
}
}
if t.raceDetectorSupported() {
t.registerRaceTests()
}
if goos != "android" && !t.iOS() {
// Only start multiple test dir shards on builders,
// where they get distributed to multiple machines.
@ -907,17 +919,6 @@ func (t *tester) registerTests() {
)
}
}
// Only run the API check on fast development platforms.
// Every platform checks the API on every GOOS/GOARCH/CGO_ENABLED combination anyway,
// so we really only need to run this check once anywhere to get adequate coverage.
// To help developers avoid trybot-only failures, we try to run on typical developer machines
// which is darwin,linux,windows/amd64 and darwin/arm64.
//
// The same logic applies to the release notes that correspond to each api/next file.
if goos == "darwin" || ((goos == "linux" || goos == "windows") && goarch == "amd64") {
t.registerTest("API check", &goTest{variant: "check", pkg: "cmd/api", timeout: 5 * time.Minute, testFlags: []string{"-check"}})
t.registerTest("API release note check", &goTest{variant: "check", pkg: "cmd/relnote", testFlags: []string{"-check"}})
}
}
// addTest adds an arbitrary test callback to the test list.
@ -1282,8 +1283,8 @@ func (t *tester) runPending(nextTest *distTest) {
worklist := t.worklist
t.worklist = nil
for _, w := range worklist {
w.start = make(chan bool, runtime.NumCPU()*2)
w.end = make(chan struct{}, runtime.NumCPU()*2)
w.start = make(chan bool)
w.end = make(chan struct{})
// w.cmd must be set up to write to w.out. We can't check that, but we
// can check for easy mistakes.
if w.cmd.Stdout == nil || w.cmd.Stdout == os.Stdout || w.cmd.Stderr == nil || w.cmd.Stderr == os.Stderr {
@ -1324,7 +1325,7 @@ func (t *tester) runPending(nextTest *distTest) {
// This makes testing a single package slower,
// but testing multiple packages together faster.
if strings.Contains(w.dt.heading, "GOMAXPROCS=2 runtime") {
maxbg = runtime.NumCPU() * 2
maxbg = runtime.NumCPU()
break
}
}