@@ -634,11 +634,14 @@ func (st *buildStatus) runAllSharded() (remoteErr, err error) {
634
634
return nil , err
635
635
}
636
636
637
- if st .conf .RunBench {
637
+ switch {
638
+ case st .conf .RunBench :
638
639
remoteErr , err = st .runBenchmarkTests ()
639
- } else if st .IsSubrepo () {
640
+ case st .IsSubrepo ():
640
641
remoteErr , err = st .runSubrepoTests ()
641
- } else if ! st .conf .IsCrossCompileOnly () {
642
+ case st .conf .IsCrossCompileOnly ():
643
+ remoteErr , err = st .buildTestPackages ()
644
+ default :
642
645
// Only run platform tests if we're not cross-compiling.
643
646
// dist can't actually build test packages without running them yet.
644
647
// See #58297.
@@ -658,6 +661,32 @@ func (st *buildStatus) runAllSharded() (remoteErr, err error) {
658
661
return nil , nil
659
662
}
660
663
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
+
661
690
func (st * buildStatus ) doSnapshot (bc buildlet.Client ) error {
662
691
// If we're using a pre-built snapshot, don't make another.
663
692
if st .useSnapshot () {
0 commit comments