diff options
author | Russ Cox <rsc@golang.org> | 2021-01-07 11:22:42 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-01-08 17:14:00 +0000 |
commit | fefad1dc856d66c024a94d3421fc52ff326fe970 (patch) | |
tree | 3bbadbdfad54ed67bef30a63dce47e2018fba49e /test | |
parent | 6728118e0ae2658e758a64fe86e2e1a3aa55268c (diff) | |
download | go-fefad1dc856d66c024a94d3421fc52ff326fe970.tar.gz go-fefad1dc856d66c024a94d3421fc52ff326fe970.zip |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/run.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/run.go b/test/run.go index db3e9f6c2f..624f2236a1 100644 --- a/test/run.go +++ b/test/run.go @@ -467,6 +467,8 @@ func goGcflagsIsEmpty() bool { return "" == os.Getenv("GO_GCFLAGS") } +var errTimeout = errors.New("command exceeded time limit") + // run runs a test. func (t *test) run() { start := time.Now() @@ -642,16 +644,18 @@ func (t *test) run() { case err = <-done: // ok case <-tick.C: + cmd.Process.Signal(os.Interrupt) + time.Sleep(1 * time.Second) cmd.Process.Kill() - err = <-done - // err = errors.New("Test timeout") + <-done + err = errTimeout } tick.Stop() } } else { err = cmd.Run() } - if err != nil { + if err != nil && err != errTimeout { err = fmt.Errorf("%s\n%s", err, buf.Bytes()) } return buf.Bytes(), err @@ -731,6 +735,10 @@ func (t *test) run() { t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out) return } + if err == errTimeout { + t.err = fmt.Errorf("compilation timed out") + return + } } else { if err != nil { t.err = err |