mirror of https://github.com/golang/go.git
cmd/dist: use goTest for manual go test invocations
This CL rewrites everywhere in dist that manually constructs an exec.Cmd to run "go test" to use the goTest abstraction. All remaining invocations of "go test" after this CL construct the command line manually, but ultimately use addCmd to execute it. I traced all exec calls from cmd/dist on linux/amd64 and this makes only no-op changes (such as re-arranging the order of flags). For #37486. Change-Id: Idc7497e39bac04def7ddaf2010881c9623e76fd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/450015 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Austin Clements <austin@google.com>
This commit is contained in:
parent
c3a0854e31
commit
2946c887ba
|
|
@ -550,39 +550,18 @@ func (t *tester) registerStdTest(pkg string) {
|
|||
defer timelog("end", dt.name)
|
||||
ranGoTest = true
|
||||
|
||||
timeoutSec := 180
|
||||
timeoutSec := 180 * time.Second
|
||||
for _, pkg := range stdMatches {
|
||||
if pkg == "cmd/go" {
|
||||
timeoutSec *= 3
|
||||
break
|
||||
}
|
||||
}
|
||||
args := []string{
|
||||
"test",
|
||||
"-short=" + short(),
|
||||
t.tags(),
|
||||
t.timeout(timeoutSec),
|
||||
}
|
||||
if gcflags != "" {
|
||||
args = append(args, "-gcflags=all="+gcflags)
|
||||
}
|
||||
if t.race {
|
||||
args = append(args, "-race")
|
||||
}
|
||||
if t.msan {
|
||||
args = append(args, "-msan")
|
||||
}
|
||||
if t.asan {
|
||||
args = append(args, "-asan")
|
||||
}
|
||||
if t.compileOnly {
|
||||
args = append(args, "-run=^$")
|
||||
}
|
||||
args = append(args, stdMatches...)
|
||||
cmd := exec.Command(gorootBinGo, args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
return (&goTest{
|
||||
timeout: timeoutSec,
|
||||
gcflags: gcflags,
|
||||
pkgs: stdMatches,
|
||||
}).run(t)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -603,23 +582,13 @@ func (t *tester) registerRaceBenchTest(pkg string) {
|
|||
timelog("start", dt.name)
|
||||
defer timelog("end", dt.name)
|
||||
ranGoBench = true
|
||||
args := []string{
|
||||
"test",
|
||||
"-short=" + short(),
|
||||
"-race",
|
||||
t.timeout(1200), // longer timeout for race with benchmarks
|
||||
"-run=^$", // nothing. only benchmarks.
|
||||
"-benchtime=.1s",
|
||||
"-cpu=4",
|
||||
}
|
||||
if !t.compileOnly {
|
||||
args = append(args, "-bench=.*")
|
||||
}
|
||||
args = append(args, benchMatches...)
|
||||
cmd := exec.Command(gorootBinGo, args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
return (&goTest{
|
||||
timeout: 1200 * time.Second, // longer timeout for race with benchmarks
|
||||
race: true,
|
||||
bench: true,
|
||||
cpu: "4",
|
||||
pkgs: benchMatches,
|
||||
}).run(t)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -789,9 +758,10 @@ func (t *tester) registerTests() {
|
|||
|
||||
// Run `go test fmt` in the moved GOROOT, without explicitly setting
|
||||
// GOROOT in the environment. The 'go' command should find itself.
|
||||
cmd := exec.Command(filepath.Join(moved, "bin", "go"), "test", "fmt")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd := (&goTest{
|
||||
goroot: moved,
|
||||
pkg: "fmt",
|
||||
}).command(t)
|
||||
unsetEnv(cmd, "GOROOT")
|
||||
unsetEnv(cmd, "GOCACHE") // TODO(bcmills): ...why‽
|
||||
err := cmd.Run()
|
||||
|
|
|
|||
Loading…
Reference in New Issue