]> Cypherpunks.ru repositories - gostls13.git/commit
internal/testenv: remove HasExec and simplify other support checks again
authorBryan C. Mills <bcmills@google.com>
Tue, 2 May 2023 17:07:26 +0000 (13:07 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 4 May 2023 19:52:29 +0000 (19:52 +0000)
commit79723f389b630e61c5e9635235b7f4c624ac1379
tree88696d86ce130583521dd875bcfc779a4b506749
parenta82f69f60e976d1a99c477903f5de98839c24f70
internal/testenv: remove HasExec and simplify other support checks again

HasExec is an attractive nuisance: it is tempting to check in a
TestMain function, but TestMain really shouldn't be running
subprocesses eagerly anyway (they add needless overhead for operations
like 'go test -list=.'), and the trick of re-executing the test binary
to determine whether 'exec' works ends up in infinite recursion if
TestMain itself calls HasExec.

Instead, tests that need to execute a subprocess should call
MustHaveExec or MustHaveExecPath from within a specific test,
or just try to exec the program and check its error status
(perhaps using testenv.SyscallIsNotSupported).

While I'm in here and testing on the SlowBots anyway, a few other
cleanups relating to subprocesses:

- Add more t.Helper calls to support checks where appropriate.

- Remove findGoTool, which can be simplified to exec.LookPath as of
  CL 404134.

- Add tests confirming the expected behavior of the support functions
  on the Go project's builders.

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