line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Util::Grabber; |
2
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
59
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
13
|
use Test2::Hub::Interceptor(); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
8
|
2
|
|
|
2
|
|
12
|
use Test2::EventFacet::Trace(); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
10
|
use Test2::API qw/test2_stack test2_ipc/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
156
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
14
|
use Test2::Util::HashBase qw/hub finished _events term_size
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
15
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub init { |
15
|
2
|
|
|
2
|
0
|
92
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Make sure we have a hub on the stack |
18
|
2
|
|
|
|
|
10
|
test2_stack->top(); |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
32
|
my $hub = test2_stack->new_hub( |
21
|
|
|
|
|
|
|
class => 'Test2::Hub::Interceptor', |
22
|
|
|
|
|
|
|
formatter => undef, |
23
|
|
|
|
|
|
|
no_ending => 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
221
|
$self->{+HUB} = $hub; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
7
|
my @events; |
29
|
2
|
|
|
6
|
|
19
|
$hub->listen(sub { push @events => $_[1] }); |
|
6
|
|
|
|
|
1191
|
|
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
46
|
$self->{+_EVENTS} = \@events; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
8
|
$self->{+TERM_SIZE} = $ENV{TS_TERM_SIZE}; |
34
|
2
|
|
|
|
|
17
|
$ENV{TS_TERM_SIZE} = 80; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
66
|
|
|
21
|
my $trace = $self->{+TRACE} ||= Test2::EventFacet::Trace->new(frame => [caller(1)]); |
37
|
2
|
|
50
|
|
|
58
|
my $state = $self->{+STATE} ||= {}; |
38
|
2
|
|
|
|
|
17
|
$hub->clean_inherited(trace => $trace, state => $state); |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
50
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub flush { |
44
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
45
|
2
|
|
|
|
|
5
|
my $out = [@{$self->{+_EVENTS}}]; |
|
2
|
|
|
|
|
7
|
|
46
|
2
|
|
|
|
|
8
|
@{$self->{+_EVENTS}} = (); |
|
2
|
|
|
|
|
7
|
|
47
|
2
|
|
|
|
|
14
|
return $out; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub events { |
51
|
2
|
|
|
2
|
1
|
26
|
my $self = shift; |
52
|
|
|
|
|
|
|
# Copy |
53
|
2
|
|
|
|
|
5
|
return [@{$self->{+_EVENTS}}]; |
|
2
|
|
|
|
|
10
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub finish { |
57
|
2
|
|
|
2
|
1
|
30
|
my ($self) = @_; # Do not shift; |
58
|
2
|
|
|
|
|
6
|
$_[0] = undef; |
59
|
|
|
|
|
|
|
|
60
|
2
|
50
|
|
|
|
11
|
if (defined $self->{+TERM_SIZE}) { |
61
|
0
|
|
|
|
|
0
|
$ENV{TS_TERM_SIZE} = $self->{+TERM_SIZE}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
else { |
64
|
2
|
|
|
|
|
13
|
delete $ENV{TS_TERM_SIZE}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
5
|
my $hub = $self->{+HUB}; |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
8
|
$self->{+FINISHED} = 1; |
70
|
2
|
|
|
|
|
9
|
test2_stack()->pop($hub); |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
33
|
|
|
51
|
my $trace = $self->{+TRACE} ||= Test2::EventFacet::Trace->new(frame => [caller(1)]); |
73
|
2
|
|
50
|
|
|
19
|
my $state = $self->{+STATE} ||= {}; |
74
|
2
|
|
|
|
|
10
|
$hub->clean_inherited(trace => $trace, state => $state); |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
57
|
my $dbg = Test2::EventFacet::Trace->new( |
77
|
|
|
|
|
|
|
frame => [caller(0)], |
78
|
|
|
|
|
|
|
); |
79
|
2
|
0
|
33
|
|
|
66
|
$hub->finalize($dbg, 1) |
80
|
|
|
|
|
|
|
if !$hub->no_ending |
81
|
|
|
|
|
|
|
&& !$hub->state->ended; |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
16
|
return $self->flush; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub DESTROY { |
87
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
88
|
2
|
50
|
|
|
|
31
|
return if $self->{+FINISHED}; |
89
|
0
|
|
|
|
|
|
test2_stack->pop($self->{+HUB}); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |