Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: go test links and runs tests for packages with no tests #26242
If asked to run "go test" on a directory with no *_test.go files, I expect "go test" not to build and run a test binary. Go 1.10 and earlier did not. But the current Go 1.11 tree does. Surprise!
If you run 'go test -badflag' then you can see the difference quite clearly: if the test doesn't run, nothing detects the bad flag, so it succeeds.
A more reasonable example is if you have a test helper library you use for all your tests that defines some common flag. It used to work to run
assuming that all your tests imported the library defining -my.flag. But now if any packages in that tree have no tests at all, a dummy test binary gets run that of course does not know about -my.flag
This was originally reported as a bug against vgo in #26214.