New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: Test tool eats known flags, docs say it doesn't #12177
Comments
The docs do say, "after the package names", but your example has no package names. This should work:
|
I'm sorry, I meant the word "pkg" to be a standin for "package_name" -- whatever package you might happen to be testing. So, yes, there is a package name there. Sorry if the short name was confusing. Your proposal does not work for me.
|
(Also does not work when I include the = sign in -v=2, just in case that matters.)
|
Not convinced this is just a documentation issue. |
Fair enough. But I don't think this has ever worked. Right now, the only way for an arg to make it into passToTest unmodified is if testFlag() returns nil for f. I can't see any revisions where that was different, but I didn't look at all of them -- I just picked a few randomly including the initial. The fix/feature would be to put an else here that simply appends the flag to passToTest if inPkg. That would make the behavior conform to the doc, I think. Probably we'd want to change the name of inPkg to "startedPkg" or "seenPkg," since the current name implies that you can leave once you begin. |
Just so it's clear -- would you like me to implement this, or will you, or have you not decided whether it would be desirable? I'm fine with any of these outcomes. I just want to make sure we're not both waiting for the other to take some action. |
I'll do it. |
CL https://golang.org/cl/14826 mentions this issue. |
CL https://golang.org/cl/17775 mentions this issue. |
The new flag -args stops flag processing, leaving the rest of the command line to be passed to the underlying test binary verbatim. Thus, both of these pass a literal -v -n on the test binary command line, without putting the go command into verbose mode or disabling execution of commands: go test . -args -v -n go test -args -v -n Also try to make the documentation a bit clearer. Fixes golang#7221. Fixes golang#12177. Change-Id: Ief9e830a6fbb9475d96011716a86e2524a35eceb Reviewed-on: https://go-review.googlesource.com/17775 Reviewed-by: Rob Pike <r@golang.org>
This issue is related to this discussion. The docs say:
"go test [-c] [-i] [build and test flags] [packages] [flags for test binary]
"If the test binary needs any other flags, they should be presented after the package names. The go tool treats as a flag the first argument that begins with a minus sign that it does not recognize itself; that argument and all subsequent arguments are passed as arguments to the test binary." (Emphasis mine.)
However, try running this command on any package that imports "github.com/golang/glog"
With go1.5rc1 (go version devel +d3ffc97 Wed Jul 29 23:50:20 2015 +0000 linux/amd64):
According to the docs, -v=2 should be passed down to the binary.
At a minimum, the docs should be fixed. Also, considering how common some of go test's flag names are, I think the behavior in the docs should also be implemented. However, it seems like there are probably plenty of scripts out there relying on the bad behavior. Perhaps a new directive, say "--" could be added, after which the remaining command line would actually be passed unmodified to the child binary.
The text was updated successfully, but these errors were encountered: