1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:14:41 -07:00

cmd/go: kill test.out after 1 minute

Will have to do better but this is enough to
stop the builders from hanging, I hope.

R=golang-dev, dsymonds, adg
CC=golang-dev
https://golang.org/cl/5533066
This commit is contained in:
Russ Cox 2012-01-10 21:01:58 -08:00
parent 1250f94f93
commit 0c012af114

View File

@ -463,8 +463,30 @@ func (b *builder) runTest(a *action) error {
cmd := exec.Command(args[0], args[1:]...)
cmd.Dir = a.p.Dir
var buf bytes.Buffer
cmd.Stdout = &buf
cmd.Stderr = &buf
t0 := time.Now()
out, err := cmd.CombinedOutput()
err := cmd.Start()
const deadline = 1 * time.Minute
tick := time.NewTimer(deadline)
if err == nil {
done := make(chan error)
go func() {
done <- cmd.Wait()
}()
select {
case err = <-done:
// ok
case <-tick.C:
cmd.Process.Kill()
err = <-done
fmt.Fprintf(&buf, "*** Test killed: ran too long.\n")
}
tick.Stop()
}
out := buf.Bytes()
t1 := time.Now()
t := fmt.Sprintf("%.3fs", t1.Sub(t0).Seconds())
if err == nil {