Skip Menu |

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

Report information
The Basics
Id: 77151
Status: rejected
Priority: 0/
Queue: Test-NoWarnings

People
Owner: Nobody in particular
Requestors: ether [...] cpan.org
Cc:
AdminCc:

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



Subject: Ignoring messages on the stderr stream without CR
consider this test: use strict; use warnings; use Test::More; use Test::NoWarnings; print STDERR "stderr"; done_testing; It prints: perl warningstest.t stderr1..0 ok 1 - no warnings # Looks like you planned 0 tests but ran 1. Without a LF, the message to STDERR does not cause a test failure! And yet, if one adds a "\n" to the print, the test *does* fail. At least, this is inconsistent; or worse, it is letting warnings leak through that should be caught.
On Fri May 11 21:05:28 2012, ETHER wrote: Show quoted text
> consider this test: > > use strict; > use warnings; > > use Test::More; > use Test::NoWarnings; > > print STDERR "stderr"; > > done_testing; > > It prints: > > perl warningstest.t > stderr1..0 > ok 1 - no warnings > # Looks like you planned 0 tests but ran 1. > > Without a LF, the message to STDERR does not cause a test failure!
And Show quoted text
> yet, if one adds a "\n" to the print, the test *does* fail. At least, > this is inconsistent; or worse, it is letting warnings leak through
that Show quoted text
> should be caught. >
There are 3 things going on here. 1 Printing to STDERR is quite different to a warning and you should not expect Test::NoWarnings to catch this. A warning is a call to warn() either in the script or from the perl compiler/run time. 2 The test harness expects the test results to be output to STDERR and expects them to be on their own line. Printing to STDERR without LFs during a test is very likely to interfere with that and the test harness may be unable to correctly parse the test results. 3 The test fails with or without the \n for me. It fails even without the print. Its exit value is 255. I guess this is because Test::NoWarnings executes a test in an END block, which comes after done_testing(). This is an error, you cannot use done_testing with Test::NoWarnings like this. If you really must use done_testing, you'll have to make sure it runs in an END block after Test::NoWarnings's END block but be careful. You'll need to do something messy like my $done_testing = 0; test test ... test $done_testing = 1; END { done_testing() if $done_testing; } but you might have to position the END block carefully to have it run after Test::NoWarnings END block.