]> Cypherpunks repositories - gostls13.git/commit
cmd/go: error when -c or -i are used with unknown flags
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 12 Jun 2020 14:14:42 +0000 (15:14 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 24 Sep 2020 20:27:51 +0000 (20:27 +0000)
commit5824a4ce1a0e47f3093128371c7156b35fe9d806
tree6b63cd4b7d8cba88027eeaf9571589ec8a2b8c6a
parent4cba6c703f68a7c1718e589feaeb2530d7812fbf
cmd/go: error when -c or -i are used with unknown flags

Other test flags passed to the test binary, such as -run or -count, are
equally pointless when -c or -i are used, since the test binary is never
run. However, custom flags in that scenario are far more likely to be
due to human error, such as:

# note the "ldflags" typo, which silently did nothing
go test -c -lflags=-w

Instead, make this scenario error. It seems unlikely that anyone is
using -c along with intended custom-defined test flags, and if they are,
removing those extra flags that do nothing is probably a good idea
anyway.

We don't add this restriction for the flags defined in 'go help
testflag', since they are far less likely to be typos or unintended
mistakes. Another reason not to do that change is that other commands
similarly silently ignore no-op flags, such as:

# -d disables the build, so -ldflags is never used
go get -d -ldflags=-w

Fixes #39484.

Change-Id: I6ba2f6866562fe8f8fceaf4cd862d874bf5cd978
Reviewed-on: https://go-review.googlesource.com/c/go/+/237697
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/test/testflag.go
src/cmd/go/testdata/script/test_flag.txt