line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::NoWarnings; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
731789
|
use strict; |
|
3
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
90
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
148
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# This is the version that added test2_is_testing_done. |
9
|
3
|
|
|
3
|
|
1348
|
use Test2 1.302167; |
|
3
|
|
|
|
|
349
|
|
|
3
|
|
|
|
|
92
|
|
10
|
3
|
|
|
3
|
|
20
|
use Test2::API qw( context_do test2_is_testing_done ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
156
|
|
11
|
3
|
|
|
3
|
|
1201
|
use Test2::Event::Warning; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1010
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $echo = 0; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
3
|
|
|
3
|
|
42
|
shift; |
17
|
3
|
|
|
|
|
9
|
my %args = @_; |
18
|
3
|
50
|
|
|
|
15
|
$echo = $args{echo} if exists $args{echo}; |
19
|
3
|
|
|
|
|
2491
|
return; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $_orig_warn_handler = $SIG{__WARN__}; |
23
|
|
|
|
|
|
|
## no critic (Variables::RequireLocalizedPunctuationVars) |
24
|
|
|
|
|
|
|
$SIG{__WARN__} = sub { |
25
|
|
|
|
|
|
|
unless ( test2_is_testing_done() ) { |
26
|
|
|
|
|
|
|
my $w = $_[0]; |
27
|
|
|
|
|
|
|
$w =~ s/\n+$//g; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
context_do { |
30
|
|
|
|
|
|
|
my $ctx = shift; |
31
|
|
|
|
|
|
|
$ctx->send_event( |
32
|
|
|
|
|
|
|
'Warning', |
33
|
|
|
|
|
|
|
warning => "Unexpected warning: $w", |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
$_[0]; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return unless $echo; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return if $_orig_warn_handler && $_orig_warn_handler eq 'IGNORE'; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# The rest was copied from Test::Warnings |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# TODO: this doesn't handle blessed coderefs... does anyone care? |
46
|
|
|
|
|
|
|
goto &$_orig_warn_handler |
47
|
|
|
|
|
|
|
if $_orig_warn_handler |
48
|
|
|
|
|
|
|
and ( |
49
|
|
|
|
|
|
|
( ref $_orig_warn_handler eq 'CODE' ) |
50
|
|
|
|
|
|
|
or ( $_orig_warn_handler ne 'DEFAULT' |
51
|
|
|
|
|
|
|
and $_orig_warn_handler ne 'IGNORE' |
52
|
|
|
|
|
|
|
and defined &$_orig_warn_handler ) |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
if ( $_[0] =~ /\n$/ ) { |
56
|
|
|
|
|
|
|
warn $_[0]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
|
|
|
|
|
|
require Carp; |
60
|
|
|
|
|
|
|
Carp::carp( $_[0] ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# ABSTRACT: Fail if tests warn |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |