Skip Menu |

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

Report information
The Basics
Id: 43406
Status: rejected
Priority: 0/
Queue: Test-Harness

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

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



Subject: prove fails to see some warnings
Hi, The attached example distro shows that 'prove' misses warnings that 'make test' (correctly) sees. First run: prove -lv t/*.t t/basic.... 1..2 ok 1 - called warnfail successfully ok 2 - no warnings ok All tests successful. then after 'perl Makefile.PL': make test TEST_VERBOSE=1 t/basic.... 1..2 ok 1 - called warnfail successfully not ok 2 - no warnings # Failed test 'no warnings' # at /Library/Perl/5.8.8/Test/NoWarnings.pm line 45. # There were 1 warning(s) # Previous test 0 '' # Use of uninitialized value in numeric gt (>) at blib/lib/ Warnfail.pm line 6. # at blib/lib/Warnfail.pm line 6 # Warnfail::warnfail() called at t/basic.t line 11 # # Looks like you failed 1 test of 2. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/2 subtests Can you please look into this. TIA + Good luck, -- Abe.
Subject: Warnfail-0.01.tar.gz
Download Warnfail-0.01.tar.gz
application/x-gzip 857b

Message body not shown because it is not plain text.

On Wed Feb 18 14:33:08 2009, ABELTJE wrote: Show quoted text
> Hi, > > The attached example distro shows that 'prove' misses warnings that > 'make test' (correctly) sees. > > First run: prove -lv t/*.t > t/basic.... > 1..2 > ok 1 - called warnfail successfully > ok 2 - no warnings > ok > All tests successful. > > then after 'perl Makefile.PL': make test TEST_VERBOSE=1 > t/basic.... > 1..2 > ok 1 - called warnfail successfully > not ok 2 - no warnings > > # Failed test 'no warnings' > # at /Library/Perl/5.8.8/Test/NoWarnings.pm line 45. > # There were 1 warning(s) > # Previous test 0 '' > # Use of uninitialized value in numeric gt (>) at blib/lib/ > Warnfail.pm line 6. > # at blib/lib/Warnfail.pm line 6 > # Warnfail::warnfail() called at t/basic.t line 11 > # > # Looks like you failed 1 test of 2. > Dubious, test returned 1 (wstat 256, 0x100) > Failed 1/2 subtests > > > Can you please look into this.
This is because lib/Warnfail.pm in your example doesn't use warnings. By default Test::Harness adds the -w switch to the command line. Doing so enables warnings globally. It does this for compatibility with previous versions of Test::Harness. By default TAP::Harness (and therefore prove) do not add the -w switch - so warnings are completely controlled by the code being tested. If you do prove -wlv t/*.t you'll get warnings globally enabled and the test fails as expected. I'm not sure that we can change this. It seems to me correct that the code under test should control warnings for itself - but Test::Harness has to set -w for compatibility.