Skip Menu |
 

This queue is for tickets about the Test-NoWarnings CPAN distribution.

Report information
The Basics
Id: 48136
Status: open
Priority: 0/
Queue: Test-NoWarnings

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: let warning go out as normal too
Date: Fri, 24 Jul 2009 09:54:35 +1000
To: bug-Test-NoWarnings [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
Download (untitled) / with headers
text/plain 741b
It'd be good if the Test::NoWarnings handler let each warning print as normal in addition to noting the problem for the final test result. Letting it print is good for seeing where the warning falls among diag() messages, or among each test "ok" print if running a .t outside of any test harness. I know the final result describes a test number etc, but it's not much fun hunting that down among previous output, and if the script crashes completely you miss out on it. I see make_catcher() has a "return $msg", was it meant to be "warn $msg" so as to chain up? (Incidentally, "local $Carp::Internal{__PACKAGE__.""} ..." could make a temporary change to that hash elem, if that might be easier and/or safer than an explicit decrement.)
Download (untitled) / with headers
text/plain 312b
I concur wholeheartedly. Tracking down what warned when and why is difficult when they're all smashed together at the end. The version of Test::NoWarnings I wrote as a test for Test::Builder2 lets the warnings pass through and I find it far more pleasant to work with. Even if it's a flag that can be flipped.
CC: bug-Test-NoWarnings [...] rt.cpan.org
Subject: Re: [rt.cpan.org #48136] let warning go out as normal too
Date: Sat, 15 Jan 2011 09:52:11 +1100
To: mschwern [...] cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
Download (untitled) / with headers
text/plain 2.1k
"Michael G Schwern via RT" <bug-Test-NoWarnings@rt.cpan.org> writes: Show quoted text
> > Tracking down what warned when and why is > difficult when they're all smashed together at the end.
My main trouble was turning on Smart::Comments in modules for development to see traces for a failing .t file. It's vital those traces come out in sequence with the test output. They can be big too, so don't really want to sit on them all in memory. I found myself disabling Test::NoWarnings for that because it got in the way, and then having to remember to re-enable it -- because I do want an error for Smart::Comments or other warns leftover in the modules -- and so having to dec and inc the test count etc ... Show quoted text
> The version of Test::NoWarnings I wrote as a test for Test::Builder2 > lets the warnings pass through and I find it far more pleasant to work with.
I use the blob below, initiated by calling nowarnings(). It grabs info to show at the end but lets the warning otherwise go out unmolested. I put it at the very start of a test script so no need to chain to a previously installed $SIG{__WARN__}. I ended up agreeing with the stack trace of Test::NoWarnings as a way of diagnosing cpantesters reports, and keeping that trace until the end, but when there's a lot of warnings I don't really want a trace for all of them. I've found 3 enough to start on. I preferred a non-zero exit to a test count too, so as to keep out of the hair of the main .t code. With a little care it could probably be made agnostic about which if any Test, Test::Simple, Test::More etc was in use, but I've been happy with Test::More::diag(). { my $warning_count; my $stacktraces; my $stacktraces_count = 0; sub nowarnings_handler { $warning_count++; if ($stacktraces_count < 3 && eval { require Devel::StackTrace }) { $stacktraces_count++; $stacktraces .= "\n" . Devel::StackTrace->new->as_string() . "\n"; } warn @_; } sub nowarnings { $SIG{'__WARN__'} = \&nowarnings_handler; } END { if ($warning_count) { require Test::More; Test::More::diag("Saw $warning_count warning(s):"); Test::More::diag($stacktraces); Test::More::diag("Exit code 1 for warnings"); $? = 1; } } }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.