blib/lib/POE/Component/CPAN/Reporter.pm

filter: Statementstmt 52.8% 156 / 295 Branchbran 38.6% 51 / 132 Conditioncond 22.8% 13 / 57 MC/DCmcdc 0.0% 0 / 31 Subroutinesub 55.5% 20 / 36 Podpod 100% 10 / 10 totaltotal 44.5% 250 / 561 CC 95 SCAR 39.6
CC
95
Cov
45%
_command
145.5
_wheel_kill
132.0
spawn
21.5
CRAP 52.3
↑ Summary
1 package POE::Component::CPAN::Reporter;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use POE qw(Wheel::Run);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 $VERSION = '0.06';
10  
11 8 my $GOT_KILLFAM;
12  
13 BEGIN {
14 8 ▶ $GOT_KILLFAM = 0;
Subroutine BEGIN: called CC=1 SCAR=0.2
15 8 eval {
16 8 require Proc::ProcessTable;
17 0 $GOT_KILLFAM = 1;
18 };
19 }
20  
21 sub spawn {
22 7 ▶ my $package = shift;
Subroutine spawn: called CC=7 SCAR=30.7
Pod documented
23 7 my %opts = @_;
24 7 $opts{lc $_} = delete $opts{$_} for keys %opts;
25 7 my $options = delete $opts{options};
26  
27 7 ▶ if ( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 7 7
28 0 eval { require Win32; };
29 0 ▶ if ($@) { die "Win32 but failed to load:\n$@" }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
30 0 eval { require Win32::Job; };
31 0 ▶ if ($@) { die "Win32::Job but failed to load:\n$@" }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
32 0 eval { require Win32::Process; };
33 0 ▶ if ($@) { die "Win32::Process but failed to load:\n$@" }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
34 }
35  
36 7 my $self = bless \%opts, $package;
37 7 ▶ $self->{session_id} = POE::Session->create(
Branch: 1 branch
BranchTrueFalseTotal
ref $options eq 'HASH' ? : 7 0 7
38 object_states => [
39 $self => { shutdown => '_shutdown',
40 submit => '_command',
41 push => '_command',
42 unshift => '_command',
43 check => '_command',
44 indices => '_command',
45 },
46 $self => [ qw(_start _spawn_wheel _wheel_error _wheel_closed _wheel_stdout _wheel_stderr _wheel_idle _wheel_kill _sig_child _sig_handle) ],
47 ],
48 heap => $self,
49 ( ref($options) eq 'HASH' ? ( options => $options ) : () ),
50 )->ID();
51 7 return $self;
52 }
53  
54 sub session_id {
55 0 ▶ return $_[0]->{session_id};
Subroutine session_id: not called CC=1 SCAR=6.9
Pod documented
56 }
57  
58 sub pending_jobs {
59 2 ▶ return @{ $_[0]->{job_queue} };
Subroutine pending_jobs: called CC=1 SCAR=0.0
Pod documented
60 }
61  
62 sub current_job {
63 0 ▶ my $self = shift;
Subroutine current_job: not called CC=2 SCAR=17.9
Pod documented
64 0 ▶ return unless $self->{_current_job};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_current_job"} 0 0 0
65 0 my $item = Storable::dclone( $self->{_current_job} );
66 0 return $item;
67 }
68  
69 sub current_log {
70 0 ▶ my $self = shift;
Subroutine current_log: not called CC=2 SCAR=17.9
Pod documented
71 0 ▶ return unless $self->{_wheel_log};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_wheel_log"} 0 0 0
72 0 my $item = Storable::dclone( $self->{_wheel_log} );
73 0 return $item;
74 }
75  
76 sub pause_queue {
77 1 ▶ my $self = shift;
Subroutine pause_queue: called CC=1 SCAR=0.0
Pod documented
78 1 $self->{paused} = 1;
79 }
80  
81 sub resume_queue {
82 1 ▶ my $self = shift;
Subroutine resume_queue: called CC=2 SCAR=7.1
Pod documented
83 1 my $pause = delete $self->{paused};
84 1 ▶ $poe_kernel->post( $self->{session_id}, '_spawn_wheel' ) if $pause;
Branch: 1 branch
BranchTrueFalseTotal
if $pause 1 0 1
85 }
86  
87 sub paused {
88 3 ▶ return $_[0]->{paused};
Subroutine paused: called CC=1 SCAR=0.0
Pod documented
89 }
90  
91 sub statistics {
92 1 ▶ my $self = shift;
Subroutine statistics: called CC=3 SCAR=11.7
Pod documented
93 1 my @stats;
94 1 push @stats, $self->{stats}->{$_} for qw(started totaljobs avg_run min_run max_run);
95 1 ▶ return @stats if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
96 0 return \@stats;
97 }
98  
99 sub shutdown {
100 0 ▶ my $self = shift;
Subroutine shutdown: not called CC=1 SCAR=6.9
Pod documented
101 0 $poe_kernel->post( $self->{session_id}, 'shutdown' );
102 }
103  
104 sub _start {
105 7 ▶ my ($kernel,$self) = @_[KERNEL,OBJECT];
Subroutine _start: called CC=5 SCAR=16.8
106 7 $kernel->sig( 'HUP', '_sig_handle' );
107 7 $self->{session_id} = $_[SESSION]->ID();
108 7 ▶ if ( $self->{alias} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'alias'}) { } 7 0 7
109 7 $kernel->alias_set( $self->{alias} );
110 } else {
111 0 $kernel->refcount_increment( $self->{session_id} => __PACKAGE__ );
112 }
113 7 $self->{job_queue} = [ ];
114 7 ▶ $self->{idle} = 600 unless $self->{idle};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"idle"} 7 0 7
115 7 ▶ $self->{timeout} = 3600 unless $self->{timeout};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"timeout"} 7 0 7
116 $self->{stats} = {
117 7 started => time(),
118 totaljobs => 0,
119 avg_run => 0,
120 min_run => 0,
121 max_run => 0,
122 _sum => 0,
123 };
124 7 ▶ $ENV{PERL_CPAN_REPORTER_DIR} = $self->{reporterdir} if $self->{reporterdir};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"reporterdir"} 0 7 7
125 7 undef;
126 }
127  
128 sub _sig_handle {
129 1 ▶ $poe_kernel->sig_handled();
Subroutine _sig_handle: called CC=1 SCAR=0.0
130 }
131  
132 sub _shutdown {
133 7 ▶ my ($kernel,$self) = @_[KERNEL,OBJECT];
Subroutine _shutdown: called CC=4 SCAR=13.9
134 7 $kernel->sig( 'HUP' );
135 7 $kernel->sig( 'KILL' );
136 7 $kernel->alias_remove( $_ ) for $kernel->alias_list();
137 7 ▶ $kernel->refcount_decrement( $self->{session_id} => __PACKAGE__ ) unless $self->{alias};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"alias"} 0 7 7
138 7 $kernel->refcount_decrement( $_->{session}, __PACKAGE__ ) for @{ $self->{job_queue} };
139 7 $self->{_shutdown} = 1;
140 7 undef;
141 }
142  
143 sub _command {
144 7 ▶ my ($kernel,$self,$state,$sender) = @_[KERNEL,OBJECT,STATE,SENDER];
Subroutine _command: called CC=31 SCAR=49.8
145 7 ▶ return if $self->{_shutdown};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_shutdown"} 0 7 7
146 7 my $args;
147 7 ▶ if ( ref( $_[ARG0] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[10] eq 'HASH') { } 7 0 7
148 7 $args = { %{ $_[ARG0] } };
149 } else {
150 0 $args = { @_[ARG0..$#_] };
151 }
152  
153 7 ▶ $state = 'push' if $state eq 'submit';
Branch: 1 branch
BranchTrueFalseTotal
if $state eq "submit" 5 2 7
154  
155 7 $args->{lc $_} = delete $args->{$_} for grep { $_ !~ /^_/ } keys %{ $args };
156  
157 7 ▶ my $ref = $kernel->alias_resolve( $args->{session} ) || $sender;
Condition33%1/3
$kernel->alias_resolve($args->{'session'}) || $sender
l!l&&r!l&&!r
070
MC/DC0%0/2
$kernel->alias_resolve($args->{'session'}) || $sender
$kernel->alias_resolve($args->{'session'}) $sender
Truth table33%1/3
A || B
A= $kernel->alias_resolve($args->{'session'})B= $sender
ABresult
1X1
011
000
158 7 $args->{session} = $ref->ID();
159  
160 7 ▶ if ( !$args->{module} and $state !~ /^(check|indices)$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->{"module"} or $state =~ /^(check|indices)$/i) 0 7 7
Condition66%2/3
$args->{"module"} or $state =~ /^(check|indices)$/i
l!l&&r!l&&!r
520
MC/DC0%0/2
$args->{"module"} or $state =~ /^(check|indices)$/i
$args->{"module"} $state =~ /^(check|indices)$/i
Truth table66%2/3
A or B
A= $args->{"module"}B= $state =~ /^(check|indices)$/i
ABresult
1X1
011
000
161 0 warn "No 'module' specified for $state";
162 0 return;
163 }
164  
165 7 ▶ unless ( $args->{event} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->{"event"}) 0 7 7
166 0 warn "No 'event' specified for $state";
167 0 return;
168 }
169  
170 7 ▶ if ( $state =~ /^(package|author)$/ and !$args->{search} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state =~ /^(package|author)$/ and not $args->{"search"}) 0 7 7
Condition33%1/3
$state =~ /^(package|author)$/ and not $args->{"search"}
!ll&&!rl&&r
700
MC/DC0%0/2
$state =~ /^(package|author)$/ and not $args->{"search"}
$state =~ /^(package|author)$/ not $args->{"search"}
Truth table33%1/3
A and not(B)
A= $state =~ /^(package|author)$/B= not $args->{"search"}
ABresult
0X0
100
111
171 0 warn "No 'search' criteria specified for $state";
172 0 return;
173 }
174  
175 7 $args->{submitted} = time();
176  
177 7 ▶ if ( $state eq 'check' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state eq 'check') { } 1 6 7
elsif ($state eq 'indices') { } 1 5 6
178 1 ▶ if ( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 1 1
179 0 $args->{program} = \&_check_reporter;
180 0 ▶ $args->{program_args} = [ $args->{perl} || $self->{perl} || $^X ];
Condition0%0/6
$args->{'perl'} || $self->{'perl'} || $^X
l!l&&r!l&&!r
000
$args->{"perl"} or $self->{"perl"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{'perl'} || $self->{'perl'} || $^X
$args->{"perl"} $self->{"perl"} $^X
Truth table0%0/4
A or B || C
A= $args->{"perl"}B= $self->{"perl"}C= $^X
ABCresult
1XX1
01X1
0011
0000
181 }
182 else {
183 1 ▶ my $perl = $args->{perl} || $self->{perl} || $^X;
Condition33%2/6
$args->{'perl'} || $self->{'perl'} || $^X
l!l&&r!l&&!r
010
$args->{"perl"} or $self->{"perl"}
l!l&&r!l&&!r
001
MC/DC0%0/3
$args->{'perl'} || $self->{'perl'} || $^X
$args->{"perl"} $self->{"perl"} $^X
Truth table25%1/4
A or B || C
A= $args->{"perl"}B= $self->{"perl"}C= $^X
ABCresult
1XX1
01X1
0011
0000
184 1 $args->{program} = [ $perl, '-MCPAN::Reporter', '-e', 1 ];
185 }
186 1 $args->{debug} = 1;
187 }
188 elsif ( $state eq 'indices' ) {
189 1 ▶ $args->{prioritise} = 0 unless $args->{prioritise};
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{"prioritise"} 1 0 1
190 1 ▶ if ( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 1 1
191 0 $args->{program} = \&_reload_indices;
192 0 ▶ $args->{program_args} = [ $args->{perl} || $self->{perl} || $^X ];
Condition0%0/6
$args->{'perl'} || $self->{'perl'} || $^X
l!l&&r!l&&!r
000
$args->{"perl"} or $self->{"perl"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{'perl'} || $self->{'perl'} || $^X
$args->{"perl"} $self->{"perl"} $^X
Truth table0%0/4
A or B || C
A= $args->{"perl"}B= $self->{"perl"}C= $^X
ABCresult
1XX1
01X1
0011
0000
193 }
194 else {
195 1 ▶ my $perl = $args->{perl} || $self->{perl} || $^X;
Condition33%2/6
$args->{'perl'} || $self->{'perl'} || $^X
l!l&&r!l&&!r
100
$args->{"perl"} or $self->{"perl"}
l!l&&r!l&&!r
100
MC/DC0%0/3
$args->{'perl'} || $self->{'perl'} || $^X
$args->{"perl"} $self->{"perl"} $^X
Truth table25%1/4
A or B || C
A= $args->{"perl"}B= $self->{"perl"}C= $^X
ABCresult
1XX1
01X1
0011
0000
196 1 my $code = 'CPAN::Index->reload();';
197 1 $args->{program} = [ $perl, '-MCPAN', '-e', $code ];
198 }
199 }
200 else {
201 5 ▶ if ( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 5 5
202 0 $args->{program} = \&_test_module;
203 0 ▶ $args->{program_args} = [ $args->{perl} || $self->{perl} || $^X, $args->{module} ];
Condition0%0/6
$args->{'perl'} || $self->{'perl'} || $^X
l!l&&r!l&&!r
000
$args->{"perl"} or $self->{"perl"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{'perl'} || $self->{'perl'} || $^X
$args->{"perl"} $self->{"perl"} $^X
Truth table0%0/4
A or B || C
A= $args->{"perl"}B= $self->{"perl"}C= $^X
ABCresult
1XX1
01X1
0011
0000
204 }
205 else {
206 5 ▶ my $perl = $args->{perl} || $self->{perl} || $^X;
Condition33%2/6
$args->{'perl'} || $self->{'perl'} || $^X
l!l&&r!l&&!r
500
$args->{"perl"} or $self->{"perl"}
l!l&&r!l&&!r
500
MC/DC0%0/3
$args->{'perl'} || $self->{'perl'} || $^X
$args->{"perl"} $self->{"perl"} $^X
Truth table25%1/4
A or B || C
A= $args->{"perl"}B= $self->{"perl"}C= $^X
ABCresult
1XX1
01X1
0011
0000
207 5 my $code = 'my $module = shift; local $CPAN::Config->{test_report} = 1; if ( $CPAN::Config->{build_dir_reuse} && $CPAN::META->can(q{reset_tested}) ) { CPAN::Index->reload; $CPAN::META->reset_tested; } test( $module );';
208 5 $args->{program} = [ $perl, '-MCPAN', '-e', $code, $args->{module} ];
209 }
210 }
211  
212 7 $kernel->refcount_increment( $args->{session}, __PACKAGE__ );
213  
214 7 $args->{cmd} = $state;
215  
216 7 ▶ if ( $state eq 'unshift' or $args->{prioritise} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state eq 'unshift' or $args->{'prioritise'}) { } 0 7 7
Condition33%1/3
$state eq "unshift" or $args->{"prioritise"}
l!l&&r!l&&!r
007
MC/DC0%0/2
$state eq "unshift" or $args->{"prioritise"}
$state eq "unshift" $args->{"prioritise"}
Truth table33%1/3
A or B
A= $state eq "unshift"B= $args->{"prioritise"}
ABresult
1X1
011
000
217 0 unshift @{ $self->{job_queue} }, $args;
218 }
219 else {
220 7 push @{ $self->{job_queue} }, $args;
221 }
222  
223 7 $kernel->yield( '_spawn_wheel' );
224  
225 7 undef;
226 }
227  
228 sub _sig_child {
229 7 ▶ my ($kernel,$self,$thing,$pid,$status) = @_[KERNEL,OBJECT,ARG0..ARG2];
Subroutine _sig_child: called CC=11 SCAR=27.6
230 7 push @{ $self->{_wheel_log} }, "$thing $pid $status";
231 7 ▶ warn "$thing $pid $status\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 3 4 7
232 7 $kernel->delay( '_wheel_idle' );
233 7 my $job = delete $self->{_current_job};
234 7 $job->{status} = $status;
235 7 my $log = delete $self->{_wheel_log};
236 7 ▶ if ( $job->{cmd} eq 'recent' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($job->{'cmd'} eq 'recent') { } 0 7 7
elsif ($job->{'cmd'} =~ /^(package|author)$/) { } 0 7 7
237 0 pop @{ $log };
238 0 s/\x0D$// for @{ $log };
239 0 $job->{recent} = $log;
240 }
241 elsif ( $job->{cmd} =~ /^(package|author)$/ ) {
242 0 pop @{ $log };
243 0 s/\x0D$// for @{ $log };
244 0 @{ $job->{results} } = grep { $_ !~ /^\[/ } @{ $log };
245 }
246 else {
247 7 $job->{log} = $log;
248 }
249 7 $job->{end_time} = time();
250 7 ▶ unless ( $self->{debug} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"debug"}) 4 3 7
251 4 delete $job->{program};
252 4 delete $job->{program_args};
253 }
254 # Stats
255 7 my $run_time = $job->{end_time} - $job->{start_time};
256 7 ▶ $self->{stats}->{max_run} = $run_time if $run_time > $self->{stats}->{max_run};
Branch: 1 branch
BranchTrueFalseTotal
if $run_time > $self->{"stats"}{"max_run"} 0 7 7
257 7 ▶ $self->{stats}->{min_run} = $run_time if $self->{stats}->{min_run} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"stats"}{"min_run"} == 0 7 0 7
258 7 ▶ $self->{stats}->{min_run} = $run_time if $run_time < $self->{stats}->{min_run};
Branch: 1 branch
BranchTrueFalseTotal
if $run_time < $self->{"stats"}{"min_run"} 0 7 7
259 7 $self->{stats}->{_sum} += $run_time;
260 7 $self->{stats}->{totaljobs}++;
261 7 $self->{stats}->{avg_run} = $self->{stats}->{_sum} / $self->{stats}->{totaljobs};
262 7 $self->{debug} = delete $job->{global_debug};
263 7 ▶ $ENV{PERL_CPAN_REPORTER_DIR} = delete $job->{backup_env} if $job->{reporterdir};
Branch: 1 branch
BranchTrueFalseTotal
if $job->{"reporterdir"} 0 7 7
264 7 $kernel->post( $job->{session}, $job->{event}, $job );
265 7 $kernel->refcount_decrement( $job->{session}, __PACKAGE__ );
266 7 $kernel->yield( '_spawn_wheel' );
267 7 $kernel->sig_handled();
268 }
269  
270 sub _spawn_wheel {
271 15 ▶ my ($kernel,$self) = @_[KERNEL,OBJECT];
Subroutine _spawn_wheel: called CC=9 SCAR=22.9
272 15 ▶ return if $self->{wheel};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"wheel"} 0 15 15
273 15 ▶ return if $self->{_shutdown};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_shutdown"} 0 15 15
274 15 ▶ return if $self->{paused};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"paused"} 1 14 15
275 14 my $job = shift @{ $self->{job_queue} };
276 14 ▶ return unless $job;
Branch: 1 branch
BranchTrueFalseTotal
unless $job 7 7 14
277 7 ▶ if ( $job->{reporterdir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($job->{"reporterdir"}) 0 7 7
278 0 $job->{backup_env} = $ENV{PERL_CPAN_REPORTER_DIR};
279 0 $ENV{PERL_CPAN_REPORTER_DIR} = $job->{reporterdir};
280 }
281 $self->{wheel} = POE::Wheel::Run->new(
282 Program => $job->{program},
283 ProgramArgs => $job->{program_args},
284 7 StdoutEvent => '_wheel_stdout',
285 StderrEvent => '_wheel_stderr',
286 ErrorEvent => '_wheel_error',
287 CloseEvent => '_wheel_close',
288 );
289 7 ▶ unless ( $self->{wheel} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"wheel"}) 0 7 7
290 0 warn "Couldn\'t spawn a wheel for $job->{module}\n";
291 0 $kernel->refcount_decrement( $job->{session}, __PACKAGE__ );
292 0 return;
293 }
294 7 ▶ if ( defined $job->{debug} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $job->{"debug"}) 3 4 7
295 3 $job->{global_debug} = delete $self->{debug};
296 3 $self->{debug} = $job->{debug};
297 }
298 7 $self->{_wheel_log} = [ ];
299 7 $self->{_current_job} = $job;
300 7 $job->{PID} = $self->{wheel}->PID();
301 7 $job->{start_time} = time();
302 7 $kernel->sig_child( $job->{PID}, '_sig_child' );
303 7 ▶ $kernel->delay( '_wheel_idle', 60 ) unless $job->{cmd} eq 'indices';
Branch: 1 branch
BranchTrueFalseTotal
unless $job->{"cmd"} eq "indices" 6 1 7
304 7 undef;
305 }
306  
307 sub _wheel_error {
308 7 ▶ $poe_kernel->delay( '_wheel_idle' );
Subroutine _wheel_error: called CC=1 SCAR=0.0
309 7 delete $_[OBJECT]->{wheel};
310 7 undef;
311 }
312  
313 sub _wheel_closed {
314 0 ▶ $poe_kernel->delay( '_wheel_idle' );
Subroutine _wheel_closed: not called CC=1 SCAR=6.9
315 0 delete $_[OBJECT]->{wheel};
316 0 undef;
317 }
318  
319 sub _wheel_stdout {
320 0 ▶ my ($self, $input, $wheel_id) = @_[OBJECT, ARG0, ARG1];
Subroutine _wheel_stdout: not called CC=2 SCAR=17.9
321 0 $self->{_wheel_time} = time();
322 0 push @{ $self->{_wheel_log} }, $input;
323 0 ▶ warn $input, "\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
324 0 undef;
325 }
326  
327 sub _wheel_stderr {
328 7 ▶ my ($self, $input, $wheel_id) = @_[OBJECT, ARG0, ARG1];
Subroutine _wheel_stderr: called CC=7 SCAR=24.6
329 7 $self->{_wheel_time} = time();
330 7 ▶ if ( $^O eq 'MSWin32' and !$self->{_current_job}->{GRP_PID} and my ($pid) = $input =~ /(\d+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" and not $self->{"_current_job"}{"GRP_PID"} and my($pid) = $input =~ /(\d+)/) 0 7 7
Condition33%2/6
$^O eq "MSWin32" and not $self->{"_current_job"}{"GRP_PID"} and my($pid) = $input =~ /(\d+)/
!ll&&!rl&&r
700
$^O eq "MSWin32" and not $self->{"_current_job"}{"GRP_PID"}
!ll&&!rl&&r
700
MC/DC0%0/3
$^O eq "MSWin32" and not $self->{"_current_job"}{"GRP_PID"} and my($pid) = $input =~ /(\d+)/
$^O eq "MSWin32" not $self->{"_current_job"}{"GRP_PID"} my($pid) = $input =~ /(\d+)/
Truth table25%1/4
A and not(B) and C
A= $^O eq "MSWin32"B= not $self->{"_current_job"}{"GRP_PID"}C= my($pid) = $input =~ /(\d+)/
ABCresult
0XX0
10X0
1100
1111
331 0 $self->{_current_job}->{GRP_PID} = $pid;
332 0 ▶ warn "Grp PID: $pid\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
333 0 return;
334 }
335 7 ▶ push @{ $self->{_wheel_log} }, $input unless $self->{_current_job}->{cmd} eq 'recent';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_current_job"}{"cmd"} eq "recent" 7 0 7
336 7 ▶ warn $input, "\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 3 4 7
337 7 undef;
338 }
339  
340 sub _wheel_idle {
341 0 ▶ my ($kernel,$self) = @_[KERNEL,OBJECT];
Subroutine _wheel_idle: not called CC=3 SCAR=24.8
342 0 my $now = time();
343 0 ▶ if ( $now - $self->{_wheel_time} >= $self->{idle} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($now - $self->{"_wheel_time"} >= $self->{"idle"}) 0 0 0
344 0 $self->{_current_job}->{idle_kill} = 1;
345 0 $kernel->yield( '_wheel_kill', 'Killing current run due to excessive idle' );
346 0 return;
347 }
348 0 ▶ if ( $now - $self->{_current_job}->{start_time} >= $self->{timeout} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($now - $self->{"_current_job"}{"start_time"} >= $self->{"timeout"}) 0 0 0
349 0 $self->{_current_job}->{excess_kill} = 1;
350 0 $kernel->yield( '_wheel_kill', 'Killing current run due to excessive run-time' );
351 0 return;
352 }
353 0 $kernel->delay( '_wheel_idle', 60 );
354 0 return;
355 }
356  
357 sub _wheel_kill {
358 0 ▶ my ($kernel,$self,$reason) = @_[KERNEL,OBJECT,ARG0];
Subroutine _wheel_kill: not called CC=11 SCAR=48.8
359 0 push @{ $self->{_wheel_log} }, $reason;
360 0 ▶ warn $reason, "\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
361 0 ▶ if ( $^O eq 'MSWin32' and $self->{wheel} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32' and $self->{'wheel'}) { } 0 0 0
Condition0%0/3
$^O eq "MSWin32" and $self->{"wheel"}
!ll&&!rl&&r
000
MC/DC0%0/2
$^O eq "MSWin32" and $self->{"wheel"}
$^O eq "MSWin32" $self->{"wheel"}
Truth table0%0/3
A and B
A= $^O eq "MSWin32"B= $self->{"wheel"}
ABresult
0X0
100
111
362 0 my $grp_pid = $self->{_current_job}->{GRP_PID};
363 0 ▶ return unless $grp_pid;
Branch: 1 branch
BranchTrueFalseTotal
unless $grp_pid 0 0 0
364 0 ▶ warn Win32::FormatMessage( Win32::GetLastError() )
Branch: 1 branch
BranchTrueFalseTotal
unless Win32::Process::KillProcess($grp_pid, 0) 0 0 0
365 unless Win32::Process::KillProcess( $grp_pid, 0 );
366 }
367 else {
368 0 ▶ if ( !$self->{no_grp_kill} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->{'no_grp_kill'}) { } 0 0 0
elsif ($GOT_KILLFAM) { } 0 0 0
369 0 ▶ $self->{wheel}->kill(-9) if $self->{wheel};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"wheel"} 0 0 0
370 }
371 elsif ( $GOT_KILLFAM ) {
372 0 ▶ _kill_family( 9, $self->{wheel}->PID() ) if $self->{wheel};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"wheel"} 0 0 0
373 }
374 else {
375 0 ▶ $self->{wheel}->kill(9) if $self->{wheel};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"wheel"} 0 0 0
376 }
377 }
378 0 return;
379 }
380  
381 sub _check_reporter {
382 0 ▶ my $perl = shift;
Subroutine _check_reporter: not called CC=3 SCAR=24.8
383 0 my $cmdline = $perl . q{ -MCPAN::Reporter -e 1};
384 0 ▶ my $job = Win32::Job->new()
Branch: 1 branch
BranchTrueFalseTotal
my $job = "Win32::Job"->new or die Win32::FormatMessage(Win32::GetLastError()) 0 0 0
385 or die Win32::FormatMessage( Win32::GetLastError() );
386 0 ▶ my $pid = $job->spawn( $perl, $cmdline )
Branch: 1 branch
BranchTrueFalseTotal
my $pid = $job->spawn($perl, $cmdline) or die Win32::FormatMessage(Win32::GetLastError()) 0 0 0
387 or die Win32::FormatMessage( Win32::GetLastError() );
388 0 warn $pid, "\n";
389 0 ▶ my $ok = $job->watch( sub { 0 }, 60 );
Subroutine __ANON__: not called CC=1 SCAR=6.9
390 0 my $hashref = $job->status();
391 0 return $hashref->{$pid}->{exitcode};
392 }
393  
394 sub _test_module {
395 0 ▶ my $perl = shift;
Subroutine _test_module: not called CC=3 SCAR=24.8
396 0 my $module = shift;
397 0 my $cmdline = $perl . ' -MCPAN -e "my $module = shift; local $CPAN::Config->{test_report} = 1; if ( $CPAN::Config->{build_dir_reuse} && $CPAN::META->can(q{reset_tested}) ) { CPAN::Index->reload; $CPAN::META->reset_tested; } test( $module );" ' . $module;
398 0 ▶ my $job = Win32::Job->new()
Branch: 1 branch
BranchTrueFalseTotal
my $job = "Win32::Job"->new or die Win32::FormatMessage(Win32::GetLastError()) 0 0 0
399 or die Win32::FormatMessage( Win32::GetLastError() );
400 0 ▶ my $pid = $job->spawn( $perl, $cmdline )
Branch: 1 branch
BranchTrueFalseTotal
my $pid = $job->spawn($perl, $cmdline) or die Win32::FormatMessage(Win32::GetLastError()) 0 0 0
401 or die Win32::FormatMessage( Win32::GetLastError() );
402 0 warn $pid, "\n";
403 0 ▶ my $ok = $job->watch( sub { 0 }, 60 );
Subroutine __ANON__: not called CC=1 SCAR=6.9
404 0 my $hashref = $job->status();
405 0 return $hashref->{$pid}->{exitcode};
406 }
407  
408 sub _reload_indices {
409 0 ▶ my $perl = shift;
Subroutine _reload_indices: not called CC=3 SCAR=24.8
410 0 my $cmdline = $perl . ' -MCPAN -e "CPAN::Index->reload();"';
411 0 ▶ my $job = Win32::Job->new()
Branch: 1 branch
BranchTrueFalseTotal
my $job = "Win32::Job"->new or die Win32::FormatMessage(Win32::GetLastError()) 0 0 0
412 or die Win32::FormatMessage( Win32::GetLastError() );
413 0 ▶ my $pid = $job->spawn( $perl, $cmdline )
Branch: 1 branch
BranchTrueFalseTotal
my $pid = $job->spawn($perl, $cmdline) or die Win32::FormatMessage(Win32::GetLastError()) 0 0 0
414 or die Win32::FormatMessage( Win32::GetLastError() );
415 0 warn $pid, "\n";
416 0 ▶ my $ok = $job->watch( sub { 0 }, 60 );
Subroutine __ANON__: not called CC=1 SCAR=6.9
417 0 my $hashref = $job->status();
418 0 return $hashref->{$pid}->{exitcode};
419 }
420  
421 sub _kill_family {
422 0 ▶ my ($signal, @pids) = @_;
Subroutine _kill_family: not called CC=1 SCAR=6.9
423 0 my $pt = Proc::ProcessTable->new;
424 0 my (@procs) = @{$pt->table};
425 0 my (@kids) = _get_pids( \@procs, @pids );
426 0 @pids = (@pids, @kids);
427 0 kill $signal, reverse @pids;
428 }
429  
430 sub _get_pids {
431 0 ▶ my($procs, @kids) = @_;
Subroutine _get_pids: not called CC=4 SCAR=30.0
432 0 my @pids;
433 0 foreach my $kid (@kids) {
434 0 foreach my $proc (@$procs) {
435 0 ▶ if ($proc->ppid == $kid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($proc->ppid == $kid) 0 0 0
436 0 my $pid = $proc->pid;
437 0 push @pids, $pid, _get_pids( $procs, $pid );
438 }
439 }
440 }
441 0 @pids;
442 }
443  
444 8 1;
445 __END__
↑ Summary