]> Cypherpunks repositories - gostls13.git/commit
internal/testenv: add CommandContext and Command
authorBryan C. Mills <bcmills@google.com>
Wed, 26 Oct 2022 16:18:13 +0000 (12:18 -0400)
committerGopher Robot <gobot@golang.org>
Mon, 31 Oct 2022 20:53:50 +0000 (20:53 +0000)
commit84cd7ab3c388fb3280cf426a35045d85cda99ff8
treec0095494d1b06e22b0d801c0ad33ad50492d2e96
parent76940b3e5749a9936cbc32631e068065c2003267
internal/testenv: add CommandContext and Command

This adds a testenv.CommandContext function, with timeout behavior
based on the existing logic in cmd/go.TestScript: namely, the command
is terminated with SIGQUIT (if supported) with an arbitrary grace
period remaining until the test's deadline.

If the test environment does not support executing subprocesses,
CommandContext skips the test.

If the command is terminated due to the timout expiring or the test
fails to wait for the command after starting it, CommandContext marks
the test as failing.

For tests where a shorter timeout is desired (such as for fail-fast
behavior), one may be supplied using context.WithTimeout.

The more concise Command helper is like CommandContext but without
the need to supply an explicit Context.

Updates #50436.

Change-Id: Ifd81fb86c402f034063c9e9c03045b4106eab81a
Reviewed-on: https://go-review.googlesource.com/c/go/+/445596
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/internal/testenv/testenv.go