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