line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::Tester; |
2
|
1
|
|
|
1
|
|
444
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp qw/croak/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
8
|
1
|
|
|
1
|
|
7
|
use Test2::Util::Ref qw/rtype/; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
226
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
50
|
|
1
|
|
4
|
if (eval { require Module::Pluggable; 1 }) { |
|
1
|
|
|
|
|
164
|
|
|
0
|
|
|
|
|
0
|
|
12
|
0
|
|
|
|
|
0
|
Module::Pluggable->import(search_path => ['Test2::EventFacet'], require => 1); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
else { |
15
|
1
|
|
|
|
|
5
|
require Test2::EventFacet::About; |
16
|
1
|
|
|
|
|
3
|
require Test2::EventFacet::Amnesty; |
17
|
1
|
|
|
|
|
11
|
require Test2::EventFacet::Assert; |
18
|
1
|
|
|
|
|
4
|
require Test2::EventFacet::Control; |
19
|
1
|
|
|
|
|
4
|
require Test2::EventFacet::Error; |
20
|
1
|
|
|
|
|
4
|
require Test2::EventFacet::Hub; |
21
|
1
|
|
|
|
|
3
|
require Test2::EventFacet::Info; |
22
|
1
|
|
|
|
|
5
|
require Test2::EventFacet::Info::Table; |
23
|
1
|
|
|
|
|
3
|
require Test2::EventFacet::Meta; |
24
|
1
|
|
|
|
|
4
|
require Test2::EventFacet::Parent; |
25
|
1
|
|
|
|
|
3
|
require Test2::EventFacet::Plan; |
26
|
1
|
|
|
|
|
481
|
require Test2::EventFacet::Render; |
27
|
1
|
|
|
|
|
449
|
require Test2::EventFacet::Trace; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
*plugins = sub { |
30
|
|
|
|
|
|
|
return ( |
31
|
1
|
|
|
1
|
|
5
|
'Test2::EventFacet::About', |
32
|
|
|
|
|
|
|
'Test2::EventFacet::Amnesty', |
33
|
|
|
|
|
|
|
'Test2::EventFacet::Assert', |
34
|
|
|
|
|
|
|
'Test2::EventFacet::Control', |
35
|
|
|
|
|
|
|
'Test2::EventFacet::Error', |
36
|
|
|
|
|
|
|
'Test2::EventFacet::Hub', |
37
|
|
|
|
|
|
|
'Test2::EventFacet::Info', |
38
|
|
|
|
|
|
|
'Test2::EventFacet::Info::Table', |
39
|
|
|
|
|
|
|
'Test2::EventFacet::Meta', |
40
|
|
|
|
|
|
|
'Test2::EventFacet::Parent', |
41
|
|
|
|
|
|
|
'Test2::EventFacet::Plan', |
42
|
|
|
|
|
|
|
'Test2::EventFacet::Render', |
43
|
|
|
|
|
|
|
'Test2::EventFacet::Trace', |
44
|
|
|
|
|
|
|
); |
45
|
1
|
|
|
|
|
30
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
1
|
|
5
|
use Test2::Util::Importer 'Test2::Util::Importer' => 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ |
52
|
|
|
|
|
|
|
facets |
53
|
|
|
|
|
|
|
filter_events |
54
|
|
|
|
|
|
|
event_groups |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my %TYPES; |
58
|
|
|
|
|
|
|
for my $class (__PACKAGE__->plugins) { |
59
|
|
|
|
|
|
|
my $type = $class; |
60
|
|
|
|
|
|
|
$type =~ s/^Test2::EventFacet:://g; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
next unless $class->isa('Test2::EventFacet'); |
63
|
|
|
|
|
|
|
my $key; |
64
|
|
|
|
|
|
|
$key = $class->facet_key if $class->can('facet_key'); |
65
|
|
|
|
|
|
|
$key = lc($type) unless defined $key; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$TYPES{$type} = $class; |
68
|
|
|
|
|
|
|
$TYPES{lc($type)} = $class; |
69
|
|
|
|
|
|
|
$TYPES{$key} = $class; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub filter_events { |
73
|
3
|
|
|
3
|
0
|
199
|
my $events = shift; |
74
|
|
|
|
|
|
|
|
75
|
3
|
100
|
|
|
|
8
|
my @match = map { rtype($_) eq 'REGEXP' ? $_ : qr/^\Q$_\E::/} @_; |
|
3
|
|
|
|
|
13
|
|
76
|
|
|
|
|
|
|
|
77
|
3
|
|
|
|
|
8
|
my @out; |
78
|
3
|
|
|
|
|
7
|
for my $e (@$events) { |
79
|
15
|
50
|
|
|
|
42
|
my $trace = $e->facet_data->{trace} or next; |
80
|
15
|
100
|
|
|
|
678
|
next unless grep { $trace->{frame}->[3] =~ $_ } @match; |
|
15
|
|
|
|
|
90
|
|
81
|
8
|
|
|
|
|
27
|
push @out => $e; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
14
|
return \@out; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub event_groups { |
88
|
1
|
|
|
1
|
0
|
18500
|
my $events = shift; |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
4
|
my $out = {}; |
91
|
1
|
|
|
|
|
7
|
for my $e (@$events) { |
92
|
8
|
|
|
|
|
45
|
my $trace = $e->facet_data->{trace}; |
93
|
8
|
100
|
33
|
|
|
429
|
my $tool = ($trace && $trace->{frame} && $trace->{frame}->[3]) ? $trace->{frame}->[3] : undef; |
94
|
|
|
|
|
|
|
|
95
|
8
|
100
|
|
|
|
18
|
unless ($tool) { |
96
|
1
|
|
|
|
|
4
|
push @{$out->{__NA__}} => $e; |
|
1
|
|
|
|
|
4
|
|
97
|
1
|
|
|
|
|
4
|
next; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
7
|
|
|
|
|
42
|
my ($pkg, $sub) = ($tool =~ m/^(.*)(?:::|')([^:']+)$/); |
101
|
|
|
|
|
|
|
|
102
|
7
|
|
|
|
|
16
|
push @{$out->{$pkg}->{$sub}} => $e; |
|
7
|
|
|
|
|
21
|
|
103
|
7
|
|
|
|
|
11
|
push @{$out->{$pkg}->{__ALL__}} => $e; |
|
7
|
|
|
|
|
24
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
4
|
return $out; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub facets { |
110
|
6
|
|
|
6
|
1
|
801
|
my ($type, $events) = @_; |
111
|
|
|
|
|
|
|
|
112
|
6
|
|
|
|
|
10
|
my ($key, $is_list); |
113
|
6
|
|
|
|
|
36
|
my $class = $TYPES{$type}; |
114
|
6
|
100
|
|
|
|
12
|
if ($class) { |
115
|
4
|
|
33
|
|
|
30
|
$key = $class->facet_key || lc($type); |
116
|
4
|
|
|
|
|
48
|
$is_list = $class->is_list; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
else { |
119
|
2
|
|
|
|
|
7
|
$key = lc($type); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
6
|
|
|
|
|
16
|
my @out; |
123
|
6
|
|
|
|
|
12
|
for my $e (@$events) { |
124
|
42
|
|
|
|
|
203
|
my $fd = $e->facet_data; |
125
|
42
|
100
|
|
|
|
1267
|
my $f = $fd->{$key} or next; |
126
|
|
|
|
|
|
|
|
127
|
9
|
100
|
|
|
|
50
|
my $list = defined($is_list) ? $is_list : rtype($f) eq 'ARRAY'; |
128
|
|
|
|
|
|
|
|
129
|
9
|
100
|
|
|
|
20
|
if ($list) { |
130
|
6
|
100
|
|
|
|
12
|
push @out => map { $class ? $class->new($_) : $_ } @$f; |
|
9
|
|
|
|
|
82
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
else { |
133
|
3
|
100
|
|
|
|
13
|
push @out => $class ? $class->new($f) : $f; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
6
|
|
|
|
|
52
|
return \@out; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
__END__ |