line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Event::V2; |
2
|
246
|
|
|
246
|
|
1769
|
use strict; |
|
246
|
|
|
|
|
593
|
|
|
246
|
|
|
|
|
7302
|
|
3
|
246
|
|
|
246
|
|
1375
|
use warnings; |
|
246
|
|
|
|
|
509
|
|
|
246
|
|
|
|
|
10402
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.302181'; |
6
|
|
|
|
|
|
|
|
7
|
246
|
|
|
246
|
|
1516
|
use Scalar::Util qw/reftype/; |
|
246
|
|
|
|
|
574
|
|
|
246
|
|
|
|
|
12239
|
|
8
|
246
|
|
|
246
|
|
1549
|
use Carp qw/croak/; |
|
246
|
|
|
|
|
591
|
|
|
246
|
|
|
|
|
15611
|
|
9
|
|
|
|
|
|
|
|
10
|
246
|
|
|
246
|
|
1734
|
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } |
|
246
|
|
|
|
|
13785
|
|
11
|
|
|
|
|
|
|
|
12
|
246
|
|
|
|
|
21240
|
use Test2::Util::Facets2Legacy qw{ |
13
|
|
|
|
|
|
|
causes_fail diagnostics global increments_count no_display sets_plan |
14
|
|
|
|
|
|
|
subtest_id summary terminate |
15
|
246
|
|
|
246
|
|
107279
|
}; |
|
246
|
|
|
|
|
705
|
|
16
|
|
|
|
|
|
|
|
17
|
246
|
|
|
246
|
|
1837
|
use Test2::Util::HashBase qw/-about/; |
|
246
|
|
|
|
|
520
|
|
|
246
|
|
|
|
|
1534
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub non_facet_keys { |
20
|
|
|
|
|
|
|
return ( |
21
|
246
|
|
|
246
|
0
|
1389
|
+UUID, |
22
|
|
|
|
|
|
|
Test2::Util::ExternalMeta::META_KEY(), |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub init { |
27
|
227
|
|
|
227
|
0
|
661
|
my $self = shift; |
28
|
|
|
|
|
|
|
|
29
|
227
|
|
|
|
|
572
|
my $uuid; |
30
|
227
|
100
|
66
|
|
|
2654
|
if ($uuid = $self->{+UUID}) { |
|
|
100
|
|
|
|
|
|
31
|
|
|
|
|
|
|
croak "uuid '$uuid' passed to constructor, but uuid '$self->{+ABOUT}->{uuid}' is already set in the 'about' facet" |
32
|
4
|
100
|
100
|
|
|
274
|
if $self->{+ABOUT}->{uuid} && $self->{+ABOUT}->{uuid} ne $uuid; |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
7
|
$self->{+ABOUT}->{uuid} = $uuid; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif ($self->{+ABOUT} && $self->{+ABOUT}->{uuid}) { |
37
|
1
|
|
|
|
|
4
|
$uuid = $self->{+ABOUT}->{uuid}; |
38
|
1
|
|
|
|
|
9
|
$self->SUPER::set_uuid($uuid); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Clone the trace, make sure it is blessed |
42
|
226
|
100
|
|
|
|
1251
|
if (my $trace = $self->{+TRACE}) { |
43
|
220
|
|
|
|
|
2337
|
$self->{+TRACE} = Test2::EventFacet::Trace->new(%$trace); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub set_uuid { |
48
|
2
|
|
|
2
|
1
|
13
|
my $self = shift; |
49
|
2
|
|
|
|
|
6
|
my ($uuid) = @_; |
50
|
2
|
|
|
|
|
7
|
$self->{+ABOUT}->{uuid} = $uuid; |
51
|
2
|
|
|
|
|
11
|
$self->SUPER::set_uuid($uuid); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub facet_data { |
55
|
245
|
|
|
245
|
1
|
682
|
my $self = shift; |
56
|
245
|
|
|
|
|
562
|
my $f = { %{$self} }; |
|
245
|
|
|
|
|
1307
|
|
57
|
|
|
|
|
|
|
|
58
|
245
|
|
|
|
|
1297
|
delete $f->{$_} for $self->non_facet_keys; |
59
|
|
|
|
|
|
|
|
60
|
245
|
|
|
|
|
858
|
my %out; |
61
|
245
|
|
|
|
|
1383
|
for my $k (keys %$f) { |
62
|
969
|
100
|
|
|
|
3254
|
next if substr($k, 0, 1) eq '_'; |
63
|
|
|
|
|
|
|
|
64
|
737
|
50
|
|
|
|
2139
|
my $data = $f->{$k} or next; # Key is there, but no facet |
65
|
737
|
|
50
|
|
|
3124
|
my $is_list = 'ARRAY' eq (reftype($data) || ''); |
66
|
737
|
100
|
|
|
|
3865
|
$out{$k} = $is_list ? [ map { {%{$_}} } @$data ] : {%$data}; |
|
282
|
|
|
|
|
574
|
|
|
282
|
|
|
|
|
2839
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
245
|
100
|
|
|
|
2153
|
if (my $meta = $self->meta_facet_data) { |
70
|
1
|
50
|
|
|
|
3
|
$out{meta} = {%$meta, %{$out{meta} || {}}}; |
|
1
|
|
|
|
|
15
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
245
|
|
|
|
|
1722
|
return \%out; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding UTF-8 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Test2::Event::V2 - Second generation event. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is the event type that should be used instead of L<Test2::Event> or its |
91
|
|
|
|
|
|
|
legacy subclasses. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SYNOPSIS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 USING A CONTEXT |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
use Test2::API qw/context/; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub my_tool { |
100
|
|
|
|
|
|
|
my $ctx = context(); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $event = $ctx->send_ev2(info => [{tag => 'NOTE', details => "This is a note"}]); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$ctx->release; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return $event; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 USING THE CONSTRUCTOR |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
use Test2::Event::V2; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $e = Test2::Event::V2->new( |
114
|
|
|
|
|
|
|
trace => {frame => [$PKG, $FILE, $LINE, $SUBNAME]}, |
115
|
|
|
|
|
|
|
info => [{tag => 'NOTE', details => "This is a note"}], |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 METHODS |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This class inherits from L<Test2::Event>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over 4 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item $fd = $e->facet_data() |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This will return a hashref of facet data. Each facet hash will be a shallow |
127
|
|
|
|
|
|
|
copy of the original. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item $about = $e->about() |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This will return the 'about' facet hashref. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
B<NOTE:> This will return the internal hashref, not a copy. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item $trace = $e->trace() |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This will return the 'trace' facet, normally blessed (but this is not enforced |
138
|
|
|
|
|
|
|
when the trace is set using C<set_trace()>. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
B<NOTE:> This will return the internal trace, not a copy. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=back |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 MUTATION |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=over 4 |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item $e->add_amnesty({...}) |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Inherited from L<Test2::Event>. This can be used to add 'amnesty' facets to an |
151
|
|
|
|
|
|
|
existing event. Each new item is added to the B<END> of the list. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
B<NOTE:> Items B<ARE> blessed when added. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item $e->add_hub({...}) |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Inherited from L<Test2::Event>. This is used by hubs to stamp events as they |
158
|
|
|
|
|
|
|
pass through. New items are added to the B<START> of the list. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
B<NOTE:> Items B<ARE NOT> blessed when added. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item $e->set_uuid($UUID) |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Inherited from L<Test2::Event>, overridden to also vivify/mutate the 'about' |
165
|
|
|
|
|
|
|
facet. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item $e->set_trace($trace) |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Inherited from L<Test2::Event> which allows you to change the trace. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
B<Note:> This method does not bless/clone the trace for you. Many things will |
172
|
|
|
|
|
|
|
expect the trace to be blessed, so you should probably do that. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=back |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 LEGACY SUPPORT METHODS |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
These are all imported from L<Test2::Util::Facets2Legacy>, see that module or |
179
|
|
|
|
|
|
|
L<Test2::Event> for documentation on what they do. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=over 4 |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item causes_fail |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item diagnostics |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item global |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item increments_count |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item no_display |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item sets_plan |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item subtest_id |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item summary |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item terminate |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=back |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 THIRD PARTY META-DATA |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This object consumes L<Test2::Util::ExternalMeta> which provides a consistent |
206
|
|
|
|
|
|
|
way for you to attach meta-data to instances of this class. This is useful for |
207
|
|
|
|
|
|
|
tools, plugins, and other extensions. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 SOURCE |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
The source code repository for Test2 can be found at |
212
|
|
|
|
|
|
|
F<http://github.com/Test-More/test-more/>. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 MAINTAINERS |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=over 4 |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item Chad Granum E<lt>exodist@cpan.orgE<gt> |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=back |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 AUTHORS |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=over 4 |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item Chad Granum E<lt>exodist@cpan.orgE<gt> |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=back |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head1 COPYRIGHT |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
Copyright 2020 Chad Granum E<lt>exodist@cpan.orgE<gt>. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
235
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
See F<http://dev.perl.org/licenses/> |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=cut |