Skip to content

Commit 18cffb7

Browse files
n
Change-Id: I15be25455bff2d364a6910a61beeb5131eebd067
1 parent cd1e3c4 commit 18cffb7

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

src/cmd/dist/test.go

+37-36
Original file line numberDiff line numberDiff line change
@@ -711,24 +711,6 @@ func (t *tester) registerTests() {
711711
})
712712
}
713713

714-
// Runtime CPU tests.
715-
if !t.compileOnly && t.hasParallelism() {
716-
for i := 1; i <= 4; i *= 2 {
717-
t.registerTest(fmt.Sprintf("GOMAXPROCS=2 runtime -cpu=%d -quick", i),
718-
&goTest{
719-
variant: "cpu" + strconv.Itoa(i),
720-
timeout: 300 * time.Second,
721-
cpu: strconv.Itoa(i),
722-
short: true,
723-
testFlags: []string{"-quick"},
724-
// We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
725-
// creation of first goroutines and first garbage collections in the parallel setting.
726-
env: []string{"GOMAXPROCS=2"},
727-
pkg: "runtime",
728-
})
729-
}
730-
}
731-
732714
// GOEXPERIMENT=rangefunc tests
733715
if !t.compileOnly {
734716
t.registerTest("GOEXPERIMENT=rangefunc go test iter",
@@ -864,10 +846,6 @@ func (t *tester) registerTests() {
864846
})
865847
}
866848

867-
if t.raceDetectorSupported() {
868-
t.registerRaceTests()
869-
}
870-
871849
const cgoHeading = "Testing cgo"
872850
if t.cgoEnabled {
873851
t.registerCgoTests(cgoHeading)
@@ -883,6 +861,40 @@ func (t *tester) registerTests() {
883861
})
884862
}
885863

864+
// Only run the API check on fast development platforms.
865+
// Every platform checks the API on every GOOS/GOARCH/CGO_ENABLED combination anyway,
866+
// so we really only need to run this check once anywhere to get adequate coverage.
867+
// To help developers avoid trybot-only failures, we try to run on typical developer machines
868+
// which is darwin,linux,windows/amd64 and darwin/arm64.
869+
//
870+
// The same logic applies to the release notes that correspond to each api/next file.
871+
if goos == "darwin" || ((goos == "linux" || goos == "windows") && goarch == "amd64") {
872+
t.registerTest("API release note check", &goTest{variant: "check", pkg: "cmd/relnote", testFlags: []string{"-check"}})
873+
t.registerTest("API check", &goTest{variant: "check", pkg: "cmd/api", timeout: 5 * time.Minute, testFlags: []string{"-check"}})
874+
}
875+
876+
// Runtime CPU tests.
877+
if !t.compileOnly && t.hasParallelism() {
878+
for i := 1; i <= 4; i *= 2 {
879+
t.registerTest(fmt.Sprintf("GOMAXPROCS=2 runtime -cpu=%d -quick", i),
880+
&goTest{
881+
variant: "cpu" + strconv.Itoa(i),
882+
timeout: 300 * time.Second,
883+
cpu: strconv.Itoa(i),
884+
short: true,
885+
testFlags: []string{"-quick"},
886+
// We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
887+
// creation of first goroutines and first garbage collections in the parallel setting.
888+
env: []string{"GOMAXPROCS=2"},
889+
pkg: "runtime",
890+
})
891+
}
892+
}
893+
894+
if t.raceDetectorSupported() {
895+
t.registerRaceTests()
896+
}
897+
886898
if goos != "android" && !t.iOS() {
887899
// Only start multiple test dir shards on builders,
888900
// where they get distributed to multiple machines.
@@ -907,17 +919,6 @@ func (t *tester) registerTests() {
907919
)
908920
}
909921
}
910-
// Only run the API check on fast development platforms.
911-
// Every platform checks the API on every GOOS/GOARCH/CGO_ENABLED combination anyway,
912-
// so we really only need to run this check once anywhere to get adequate coverage.
913-
// To help developers avoid trybot-only failures, we try to run on typical developer machines
914-
// which is darwin,linux,windows/amd64 and darwin/arm64.
915-
//
916-
// The same logic applies to the release notes that correspond to each api/next file.
917-
if goos == "darwin" || ((goos == "linux" || goos == "windows") && goarch == "amd64") {
918-
t.registerTest("API check", &goTest{variant: "check", pkg: "cmd/api", timeout: 5 * time.Minute, testFlags: []string{"-check"}})
919-
t.registerTest("API release note check", &goTest{variant: "check", pkg: "cmd/relnote", testFlags: []string{"-check"}})
920-
}
921922
}
922923

923924
// addTest adds an arbitrary test callback to the test list.
@@ -1282,8 +1283,8 @@ func (t *tester) runPending(nextTest *distTest) {
12821283
worklist := t.worklist
12831284
t.worklist = nil
12841285
for _, w := range worklist {
1285-
w.start = make(chan bool, runtime.NumCPU()*2)
1286-
w.end = make(chan struct{}, runtime.NumCPU()*2)
1286+
w.start = make(chan bool)
1287+
w.end = make(chan struct{})
12871288
// w.cmd must be set up to write to w.out. We can't check that, but we
12881289
// can check for easy mistakes.
12891290
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) {
13241325
// This makes testing a single package slower,
13251326
// but testing multiple packages together faster.
13261327
if strings.Contains(w.dt.heading, "GOMAXPROCS=2 runtime") {
1327-
maxbg = runtime.NumCPU() * 2
1328+
maxbg = runtime.NumCPU()
13281329
break
13291330
}
13301331
}

0 commit comments

Comments
 (0)