diff options
author | Bryan C. Mills <bcmills@google.com> | 2022-04-22 23:33:16 -0400 |
---|---|---|
committer | Bryan Mills <bcmills@google.com> | 2022-04-26 14:49:07 +0000 |
commit | 7b31af0eae8ce369d5ffd16be1de0b2f0121e7c2 (patch) | |
tree | 7b7097d33aa1c4b0fbc23c85b1f95d4124c4662d /src/os/exec/exec_linux_test.go | |
parent | ad5eaa8c4cd952df0d4894f11ee0158a9a33a0f3 (diff) | |
download | go-7b31af0eae8ce369d5ffd16be1de0b2f0121e7c2.tar.gz go-7b31af0eae8ce369d5ffd16be1de0b2f0121e7c2.zip |
os/exec: use a TestMain to avoid hijacking stdout for helper commands
The previous implementation of helperCommand relied on running a
well-known Test function which implemented all known commands.
That not only added Skip noise in the test's output, but also (and
more importantly) meant that the commands could not write directly to
stdout in the usual way, since the testing package hijacks os.Stdout
for its own use.
The new implementation addresses the above issues, and also ensures
that all registered commands are actually used, reducing the risk of
an unused command sticking around after refactoring.
It also sets the subprocess environment variable directly in the test
process, instead of on each individual helper command's Env field,
allowing helper commands to be used without an explicit Env.
Updates #50599.
(Also for #50436.)
Change-Id: I189c7bed9a07cfe47a084b657b88575b1ee370b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/401934
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/os/exec/exec_linux_test.go')
-rw-r--r-- | src/os/exec/exec_linux_test.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/os/exec/exec_linux_test.go b/src/os/exec/exec_linux_test.go index 4a37c96e63..b9f6b7b767 100644 --- a/src/os/exec/exec_linux_test.go +++ b/src/os/exec/exec_linux_test.go @@ -22,7 +22,7 @@ import ( ) func init() { - if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" { + if os.Getenv("GO_EXEC_TEST_PID") == "" { return } |