-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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 with -run /something
prints "no tests to run" inconsistently
#48851
Comments
Subtests can be created dynamically, so the only way to conclusively discover all of them is to actually run the top-level tests that match the pattern. So, in practice, |
So I guess that means that the first two outputs are correct, and the third one is wrong.
|
Yep I agree. At the very least, |
OTOH, if I specified a subtest filter which didn't match anything, it's probably not what I intended to do and would like to know, so although the third output is technically wrong but IMHO preferable. |
I see your point about the fact that it probably wasn't intentionally. But a test is getting run, it's just that no subtests were run. Imagine a scenario where
Which is a bit confusing. I would think "Why is it printing the log line if no tests were run?". Especially knowing that if I replaced the
|
That one is even worse, because it both printed FAIL and "testing: warning no tests to run". I don't know of any other situation where that can happen. |
My inclination is to change the message to That would at least be correct in all three cases, even if it conveys slightly less information about whether the tests that did run were meaningful. |
Seems reasonable enough to me 👍 |
@bcmills This is in the 1.18 milestone; time to move to 1.19? Thanks. |
Looks like this is fixed in go1.20 already:
|
When running a test with
-run /subtest_name
where no subtests match, it will print okay, even though no tests were run. Same is true if you use-run Test/subtest_name
.If instead, you do
-run TestNameInPackage/subtest_name
(whereTestNameInPackage
is the name of a test in that package) it will print "[no tests to run]"Example:
It has a similar issue when
-v
is set/cc @bcmills @jayconrod @matloob
The text was updated successfully, but these errors were encountered: