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