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