Runner/Timeout.pm

filter: Statementstmt 88.8% 32 / 36 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 75.3% 49 / 65 CC 6 SCAR 13.9
CC
6
Cov
80%
signal
7.5
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« Runner/LineBuffer.pm ↑ Summary Runner/Quote.pm »
1 package Command::Runner::Timeout;
2 10 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use experimental qw(lexical_subs signatures);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use Time::HiRes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 our $_USE_CLOCK_MONOTONIC = 0;
8  
9 10 my $time;
10 {
11 10 local $SIG{__DIE__} = 'DEFAULT';
12 10 local $@;
13 10 ▶ if (eval 'Time::HiRes::clock_gettime( Time::HiRes::CLOCK_MONOTONIC() )') {
Branch: 1 branch
BranchTrueFalseTotal
if (eval 'Time::HiRes::clock_gettime( Time::HiRes::CLOCK_MONOTONIC() )') { } 10 0 10
14 132 ▶ $time = sub (@) { Time::HiRes::clock_gettime(Time::HiRes::CLOCK_MONOTONIC()) };
Subroutine __ANON__: called CC=1 SCAR=0.0
15 10 $_USE_CLOCK_MONOTONIC = 1;
16 } else {
17 0 $time = \&Time::HiRes::time;
18 }
19 }
20  
21 4 ▶sub new ($class, $at, $kill) {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
22 4 my $now = $time->();
23 4 bless { signaled => 0, at => $now + $at, at_kill => $now + $at + $kill }, $class;
24 }
25  
26 128 ▶sub signal ($self) {
Subroutine signal: called CC=6 SCAR=20.2
Pod undocumented
27 128 ▶ return if !$self->{at} && !$self->{at_kill};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"at"} or $self->{"at_kill"} 0 128 128
Condition33%1/3
$self->{"at"} or $self->{"at_kill"}
l!l&&r!l&&!r
12800
MC/DC0%0/2
$self->{"at"} or $self->{"at_kill"}
$self->{"at"} $self->{"at_kill"}
Truth table33%1/3
A or B
A= $self->{"at"}B= $self->{"at_kill"}
ABresult
1X1
011
000
28 128 my $now = $time->();
29 128 ▶ if ($self->{at} and $now >= $self->{at}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"at"} and $now >= $self->{"at"}) 4 124 128
Condition66%2/3
$self->{"at"} and $now >= $self->{"at"}
!ll&&!rl&&r
01244
MC/DC50%1/2
$self->{"at"} and $now >= $self->{"at"}
$self->{"at"} $now >= $self->{"at"}
Truth table66%2/3
A and B
A= $self->{"at"}B= $now >= $self->{"at"}
ABresult
0X0
100
111
30 4 $self->{at} = undef;
31 4 $self->{signaled} = 1;
32 4 return 'TERM';
33 }
34 124 ▶ if ($now >= $self->{at_kill}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($now >= $self->{"at_kill"}) 0 124 124
35 0 $self->{at_kill} = undef;
36 0 $self->{signaled} = 1;
37 0 return 'KILL';
38 }
39 124 return;
40 }
41  
42 4 ▶sub signaled ($self) {
Subroutine signaled: called CC=1 SCAR=0.0
Pod undocumented
43 4 $self->{signaled};
44 }
45  
46 10 1;
« Runner/LineBuffer.pm ↑ Summary Runner/Quote.pm »