When running an applications test suite I want to promote all Perl compile and run-time warnings (eg the \"Uninitialized variable\" warning) to fatal errors so that I and the ot
I think you're looking for Test::NoWarnings.
The reason use warnings FATAL => qw( all );
isn't working for you is because use warnings
is lexically scoped. So any warnings produced inside TestHelper.pm would be fatal, but warnings produced elsewhere will work as normal.
If you want to enable fatal warnings globally, I think a $SIG{__WARN__}
handler is probably the only way to do it. If you don't want it to blow up on the first warning, you could let your handler store them in an array, then check it in an END
block.
my @WARNINGS;
$SIG{__WARN__} = sub { push @WARNINGS, shift };
END {
if ( @WARNINGS ) {
print STDERR "There were warnings!\n";
print "$_\n" for @WARNINGS;
exit 1;
}
}