.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test::FailWarnings 3pm" .TH Test::FailWarnings 3pm "2022-10-22" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::FailWarnings \- Add test failures if warnings are caught .SH "VERSION" .IX Header "VERSION" version 0.008 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Test file: .PP .Vb 4 \& use strict; \& use warnings; \& use Test::More; \& use Test::FailWarnings; \& \& ok( 1, "first test" ); \& ok( 1 + "lkadjaks", "add non\-numeric" ); \& \& done_testing; .Ve .PP Output: .PP .Vb 8 \& ok 1 \- first test \& not ok 2 \- Test::FailWarnings should catch no warnings \& # Failed test \*(AqTest::FailWarnings should catch no warnings\*(Aq \& # at t/bin/main\-warn.pl line 7. \& # Warning was \*(AqArgument "lkadjaks" isn\*(Aqt numeric in addition (+) at t/bin/main\-warn.pl line 7.\*(Aq \& ok 3 \- add non\-numeric \& 1..3 \& # Looks like you failed 1 test of 3. .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module hooks \f(CW$SIG{_\|_WARN_\|_}\fR and converts warnings to Test::More \&\f(CW\*(C`fail()\*(C'\fR calls. It is designed to be used with \f(CW\*(C`done_testing\*(C'\fR, when you don't need to know the test count in advance. .PP Just as with Test::NoWarnings, this does not catch warnings if other things localize \f(CW$SIG{_\|_WARN_\|_}\fR, as this is designed to catch \fIunhandled\fR warnings. .SH "USAGE" .IX Header "USAGE" .ie n .SS "Overriding $SIG{_\|_WARN_\|_}" .el .SS "Overriding \f(CW$SIG{_\|_WARN_\|_}\fP" .IX Subsection "Overriding $SIG{__WARN__}" On \f(CW\*(C`import\*(C'\fR, \f(CW$SIG{_\|_WARN_\|_}\fR is replaced with \&\f(CW\*(C`Test::FailWarnings::handler\*(C'\fR. .PP .Vb 1 \& use Test::FailWarnings; # global .Ve .PP If you don't want global replacement, require the module instead and localize in whatever scope you want. .PP .Vb 1 \& require Test::FailWarnings; \& \& { \& local $SIG{_\|_WARN_\|_} = \e&Test::FailWarnings::handler; \& # ... warnings will issue fail() here \& } .Ve .PP When the handler reports on the source of the warning, it will look past any calling packages starting with \f(CW\*(C`Carp\*(C'\fR or \f(CW\*(C`warnings\*(C'\fR to try to detect the real origin of the warning. .SS "Allowing warnings from dependencies" .IX Subsection "Allowing warnings from dependencies" If you want to ignore failures from outside your own code, you can set \&\f(CW$Test::FailWarnings::ALLOW_DEPS\fR to a true value. You can do that on the \f(CW\*(C`use\*(C'\fR line with \f(CW\*(C`\-allow_deps\*(C'\fR. .PP .Vb 1 \& use Test::FailWarnings \-allow_deps => 1; .Ve .PP When true, warnings will only be thrown if they appear to originate from a filename matching \f(CW\*(C`qr/^(?:t|xt|lib|blib)/\*(C'\fR .SS "Allowing warnings from specific modules" .IX Subsection "Allowing warnings from specific modules" If you want to white-list specific modules only, you can add their package names to \f(CW@Test::NoWarnings::ALLOW_FROM\fR. You can do that on the \f(CW\*(C`use\*(C'\fR line with \f(CW\*(C`\-allow_from\*(C'\fR. .PP .Vb 1 \& use Test::FailWarnings \-allow_from => [ qw/Annoying::Module/ ]; .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 4 Test::NoWarnings \*(-- catches warnings and reports in an \f(CW\*(C`END\*(C'\fR block. Not (yet) friendly with \f(CW\*(C`done_testing\*(C'\fR. .IP "\(bu" 4 Test::Warnings \*(-- a replacement for Test::NoWarnings that works with done_testing .IP "\(bu" 4 Test::Warn \*(-- test for warnings without triggering failures from this modules .SH "SUPPORT" .IX Header "SUPPORT" .SS "Bugs / Feature Requests" .IX Subsection "Bugs / Feature Requests" Please report any bugs or feature requests through the issue tracker at . You will be notified automatically of any progress on your issue. .SS "Source Code" .IX Subsection "Source Code" This is open source software. The code repository is available for public review and contribution under the terms of the license. .PP .PP .Vb 1 \& git clone https://github.com/dagolden/Test\-FailWarnings.git .Ve .SH "AUTHOR" .IX Header "AUTHOR" David Golden .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2013 by David Golden. .PP This is free software, licensed under: .PP .Vb 1 \& The Apache License, Version 2.0, January 2004 .Ve