Skip to content

Commit ae60636

Browse files
aclementsgopherbot
authored andcommitted
cmd/dist: drop support for pre-compiled test binaries
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 <[email protected]> Auto-Submit: Austin Clements <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Austin Clements <[email protected]>
1 parent 15e2669 commit ae60636

File tree

1 file changed

+0
-60
lines changed

1 file changed

+0
-60
lines changed

src/cmd/dist/test.go

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"log"
1212
"os"
1313
"os/exec"
14-
"path"
1514
"path/filepath"
1615
"reflect"
1716
"regexp"
@@ -390,11 +389,6 @@ func (t *tester) registerStdTest(pkg string) {
390389
break
391390
}
392391
}
393-
// Special case for our slow cross-compiled
394-
// qemu builders:
395-
if t.shouldUsePrecompiledStdTest() {
396-
return t.runPrecompiledStdTest(t.timeoutDuration(timeoutSec))
397-
}
398392
args := []string{
399393
"test",
400394
"-short=" + short(),
@@ -1657,60 +1651,6 @@ func (t *tester) makeGOROOTUnwritable() (undo func()) {
16571651
return undo
16581652
}
16591653

1660-
// shouldUsePrecompiledStdTest reports whether "dist test" should use
1661-
// a pre-compiled go test binary on disk rather than running "go test"
1662-
// and compiling it again. This is used by our slow qemu-based builder
1663-
// that do full processor emulation where we cross-compile the
1664-
// make.bash step as well as pre-compile each std test binary.
1665-
//
1666-
// This only reports true if dist is run with an single go_test:foo
1667-
// argument (as the build coordinator does with our slow qemu-based
1668-
// builders), we're in a builder environment ("GO_BUILDER_NAME" is set),
1669-
// and the pre-built test binary exists.
1670-
func (t *tester) shouldUsePrecompiledStdTest() bool {
1671-
bin := t.prebuiltGoPackageTestBinary()
1672-
if bin == "" {
1673-
return false
1674-
}
1675-
_, err := os.Stat(bin)
1676-
return err == nil
1677-
}
1678-
1679-
// prebuiltGoPackageTestBinary returns the path where we'd expect
1680-
// the pre-built go test binary to be on disk when dist test is run with
1681-
// a single argument.
1682-
// It returns an empty string if a pre-built binary should not be used.
1683-
func (t *tester) prebuiltGoPackageTestBinary() string {
1684-
if len(stdMatches) != 1 || t.race || t.compileOnly || os.Getenv("GO_BUILDER_NAME") == "" {
1685-
return ""
1686-
}
1687-
pkg := stdMatches[0]
1688-
return filepath.Join(os.Getenv("GOROOT"), "src", pkg, path.Base(pkg)+".test")
1689-
}
1690-
1691-
// runPrecompiledStdTest runs the pre-compiled standard library package test binary.
1692-
// See shouldUsePrecompiledStdTest above; it must return true for this to be called.
1693-
func (t *tester) runPrecompiledStdTest(timeout time.Duration) error {
1694-
bin := t.prebuiltGoPackageTestBinary()
1695-
fmt.Fprintf(os.Stderr, "# %s: using pre-built %s...\n", stdMatches[0], bin)
1696-
cmd := exec.Command(bin, "-test.short="+short(), "-test.timeout="+timeout.String())
1697-
setDir(cmd, filepath.Dir(bin))
1698-
cmd.Stdout = os.Stdout
1699-
cmd.Stderr = os.Stderr
1700-
if err := cmd.Start(); err != nil {
1701-
return err
1702-
}
1703-
// And start a timer to kill the process if it doesn't kill
1704-
// itself in the prescribed timeout.
1705-
const backupKillFactor = 1.05 // add 5%
1706-
timer := time.AfterFunc(time.Duration(float64(timeout)*backupKillFactor), func() {
1707-
fmt.Fprintf(os.Stderr, "# %s: timeout running %s; killing...\n", stdMatches[0], bin)
1708-
cmd.Process.Kill()
1709-
})
1710-
defer timer.Stop()
1711-
return cmd.Wait()
1712-
}
1713-
17141654
// raceDetectorSupported is a copy of the function
17151655
// internal/platform.RaceDetectorSupported, which can't be used here
17161656
// because cmd/dist has to be buildable by Go 1.4.

0 commit comments

Comments
 (0)