From d5fefbb4980aaf46ac25344615c660136c365b9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jakub=20=C4=8Cajka?= Date: Mon, 13 Dec 2021 13:28:15 +0100 Subject: [PATCH] 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 --- misc/cgo/testshared/shared_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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:]...) -- 2.51.0