Skip to content

Commit a24ba0f

Browse files
committed
cmd/coordinator: build test packages for misc-compile builders
Only works for Go 1.21+. Go 1.20 is excluded for now because `go tool dist test -compile-only` does not work as expected for that release. Fixes golang/go#61923. Change-Id: I6587576def06d07752c938a1f8d45cfcc74de7f7 Reviewed-on: https://go-review.googlesource.com/c/build/+/518295 Run-TryBot: Michael Knyszek <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent d6acd95 commit a24ba0f

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

cmd/coordinator/buildstatus.go

+32-3
Original file line numberDiff line numberDiff line change
@@ -634,11 +634,14 @@ func (st *buildStatus) runAllSharded() (remoteErr, err error) {
634634
return nil, err
635635
}
636636

637-
if st.conf.RunBench {
637+
switch {
638+
case st.conf.RunBench:
638639
remoteErr, err = st.runBenchmarkTests()
639-
} else if st.IsSubrepo() {
640+
case st.IsSubrepo():
640641
remoteErr, err = st.runSubrepoTests()
641-
} else if !st.conf.IsCrossCompileOnly() {
642+
case st.conf.IsCrossCompileOnly():
643+
remoteErr, err = st.buildTestPackages()
644+
default:
642645
// Only run platform tests if we're not cross-compiling.
643646
// dist can't actually build test packages without running them yet.
644647
// See #58297.
@@ -658,6 +661,32 @@ func (st *buildStatus) runAllSharded() (remoteErr, err error) {
658661
return nil, nil
659662
}
660663

664+
// buildTestPackages runs `go tool dist test -compile-only`, which builds all standard
665+
// library test packages but does not run any tests. Used in cross-compilation modes.
666+
func (st *buildStatus) buildTestPackages() (remoteErr, err error) {
667+
if st.RevBranch == "release-branch.go1.19" || st.RevBranch == "release-branch.go1.20" {
668+
// TODO(mknyszek): Go 1.19 and 1.20 don't support `go tool dist test -compile-only`
669+
// very well. Remove this condition when Go 1.20 is no longer supported.
670+
return nil, nil
671+
}
672+
sp := st.CreateSpan("build_test_pkgs")
673+
remoteErr, err = st.bc.Exec(st.ctx, path.Join("go", "bin", "go"), buildlet.ExecOpts{
674+
Output: st,
675+
Debug: true,
676+
Args: []string{"tool", "dist", "test", "-compile-only"},
677+
})
678+
if err != nil {
679+
sp.Done(err)
680+
return nil, err
681+
}
682+
if remoteErr != nil {
683+
sp.Done(remoteErr)
684+
return fmt.Errorf("go tool dist test -compile-only failed: %v", remoteErr), nil
685+
}
686+
sp.Done(nil)
687+
return nil, nil
688+
}
689+
661690
func (st *buildStatus) doSnapshot(bc buildlet.Client) error {
662691
// If we're using a pre-built snapshot, don't make another.
663692
if st.useSnapshot() {

0 commit comments

Comments
 (0)