line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::Tester; |
2
|
1
|
|
|
1
|
|
472
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp qw/croak/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
8
|
1
|
|
|
1
|
|
5
|
use Test2::Util::Ref qw/rtype/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
203
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
50
|
|
1
|
|
4
|
if (eval { require Module::Pluggable; 1 }) { |
|
1
|
|
|
|
|
455
|
|
|
1
|
|
|
|
|
11226
|
|
12
|
1
|
|
|
|
|
7
|
Module::Pluggable->import(search_path => ['Test2::EventFacet'], require => 1); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
else { |
15
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::About; |
16
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Amnesty; |
17
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Assert; |
18
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Control; |
19
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Error; |
20
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Hub; |
21
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Info; |
22
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Info::Table; |
23
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Meta; |
24
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Parent; |
25
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Plan; |
26
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Render; |
27
|
0
|
|
|
|
|
0
|
require Test2::EventFacet::Trace; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
*plugins = sub { |
30
|
|
|
|
|
|
|
return ( |
31
|
0
|
|
|
|
|
0
|
'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
|
0
|
|
|
|
|
0
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
1
|
|
98
|
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
|
337
|
my $events = shift; |
74
|
|
|
|
|
|
|
|
75
|
3
|
100
|
|
|
|
13
|
my @match = map { rtype($_) eq 'REGEXP' ? $_ : qr/^\Q$_\E::/} @_; |
|
3
|
|
|
|
|
11
|
|
76
|
|
|
|
|
|
|
|
77
|
3
|
|
|
|
|
6
|
my @out; |
78
|
3
|
|
|
|
|
7
|
for my $e (@$events) { |
79
|
15
|
50
|
|
|
|
39
|
my $trace = $e->facet_data->{trace} or next; |
80
|
15
|
100
|
|
|
|
688
|
next unless grep { $trace->{frame}->[3] =~ $_ } @match; |
|
15
|
|
|
|
|
96
|
|
81
|
8
|
|
|
|
|
26
|
push @out => $e; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
15
|
return \@out; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub event_groups { |
88
|
1
|
|
|
1
|
0
|
26695
|
my $events = shift; |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
4
|
my $out = {}; |
91
|
1
|
|
|
|
|
7
|
for my $e (@$events) { |
92
|
8
|
|
|
|
|
29
|
my $trace = $e->facet_data->{trace}; |
93
|
8
|
100
|
33
|
|
|
461
|
my $tool = ($trace && $trace->{frame} && $trace->{frame}->[3]) ? $trace->{frame}->[3] : undef; |
94
|
|
|
|
|
|
|
|
95
|
8
|
100
|
|
|
|
20
|
unless ($tool) { |
96
|
1
|
|
|
|
|
3
|
push @{$out->{__NA__}} => $e; |
|
1
|
|
|
|
|
4
|
|
97
|
1
|
|
|
|
|
3
|
next; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
7
|
|
|
|
|
44
|
my ($pkg, $sub) = ($tool =~ m/^(.*)(?:::|')([^:']+)$/); |
101
|
|
|
|
|
|
|
|
102
|
7
|
|
|
|
|
14
|
push @{$out->{$pkg}->{$sub}} => $e; |
|
7
|
|
|
|
|
30
|
|
103
|
7
|
|
|
|
|
10
|
push @{$out->{$pkg}->{__ALL__}} => $e; |
|
7
|
|
|
|
|
25
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
4
|
return $out; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub facets { |
110
|
6
|
|
|
6
|
1
|
908
|
my ($type, $events) = @_; |
111
|
|
|
|
|
|
|
|
112
|
6
|
|
|
|
|
9
|
my ($key, $is_list); |
113
|
6
|
|
|
|
|
16
|
my $class = $TYPES{$type}; |
114
|
6
|
100
|
|
|
|
15
|
if ($class) { |
115
|
4
|
|
33
|
|
|
24
|
$key = $class->facet_key || lc($type); |
116
|
4
|
|
|
|
|
42
|
$is_list = $class->is_list; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
else { |
119
|
2
|
|
|
|
|
3
|
$key = lc($type); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
6
|
|
|
|
|
19
|
my @out; |
123
|
6
|
|
|
|
|
12
|
for my $e (@$events) { |
124
|
42
|
|
|
|
|
190
|
my $fd = $e->facet_data; |
125
|
42
|
100
|
|
|
|
1302
|
my $f = $fd->{$key} or next; |
126
|
|
|
|
|
|
|
|
127
|
9
|
100
|
|
|
|
23
|
my $list = defined($is_list) ? $is_list : rtype($f) eq 'ARRAY'; |
128
|
|
|
|
|
|
|
|
129
|
9
|
100
|
|
|
|
18
|
if ($list) { |
130
|
6
|
100
|
|
|
|
18
|
push @out => map { $class ? $class->new($_) : $_ } @$f; |
|
9
|
|
|
|
|
85
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
else { |
133
|
3
|
100
|
|
|
|
12
|
push @out => $class ? $class->new($f) : $f; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
6
|
|
|
|
|
46
|
return \@out; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
__END__ |