• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Test/H25-Sep-2013-21757

t/H25-Sep-2013-272205

xt/H25-Sep-2013-10767

CONTRIBUTINGH A D25-Sep-20132.2 KiB7145

ChangesH A D25-Sep-20131.4 KiB6735

LICENSEH A D25-Sep-201311.2 KiB208172

MANIFESTH A D25-Sep-2013529 3231

META.jsonH A D25-Sep-20132.2 KiB9088

META.ymlH A D25-Sep-20131.1 KiB5251

Makefile.PLH A D25-Sep-20131.7 KiB8368

READMEH A D25-Sep-20133.4 KiB11279

cpanfileH A D25-Sep-2013849 3329

dist.iniH A D25-Sep-2013178 97

perlcritic.rcH A D25-Sep-2013570 2418

tidyall.iniH A D25-Sep-2013160 65

README

1NAME
2    Test::FailWarnings - Add test failures if warnings are caught
3
4VERSION
5    version 0.008
6
7SYNOPSIS
8    Test file:
9
10        use strict;
11        use warnings;
12        use Test::More;
13        use Test::FailWarnings;
14
15        ok( 1, "first test" );
16        ok( 1 + "lkadjaks", "add non-numeric" );
17
18        done_testing;
19
20    Output:
21
22        ok 1 - first test
23        not ok 2 - Test::FailWarnings should catch no warnings
24        #   Failed test 'Test::FailWarnings should catch no warnings'
25        #   at t/bin/main-warn.pl line 7.
26        # Warning was 'Argument "lkadjaks" isn't numeric in addition (+) at t/bin/main-warn.pl line 7.'
27        ok 3 - add non-numeric
28        1..3
29        # Looks like you failed 1 test of 3.
30
31DESCRIPTION
32    This module hooks $SIG{__WARN__} and converts warnings to Test::More
33    "fail()" calls. It is designed to be used with "done_testing", when you
34    don't need to know the test count in advance.
35
36    Just as with Test::NoWarnings, this does not catch warnings if other
37    things localize $SIG{__WARN__}, as this is designed to catch *unhandled*
38    warnings.
39
40USAGE
41  Overriding $SIG{__WARN__}
42    On "import", $SIG{__WARN__} is replaced with
43    "Test::FailWarnings::handler".
44
45        use Test::FailWarnings;  # global
46
47    If you don't want global replacement, require the module instead and
48    localize in whatever scope you want.
49
50        require Test::FailWarnings;
51
52        {
53            local $SIG{__WARN__} = \&Test::FailWarnings::handler;
54            # ... warnings will issue fail() here
55        }
56
57    When the handler reports on the source of the warning, it will look past
58    any calling packages starting with "Carp" or "warnings" to try to detect
59    the real origin of the warning.
60
61  Allowing warnings from dependencies
62    If you want to ignore failures from outside your own code, you can set
63    $Test::FailWarnings::ALLOW_DEPS to a true value. You can do that on the
64    "use" line with "-allow_deps".
65
66        use Test::FailWarnings -allow_deps => 1;
67
68    When true, warnings will only be thrown if they appear to originate from
69    a filename matching "qr/^(?:t|xt|lib|blib)/"
70
71  Allowing warnings from specific modules
72    If you want to white-list specific modules only, you can add their
73    package names to @Test::NoWarnings::ALLOW_FROM. You can do that on the
74    "use" line with "-allow_from".
75
76        use Test::FailWarnings -allow_from => [ qw/Annoying::Module/ ];
77
78SEE ALSO
79    *   Test::NoWarnings -- catches warnings and reports in an "END" block.
80        Not (yet) friendly with "done_testing".
81
82    *   Test::Warnings -- a replacement for Test::NoWarnings that works with
83        done_testing
84
85    *   Test::Warn -- test for warnings without triggering failures from
86        this modules
87
88SUPPORT
89  Bugs / Feature Requests
90    Please report any bugs or feature requests through the issue tracker at
91    <https://github.com/dagolden/Test-FailWarnings/issues>. You will be
92    notified automatically of any progress on your issue.
93
94  Source Code
95    This is open source software. The code repository is available for
96    public review and contribution under the terms of the license.
97
98    <https://github.com/dagolden/Test-FailWarnings>
99
100      git clone https://github.com/dagolden/Test-FailWarnings.git
101
102AUTHOR
103    David Golden <dagolden@cpan.org>
104
105COPYRIGHT AND LICENSE
106    This software is Copyright (c) 2013 by David Golden.
107
108    This is free software, licensed under:
109
110      The Apache License, Version 2.0, January 2004
111
112