-
Notifications
You must be signed in to change notification settings - Fork 86
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
message confusing for non-incrementing failures. #728
Comments
|
That non-zero exit status is far more serious than the confusing message IMO |
The non-zero status is correct here. The test really did fail. Indicating this via TAP is difficult because TAP is terrible. |
Might make sense to add a final OK event for clarity. Obviously that effects test count, but nobody seemed to complain that Test::NoWarnings does that. |
In that case isn't it easier to just make the |
We've just worked aroudn it. We just add one to the plan when we use Test::NoWarnings. |
@autarch possibly, why don't you try it and see if it looks sane? |
use strict;
use warnings;
use Test::More;
use Test2::Plugin::NoWarnings;
ok 1, 'foo';
warn 'wtf';
ok 2, 'bar';
done_testing(); The output with
And with
|
I think bumping the count looks good. Messing with the test count is what test tools do, so I don't think it's unreasonable that using this plugin can do such a thing. The one issue is that it doesn't output a test result when there's no warnings, so you can't rely on a static test count. |
Why wouldn't you want to emit a test at the end that says you got no warnings? |
It's not so much about want as about how the plugin is implemented. That said, I'm not sure I want to ;) It's just extra work for not much gain, IMO. The current implementation is really simple. Adding this extra test would make it more complicated. |
In this case it would be extra tests when you already have a failure, so I don't think the test count / static plan issue is a big deal, the test count is only wrong on failure. if it looks good then cool. I still think we need to correct this end of test message though, for other tools with similar effects. |
I can only agree TAP is terrible, but the return value not matching the number of not-ok's is just plain confusing. |
Oh, I see what you're saying. I thought you were saying that exiting non-zero was wrong. |
Failure count was being bumped by all events that cause fail. This could result in diagnostics reporting failed tests even when all ok's passed. This should be a bit more clear Fixes #728
5f39961 is a fix that should make this all a lot less confusing. |
Failure count was being bumped by all events that cause fail. This could result in diagnostics reporting failed tests even when all ok's passed. This should be a bit more clear Fixes #728
d0ea5eb updated |
I noticed that Scalar-Does tests fail since this commit https://rt.cpan.org/Public/Bug/Display.html?id=119030. This boils down to this code:
It returns non-zero exit code. Is this because Test::NoWarnings shouldn't be used this way? |
That doesn't look good to me |
this does in fact bisect to 7aa8794 |
I have investigated. The problem is that the hub is finalized before the final event happens. Example:
That is using the commit just before 7aa8794. Notice that the plan comes in just before the final event. Valid TAP requires the plan to be either before all the ok's, or after all the ok's, not in the middle. 7aa8794 did not cause the bug, it exposed it. Things were passing incorrectly before that commit. |
Ah-Ha: https://rt.cpan.org/Public/Bug/Display.html?id=66485 Test::NoWarnings is known to not work with done_testing. The test in https://rt.cpan.org/Public/Bug/Display.html?id=119030 must have been written while Test2 was incorrectly passing. The bug is not that the test now fails, the bug is that your test used to pass when it should not have. You need to switch away from using done_testing in that test. If you were to install the old Test::More from before the Test2 stuff was added your test would still be incorrect (but might pass by chance, try adding an ok and then it would surely fail) |
I am going to re-close this ticket. The problem is that you are using Test::NoWarnings incorrectly. There was a Test2 bug as well, but it was already fixed which is why you are having a problem, you were relying on the bug. |
Thank you for the explanation.
|
for future reference, Test::Warnings plays nicely with |
IMO Test2 should protect the user better from such a buggy usage. |
the silent pass was fixed, that is why we are having this discussion at all, so there is no action to be taken there. as for the inconsistent end result, the problem is that both Test2 and Test::NoWarnings use END blocks. Test2 uses one to set the exit value and do its final protections. Test::NoWarnings uses one to send an event. END blocks are tricky, execution depends on load order. There is really not much more Test2 can do technically to help here. |
Yeah, I realized that right after posting, but my edit was too late. I do think the diagnostic can be improved though. |
I can make a hub warn or die if it recieves an event after finalization. That might help a little, but is not a bad idea even if it is of minimal use here. |
Some events cause failures, but do not bump the test count (and do not add an 'ok' line in TAP output). At the end this produces a confusing message:
# Looks like you failed 1 test of 5.
This even if the 5 ok lines were all a pass.
This message should be clarified, maybe an extra test state variable to track the types of failures will be needed.
The text was updated successfully, but these errors were encountered: