| 1 | package Test::Group::NoWarnings; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Test::Group::NoWarnings - turn warnings into test failures | ||
| 8 | |||
| 9 | =head1 SYNOPSIS | ||
| 10 | |||
| 11 | use Test::Group; | ||
| 12 | use Test::Group::NoWarnings; | ||
| 13 | |||
| 14 | next_test_nowarnings(); | ||
| 15 | |||
| 16 | test mytest => sub { | ||
| 17 | # ... | ||
| 18 | }; | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | This module is an extension for L<Test::Group>. It allows you to | ||
| 23 | trap warnings generated during a test group and convert them to | ||
| 24 | test failures. | ||
| 25 | |||
| 26 | If you are not already familiar with L<Test::Group> now would be | ||
| 27 | a good time to go take a look. | ||
| 28 | |||
| 29 | See also L<Test::NoWarnings>, which does something similar for the | ||
| 30 | test script as a whole rather than for a particular group. | ||
| 31 | |||
| 32 | =head1 EXPORTS | ||
| 33 | |||
| 34 | The following function is exported by default. | ||
| 35 | |||
| 36 | =head2 next_test_nowarnings () | ||
| 37 | |||
| 38 | Causes warnings to be trapped for the next test group. | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | 1 | ▶ | use Exporter; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 43 | 1 | ▶ | use vars qw(@ISA @EXPORT $VERSION); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 44 | 1 | @ISA = qw(Exporter); | |
| 45 | 1 | @EXPORT = qw(next_test_nowarnings); | |
| 46 | 1 | $VERSION = '0.01'; | |
| 47 | |||
| 48 | 1 | ▶ | use Test::Builder; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 49 | 1 | ▶ | use Test::Group (); # keep this namespace clean |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 50 | |||
| 51 | 8 | ▶ | sub next_test_nowarnings () { |
|
Subroutine
next_test_nowarnings: called CC=1 SCAR=0.0
Pod
documented
| |||
| 52 | 12 | ▶ | Test::Group::next_test_plugin { |
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||
| 53 | 12 | my $next = shift; | |
| 54 | |||
| 55 | 12 | my @warn; | |
| 56 | { | ||
| 57 | 12 | ▶ | local $SIG{__WARN__} = sub { push @warn, shift }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 58 | 12 | $next->(); | |
| 59 | } | ||
| 60 | |||
| 61 | 12 | my $T = Test::Builder->new; | |
| 62 | 12 | $T->ok(!@warn, "no warnings"); | |
| 63 | 12 | foreach my $warn (@warn) { | |
| 64 | 12 | chomp $warn; | |
| 65 | 12 | $T->diag("WARNING: [$warn]"); | |
| 66 | } | ||
| 67 | 8 | }; | |
| 68 | } | ||
| 69 | |||
| 70 | =head1 SEE ALSO | ||
| 71 | |||
| 72 | L<Test::Group>, L<Test::NoWarnings> | ||
| 73 | |||
| 74 | =head1 AUTHORS | ||
| 75 | |||
| 76 | Nick Cleaton <ncleaton@cpan.org> | ||
| 77 | |||
| 78 | Dominique Quatravaux <domq@cpan.org> | ||
| 79 | |||
| 80 | =head1 LICENSE | ||
| 81 | |||
| 82 | Copyright (c) 2009 by Nick Cleaton and Dominique Quatravaux | ||
| 83 | |||
| 84 | This library is free software; you can redistribute it and/or modify | ||
| 85 | it under the same terms as Perl itself, either Perl version 5.8.1 or, | ||
| 86 | at your option, any later version of Perl 5 you may have available. | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | 1 | 1; | |