line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::API::InterceptResult; |
2
|
35
|
|
|
35
|
|
841
|
use strict; |
|
35
|
|
|
|
|
84
|
|
|
35
|
|
|
|
|
1228
|
|
3
|
35
|
|
|
35
|
|
194
|
use warnings; |
|
35
|
|
|
|
|
68
|
|
|
35
|
|
|
|
|
1801
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.302180'; |
6
|
|
|
|
|
|
|
|
7
|
35
|
|
|
35
|
|
207
|
use Scalar::Util qw/blessed/; |
|
35
|
|
|
|
|
98
|
|
|
35
|
|
|
|
|
2293
|
|
8
|
35
|
|
|
35
|
|
229
|
use Test2::Util qw/pkg_to_file/; |
|
35
|
|
|
|
|
87
|
|
|
35
|
|
|
|
|
1821
|
|
9
|
35
|
|
|
35
|
|
20197
|
use Storable qw/dclone/; |
|
35
|
|
|
|
|
109557
|
|
|
35
|
|
|
|
|
2956
|
|
10
|
35
|
|
|
35
|
|
308
|
use Carp qw/croak/; |
|
35
|
|
|
|
|
86
|
|
|
35
|
|
|
|
|
1823
|
|
11
|
|
|
|
|
|
|
|
12
|
35
|
|
|
35
|
|
17833
|
use Test2::API::InterceptResult::Squasher; |
|
35
|
|
|
|
|
107
|
|
|
35
|
|
|
|
|
952
|
|
13
|
35
|
|
|
35
|
|
18636
|
use Test2::API::InterceptResult::Event; |
|
35
|
|
|
|
|
102
|
|
|
35
|
|
|
|
|
1068
|
|
14
|
35
|
|
|
35
|
|
364
|
use Test2::API::InterceptResult::Hub; |
|
35
|
|
|
|
|
78
|
|
|
35
|
|
|
|
|
35533
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
7
|
50
|
|
7
|
1
|
37
|
croak "Called a method that creates a new instance in void context" unless defined wantarray; |
18
|
7
|
|
|
|
|
13
|
my $class = shift; |
19
|
7
|
|
|
|
|
35
|
bless([@_], $class); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new_from_ref { |
23
|
84
|
100
|
|
84
|
1
|
543
|
croak "Called a method that creates a new instance in void context" unless defined wantarray; |
24
|
83
|
|
|
|
|
640
|
bless($_[1], $_[0]); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
1
|
15
|
sub clone { blessed($_[0])->new(@{dclone($_[0])}) } |
|
1
|
|
|
|
|
111
|
|
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
1
|
6
|
sub event_list { @{$_[0]} } |
|
1
|
|
|
|
|
69
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _upgrade { |
32
|
122
|
|
|
122
|
|
208
|
my $self = shift; |
33
|
122
|
|
|
|
|
355
|
my ($event, %params) = @_; |
34
|
|
|
|
|
|
|
|
35
|
122
|
|
|
|
|
340
|
my $blessed = blessed($event); |
36
|
|
|
|
|
|
|
|
37
|
122
|
|
100
|
|
|
451
|
my $upgrade_class = $params{upgrade_class} ||= 'Test2::API::InterceptResult::Event'; |
38
|
|
|
|
|
|
|
|
39
|
122
|
100
|
100
|
|
|
806
|
return $event if $blessed && $event->isa($upgrade_class) && !$params{_upgrade_clone}; |
|
|
|
100
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
68
|
100
|
|
|
|
437
|
my $fd = dclone($blessed ? $event->facet_data : $event); |
42
|
|
|
|
|
|
|
|
43
|
68
|
|
66
|
|
|
665
|
my $class = $params{result_class} ||= blessed($self); |
44
|
|
|
|
|
|
|
|
45
|
68
|
100
|
|
|
|
218
|
if (my $parent = $fd->{parent}) { |
46
|
4
|
|
50
|
|
|
21
|
$parent->{children} = $class->new_from_ref($parent->{children} || [])->upgrade(%params); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
68
|
|
|
|
|
245
|
my $uc_file = pkg_to_file($upgrade_class); |
50
|
68
|
50
|
|
|
|
192
|
require($uc_file) unless $INC{$uc_file}; |
51
|
68
|
|
|
|
|
253
|
return $upgrade_class->new(facet_data => $fd, result_class => $class); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub hub { |
55
|
4
|
|
|
4
|
1
|
14
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
56
|
my $hub = Test2::API::InterceptResult::Hub->new(); |
58
|
4
|
|
|
|
|
22
|
$hub->process($_) for @$self; |
59
|
4
|
|
|
|
|
24
|
$hub->set_ended(1); |
60
|
|
|
|
|
|
|
|
61
|
4
|
|
|
|
|
12
|
return $hub; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub state { |
65
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
66
|
3
|
|
|
|
|
8
|
my %params = @_; |
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
10
|
my $hub = $self->hub; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $out = { |
71
|
3
|
|
|
|
|
9
|
map {($_ => scalar $hub->$_)} qw/count failed is_passing plan bailed_out skip_reason/ |
|
18
|
|
|
|
|
63
|
|
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$out->{bailed_out} = $self->_upgrade($out->{bailed_out}, %params)->bailout_reason || 1 |
75
|
3
|
50
|
0
|
|
|
279
|
if $out->{bailed_out}; |
76
|
|
|
|
|
|
|
|
77
|
3
|
|
|
|
|
21
|
$out->{follows_plan} = $hub->check_plan; |
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
14
|
return $out; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub upgrade { |
83
|
14
|
|
|
14
|
1
|
55
|
my $self = shift; |
84
|
14
|
|
|
|
|
37
|
my %params = @_; |
85
|
|
|
|
|
|
|
|
86
|
14
|
|
|
|
|
43
|
my @out = map { $self->_upgrade($_, %params, _upgrade_clone => 1) } @$self; |
|
30
|
|
|
|
|
152
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
return blessed($self)->new_from_ref(\@out) |
89
|
14
|
100
|
|
|
|
79
|
unless $params{in_place}; |
90
|
|
|
|
|
|
|
|
91
|
4
|
|
|
|
|
67
|
@$self = @out; |
92
|
4
|
|
|
|
|
15
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub squash_info { |
96
|
2
|
|
|
2
|
1
|
13
|
my $self = shift; |
97
|
2
|
|
|
|
|
6
|
my %params = @_; |
98
|
|
|
|
|
|
|
|
99
|
2
|
|
|
|
|
5
|
my @out; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
{ |
102
|
2
|
|
|
|
|
4
|
my $squasher = Test2::API::InterceptResult::Squasher->new(events => \@out); |
|
2
|
|
|
|
|
12
|
|
103
|
|
|
|
|
|
|
# Clone to make sure we do not indirectly modify an existing one if it |
104
|
|
|
|
|
|
|
# is already upgraded |
105
|
2
|
|
|
|
|
11
|
$squasher->process($self->_upgrade($_, %params)->clone) for @$self; |
106
|
2
|
|
|
|
|
7
|
$squasher->flush_down(); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
return blessed($self)->new_from_ref(\@out) |
110
|
2
|
100
|
|
|
|
11
|
unless $params{in_place}; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
36
|
@$self = @out; |
113
|
1
|
|
|
|
|
5
|
return $self; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
2
|
|
|
2
|
1
|
17
|
sub asserts { shift->grep(has_assert => @_) } |
117
|
1
|
|
|
1
|
1
|
6
|
sub subtests { shift->grep(has_subtest => @_) } |
118
|
1
|
|
|
1
|
1
|
9
|
sub diags { shift->grep(has_diags => @_) } |
119
|
1
|
|
|
1
|
1
|
6
|
sub notes { shift->grep(has_notes => @_) } |
120
|
1
|
|
|
1
|
1
|
6
|
sub errors { shift->grep(has_errors => @_) } |
121
|
1
|
|
|
1
|
1
|
5
|
sub plans { shift->grep(has_plan => @_) } |
122
|
0
|
|
|
0
|
1
|
0
|
sub causes_fail { shift->grep(causes_fail => @_) } |
123
|
0
|
|
|
0
|
1
|
0
|
sub causes_failure { shift->grep(causes_failure => @_) } |
124
|
|
|
|
|
|
|
|
125
|
2
|
|
|
2
|
1
|
17
|
sub flatten { shift->map(flatten => @_) } |
126
|
1
|
|
|
1
|
1
|
6
|
sub briefs { shift->map(brief => @_) } |
127
|
1
|
|
|
1
|
1
|
4
|
sub summaries { shift->map(summary => @_) } |
128
|
1
|
|
|
1
|
1
|
45
|
sub subtest_results { shift->map(subtest_result => @_) } |
129
|
1
|
|
|
1
|
1
|
14
|
sub diag_messages { shift->map(diag_messages => @_) } |
130
|
1
|
|
|
1
|
1
|
4
|
sub note_messages { shift->map(note_messages => @_) } |
131
|
1
|
|
|
1
|
1
|
5
|
sub error_messages { shift->map(error_messages => @_) } |
132
|
|
|
|
|
|
|
|
133
|
35
|
|
|
35
|
|
333
|
no warnings 'once'; |
|
35
|
|
|
|
|
98
|
|
|
35
|
|
|
|
|
9348
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
*map = sub { |
136
|
8
|
|
|
8
|
|
19
|
my $self = shift; |
137
|
8
|
|
|
|
|
24
|
my ($call, %params) = @_; |
138
|
|
|
|
|
|
|
|
139
|
8
|
|
50
|
|
|
47
|
my $args = $params{args} ||= []; |
140
|
|
|
|
|
|
|
|
141
|
8
|
|
|
|
|
22
|
return [map { local $_ = $self->_upgrade($_, %params); $_->$call(@$args) } @$self]; |
|
29
|
|
|
|
|
96
|
|
|
29
|
|
|
|
|
116
|
|
142
|
|
|
|
|
|
|
}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
*grep = sub { |
145
|
7
|
|
|
7
|
|
16
|
my $self = shift; |
146
|
7
|
|
|
|
|
19
|
my ($call, %params) = @_; |
147
|
|
|
|
|
|
|
|
148
|
7
|
|
50
|
|
|
43
|
my $args = $params{args} ||= []; |
149
|
|
|
|
|
|
|
|
150
|
7
|
|
|
|
|
21
|
my @out = grep { local $_ = $self->_upgrade($_, %params); $_->$call(@$args) } @$self; |
|
42
|
|
|
|
|
120
|
|
|
42
|
|
|
|
|
145
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
return blessed($self)->new_from_ref(\@out) |
153
|
7
|
100
|
|
|
|
49
|
unless $params{in_place}; |
154
|
|
|
|
|
|
|
|
155
|
1
|
|
|
|
|
31
|
@$self = @out; |
156
|
1
|
|
|
|
|
5
|
return $self; |
157
|
|
|
|
|
|
|
}; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
__END__ |