-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: go test usage regression, inconsistency #13583
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
Comments
I just ran across a similar (perhaps exactly the same) issue. It applies to test flags that This no longer works (note: all our code uses Gustavo's gocheck package
Instead, one is required to write:
or
|
Comment from @rsc in https://golang.org/cl/14826:
|
So, is |
CL https://golang.org/cl/17773 mentions this issue. |
What I objected to with -- in the past was the idea that you'd put more flags after it. The long-established definition of -- is that it stops flag processing, even (especially!) when what comes next look like more flags. There's also a compatibility issue. From the beginning, -- has been passed through to the underlying binary, so that it had the same meaning in the underlying test binary command line as it did in the go test command line. There may well be tests that expect that. The same compatibility issue could arise with -args, but -args is not a long-established convention being given a different meaning, so it's less likely that a test already expects it and also less problematic to give it the meaning we need. |
I'm fine with |
FWIW, Rob and I discussed -- just now, and he started out on your side but
when I made the same point I just made to you, he agreed it doesn't make
sense to use -- for this.
The important point is that go test is kind of weird: the command line is
serving both as arguments to 'go test' but then, usually, in a rewritten
form also as arguments to the test binary itself. We've worked pretty hard
(and, I would argue, successfully) so that users don't think about that:
they see a single thing, even though underneath there are two different
programs implementing that thing. It would be strange for --, which means
"the rest of the command-line is _not_ flags" to mean that only for 1/2 of
the pieces.
|
I'll just register that I'm really not keen on -args. Thus AFAICS (this was certainly true for me) once someone To me, "--" does not mean "the rest of the command line is not Consider, for example:
vs
The "-n" argument is still a flag, even though it's after the "--". The compatibility issue is unfortunate though, and probably the clincher |
A more common place you'd see -- is in something like `ls -l -- -n` as an
alternative to `ls -l ./-n`.
The sh example is at the very least convoluted. I can't think of any other
examples where -- means "the rest of the command line is not interpreted as
flags by the top-level command". Most people don't know sh -c CMD takes
additional arguments at all, and what it does with them is inconsistent,
and sh -c is explicitly about reexecution in a direct way that I would
argue 'go test' is not.
Also, fun on my Mac:
```
$ sh -c 'echo $*' -- -n a b c
-n a b c
$ sh -c '/bin/echo $*' -- -n a b c
a b c$
$
```
Again maybe not the best example. :-)
Also, for the record, the way git uses -- (to separate one kind of non-flag
argument from another) is non-standard too.
|
Discussion on CL 14826, but I am creating an issue so it isn't forgotten for Go 1.6, one way or the other.
In short, these four commands have always worked:
Now the last does not.
The text was updated successfully, but these errors were encountered: