line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Grab; |
2
|
37
|
|
|
37
|
|
193
|
use strict; |
|
37
|
|
|
|
|
78
|
|
|
37
|
|
|
|
|
965
|
|
3
|
37
|
|
|
37
|
|
214
|
use warnings; |
|
37
|
|
|
|
|
71
|
|
|
37
|
|
|
|
|
914
|
|
4
|
|
|
|
|
|
|
|
5
|
37
|
|
|
37
|
|
219
|
use Test::Stream::Sync; |
|
37
|
|
|
|
|
70
|
|
|
37
|
|
|
|
|
771
|
|
6
|
37
|
|
|
37
|
|
212
|
use Test::Stream::DebugInfo; |
|
37
|
|
|
|
|
77
|
|
|
37
|
|
|
|
|
825
|
|
7
|
37
|
|
|
37
|
|
713
|
use Test::Stream::Hub::Interceptor; |
|
37
|
|
|
|
|
72
|
|
|
37
|
|
|
|
|
911
|
|
8
|
|
|
|
|
|
|
|
9
|
37
|
|
|
37
|
|
189
|
use Test::Stream::Exporter; |
|
37
|
|
|
|
|
91
|
|
|
37
|
|
|
|
|
253
|
|
10
|
5
|
|
|
5
|
|
63
|
default_export grab => sub { __PACKAGE__->new }; |
11
|
37
|
|
|
37
|
|
206
|
no Test::Stream::Exporter; |
|
37
|
|
|
|
|
86
|
|
|
37
|
|
|
|
|
1319
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $STACK = Test::Stream::Sync->stack; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Test::Stream::HashBase( |
16
|
37
|
|
|
|
|
306
|
accessors => [qw/hub finished _events term_size/], |
17
|
37
|
|
|
37
|
|
245
|
); |
|
37
|
|
|
|
|
78
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init { |
20
|
5
|
|
|
5
|
0
|
11
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
|
|
10
|
my $ipc; |
23
|
5
|
50
|
|
|
|
21
|
if ($INC{'Test/Stream/IPC.pm'}) { |
24
|
5
|
|
|
|
|
29
|
my ($driver) = Test::Stream::IPC->drivers; |
25
|
5
|
|
|
|
|
33
|
$ipc = $driver->new; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
71
|
$self->{+HUB} = Test::Stream::Hub::Interceptor->new( |
29
|
|
|
|
|
|
|
ipc => $ipc, |
30
|
|
|
|
|
|
|
no_ending => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
11
|
my @events; |
34
|
5
|
|
|
6
|
|
51
|
$self->{+HUB}->listen(sub { push @events => $_[1] }); |
|
6
|
|
|
|
|
28
|
|
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
|
|
17
|
$self->{+_EVENTS} = \@events; |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
28
|
$STACK->top(); # Make sure there is a top hub before we begin. |
39
|
5
|
|
|
|
|
25
|
$STACK->push($self->{+HUB}); |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
18
|
$self->{+TERM_SIZE} = $ENV{TS_TERM_SIZE}; |
42
|
5
|
|
|
|
|
57
|
$ENV{TS_TERM_SIZE} = 80; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub flush { |
46
|
5
|
|
|
5
|
1
|
10
|
my $self = shift; |
47
|
5
|
|
|
|
|
32
|
my $out = [@{$self->{+_EVENTS}}]; |
|
5
|
|
|
|
|
20
|
|
48
|
5
|
|
|
|
|
11
|
@{$self->{+_EVENTS}} = (); |
|
5
|
|
|
|
|
15
|
|
49
|
5
|
|
|
|
|
35
|
return $out; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub events { |
53
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
54
|
|
|
|
|
|
|
# Copy |
55
|
1
|
|
|
|
|
2
|
return [@{$self->{+_EVENTS}}]; |
|
1
|
|
|
|
|
4
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub finish { |
59
|
5
|
|
|
5
|
1
|
18
|
my ($self) = @_; # Do not shift; |
60
|
5
|
|
|
|
|
10
|
$_[0] = undef; |
61
|
|
|
|
|
|
|
|
62
|
5
|
50
|
|
|
|
21
|
if (defined $self->{+TERM_SIZE}) { |
63
|
0
|
|
|
|
|
0
|
$ENV{TS_TERM_SIZE} = $self->{+TERM_SIZE}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else { |
66
|
5
|
|
|
|
|
30
|
delete $ENV{TS_TERM_SIZE}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
5
|
|
|
|
|
12
|
my $hub = $self->{+HUB}; |
70
|
|
|
|
|
|
|
|
71
|
5
|
|
|
|
|
17
|
$self->{+FINISHED} = 1; |
72
|
5
|
|
|
|
|
24
|
$STACK->pop($hub); |
73
|
|
|
|
|
|
|
|
74
|
5
|
|
|
|
|
67
|
my $dbg = Test::Stream::DebugInfo->new( |
75
|
|
|
|
|
|
|
frame => [caller(0)], |
76
|
|
|
|
|
|
|
); |
77
|
5
|
0
|
33
|
|
|
30
|
$hub->finalize($dbg, 1) |
78
|
|
|
|
|
|
|
if !$hub->no_ending |
79
|
|
|
|
|
|
|
&& !$hub->state->ended; |
80
|
|
|
|
|
|
|
|
81
|
5
|
|
|
|
|
40
|
return $self->flush; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub DESTROY { |
85
|
5
|
|
|
5
|
|
11
|
my $self = shift; |
86
|
5
|
50
|
|
|
|
40
|
return if $self->{+FINISHED}; |
87
|
0
|
|
|
|
|
|
$STACK->pop($self->{+HUB}); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |