]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: drop support for pre-compiled test binaries
authorAustin Clements <austin@google.com>
Wed, 9 Feb 2022 14:38:01 +0000 (09:38 -0500)
committerGopher Robot <gobot@golang.org>
Fri, 14 Oct 2022 17:56:44 +0000 (17:56 +0000)
We haven't used this in a while and it's going to complicate later
changes to dist, so drop support. This was primarily for supporting
slow QEMU-based builders, but an alternative and simpler way to do
that if we need to in the future is to supply a go_exec wrapper to run
tests in QEMU, like we do for other emulated platforms.

Simplification for #37486.

Change-Id: Idc0383f59c61d8546ea3b4d2eede4acdaf30d9b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/431256
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Austin Clements <austin@google.com>

src/cmd/dist/test.go

index 54eb41c8a48148e5eb430f5453a77e89e41ff284..5b8676c4c75ab6b05eb7f0d54fed207d789fd360 100644 (file)
@@ -11,7 +11,6 @@ import (
        "log"
        "os"
        "os/exec"
-       "path"
        "path/filepath"
        "reflect"
        "regexp"
@@ -390,11 +389,6 @@ func (t *tester) registerStdTest(pkg string) {
                                        break
                                }
                        }
-                       // Special case for our slow cross-compiled
-                       // qemu builders:
-                       if t.shouldUsePrecompiledStdTest() {
-                               return t.runPrecompiledStdTest(t.timeoutDuration(timeoutSec))
-                       }
                        args := []string{
                                "test",
                                "-short=" + short(),
@@ -1657,60 +1651,6 @@ func (t *tester) makeGOROOTUnwritable() (undo func()) {
        return undo
 }
 
-// shouldUsePrecompiledStdTest reports whether "dist test" should use
-// a pre-compiled go test binary on disk rather than running "go test"
-// and compiling it again. This is used by our slow qemu-based builder
-// that do full processor emulation where we cross-compile the
-// make.bash step as well as pre-compile each std test binary.
-//
-// This only reports true if dist is run with an single go_test:foo
-// argument (as the build coordinator does with our slow qemu-based
-// builders), we're in a builder environment ("GO_BUILDER_NAME" is set),
-// and the pre-built test binary exists.
-func (t *tester) shouldUsePrecompiledStdTest() bool {
-       bin := t.prebuiltGoPackageTestBinary()
-       if bin == "" {
-               return false
-       }
-       _, err := os.Stat(bin)
-       return err == nil
-}
-
-// prebuiltGoPackageTestBinary returns the path where we'd expect
-// the pre-built go test binary to be on disk when dist test is run with
-// a single argument.
-// It returns an empty string if a pre-built binary should not be used.
-func (t *tester) prebuiltGoPackageTestBinary() string {
-       if len(stdMatches) != 1 || t.race || t.compileOnly || os.Getenv("GO_BUILDER_NAME") == "" {
-               return ""
-       }
-       pkg := stdMatches[0]
-       return filepath.Join(os.Getenv("GOROOT"), "src", pkg, path.Base(pkg)+".test")
-}
-
-// runPrecompiledStdTest runs the pre-compiled standard library package test binary.
-// See shouldUsePrecompiledStdTest above; it must return true for this to be called.
-func (t *tester) runPrecompiledStdTest(timeout time.Duration) error {
-       bin := t.prebuiltGoPackageTestBinary()
-       fmt.Fprintf(os.Stderr, "# %s: using pre-built %s...\n", stdMatches[0], bin)
-       cmd := exec.Command(bin, "-test.short="+short(), "-test.timeout="+timeout.String())
-       setDir(cmd, filepath.Dir(bin))
-       cmd.Stdout = os.Stdout
-       cmd.Stderr = os.Stderr
-       if err := cmd.Start(); err != nil {
-               return err
-       }
-       // And start a timer to kill the process if it doesn't kill
-       // itself in the prescribed timeout.
-       const backupKillFactor = 1.05 // add 5%
-       timer := time.AfterFunc(time.Duration(float64(timeout)*backupKillFactor), func() {
-               fmt.Fprintf(os.Stderr, "# %s: timeout running %s; killing...\n", stdMatches[0], bin)
-               cmd.Process.Kill()
-       })
-       defer timer.Stop()
-       return cmd.Wait()
-}
-
 // raceDetectorSupported is a copy of the function
 // internal/platform.RaceDetectorSupported, which can't be used here
 // because cmd/dist has to be buildable by Go 1.4.