]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/testshared: pass -x flag only to commands supporting it
authorJakub Čajka <jcajka@redhat.com>
Mon, 13 Dec 2021 12:28:15 +0000 (13:28 +0100)
committerIan Lance Taylor <iant@golang.org>
Wed, 15 Dec 2021 20:18:30 +0000 (20:18 +0000)
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 <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

misc/cgo/testshared/shared_test.go

index d5d018f1516a774ecc4313a7a45c9a55da548077..7b8cc66c3a33f4fef24a1240b5aadfd4c976d221 100644 (file)
@@ -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:]...)