mirror of
https://github.com/golang/go.git
synced 2025-11-10 13:41:05 +00:00
test: fix timeout code for invoking compiler
When running go tool compile, go tool is running compile as a subprocess. Killing go tool with Process.Kill leaves the subprocess behind. Send an interrupt signal first, which it can forward on to the compile subprocess. Also report the timeout in errorcheck -t. Change-Id: I7ae0029bbe543ed7e60e0fea790dd0739d10bcaa Reviewed-on: https://go-review.googlesource.com/c/go/+/282313 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
6728118e0a
commit
fefad1dc85
1 changed files with 11 additions and 3 deletions
14
test/run.go
14
test/run.go
|
|
@ -467,6 +467,8 @@ func goGcflagsIsEmpty() bool {
|
||||||
return "" == os.Getenv("GO_GCFLAGS")
|
return "" == os.Getenv("GO_GCFLAGS")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errTimeout = errors.New("command exceeded time limit")
|
||||||
|
|
||||||
// run runs a test.
|
// run runs a test.
|
||||||
func (t *test) run() {
|
func (t *test) run() {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
@ -642,16 +644,18 @@ func (t *test) run() {
|
||||||
case err = <-done:
|
case err = <-done:
|
||||||
// ok
|
// ok
|
||||||
case <-tick.C:
|
case <-tick.C:
|
||||||
|
cmd.Process.Signal(os.Interrupt)
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
cmd.Process.Kill()
|
cmd.Process.Kill()
|
||||||
err = <-done
|
<-done
|
||||||
// err = errors.New("Test timeout")
|
err = errTimeout
|
||||||
}
|
}
|
||||||
tick.Stop()
|
tick.Stop()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil && err != errTimeout {
|
||||||
err = fmt.Errorf("%s\n%s", err, buf.Bytes())
|
err = fmt.Errorf("%s\n%s", err, buf.Bytes())
|
||||||
}
|
}
|
||||||
return buf.Bytes(), err
|
return buf.Bytes(), err
|
||||||
|
|
@ -731,6 +735,10 @@ func (t *test) run() {
|
||||||
t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out)
|
t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if err == errTimeout {
|
||||||
|
t.err = fmt.Errorf("compilation timed out")
|
||||||
|
return
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.err = err
|
t.err = err
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue