namsral/flag

`go test -v` stops working

wyc opened this issue · 4 comments

wyc commented

Hi, when I use your library instead of the default flag, I encounter this error when I try to run tests in verbose mode:

$ go test -v
flag provided but not defined: -test.v

Any quick fix for this?

wyc commented

Okay, as a hack to make it work, I added this to my global vars:

var chatty = flag.Bool("test.v", false, "verbose: print additional output")

Taken from here: https://golang.org/src/testing/testing.go#L232

Now using only your package, this particular flag seems to work. Of course this isn't ideal as the others are still broken, but I guess I'll keep adding them to my project as needed until we get a fix here. E.g., go test -trace my.trace isn't working.

wyc commented

I see this issue describing the same thing: #9

Here are steps to reproduce:

  1. Download this gist into its own directory: https://gist.github.com/wyc/b6d7dae829e613e5260e4310061161de
  2. Run go test -v

The result should be something like this:

$ go test -v
flag provided but not defined: -test.v
Usage of /tmp/go-build338776245/_/tmp/repro/_test/repro.test:
exit status 2
FAIL    _/tmp/repro 0.001s

Thanks for taking the time to describe the problem and write a test.

Please test d922432 in the testflag branch for a fix.

wyc commented

Hey, thanks for the swift response on this! I really appreciate it. Your solution works perfectly for me.

Added a test here in case you wanted one:
#11

Consider it solved!