From: Jakub Čajka Date: Mon, 13 Dec 2021 12:28:15 +0000 (+0100) Subject: misc/cgo/testshared: pass -x flag only to commands supporting it X-Git-Tag: go1.18beta2~233 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d5fefbb4980aaf46ac25344615c660136c365b9f;p=gostls13.git misc/cgo/testshared: pass -x flag only to commands supporting it Running testshared with the -testx flag leads to: ./testshared.test -testx -testwork + mkdir -p /tmp/shared_test125221103 shared_test.go:79: executing go env -x GOROOT failed exit status 2: flag provided but not defined: -x usage: go env [-json] [-u] [-w] [var ...] Run 'go help env' for details. panic: executing go env -x GOROOT failed exit status 2: flag provided but not defined: -x usage: go env [-json] [-u] [-w] [var ...] Run 'go help env' for details. Change-Id: Id299979487c021e9ad1d57f5f7088d935830a6a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/371614 Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Trust: Cherry Mui --- diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go index d5d018f151..7b8cc66c3a 100644 --- a/misc/cgo/testshared/shared_test.go +++ b/misc/cgo/testshared/shared_test.go @@ -56,7 +56,7 @@ func runWithEnv(t *testing.T, msg string, env []string, args ...string) { // t.Fatalf if the command fails. func goCmd(t *testing.T, args ...string) string { newargs := []string{args[0]} - if *testX { + if *testX && args[0] != "env" { newargs = append(newargs, "-x") } newargs = append(newargs, args[1:]...)