-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: "go test -notrealflag ./..." fails silently if the current directory has no tests #35097
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
Per https://golang.org/cmd/go/#hdr-Testing_flags:
Since the pattern did not match any test binaries, no such binaries were run. However, you could just as easily run Since |
@bcmills if you run it without the flag there are a tons of sub packages that will be tested. And if that same command is ran inside a directory which there are tests it will actually correctly report that this flag is not there
|
The Compare:
|
The problem is not where it comes from, the problem is that in the one case the tests are not ran for any of the other directories which leads to the user having no idea why test haven't ran ... |
#36527 reported a similar issue, although with an actual test file in the top-level directory (so there actually was a test to pass the flag to), and that test file actually did define the flag in question. |
Thinking about this some more, I still don't think there's anything we can do about it without breaking existing use-cases. Any special case to reject unknown flags if there is no work at all would still fail for cases like #36527 where there actually is work to do. It seems like the only robust way to ensure that the user's intended package argument is actually parsed as such is to require a package argument in all cases, but lots of users today have already learned to run commands like |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Running
go test -notrealflag ./...
in a directory with no tests doesn't not report that there is no such flag.In the real case I hit I was mistakenly providing
-fastfail
instead of-failfast
and this did not run any tests and gave me no reason why it didn't.There is an error if the current directory has tests.
What did you expect to see?
An error and the help of
go test
What did you see instead?
The text was updated successfully, but these errors were encountered: