JobQueue/DependencyJob.pm

filter: Statementstmt 64.4% 38 / 59 Branchbran 38.8% 7 / 18 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 72.7% 8 / 11 Podpod 50.0% 3 / 6 totaltotal 56.8% 58 / 102 CC 12 SCAR 14.5
CC
12
Cov
57%
startup
6.2
job_part_finished
6.0
failed
6.0
CRAP 4.3
« JobQueue/DependencyQueue.pm ↑ Summary JobQueue/RemoteDependencyJob.pm »
1  
2 package Proc::JobQueue::DependencyJob;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Callback;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 require Proc::JobQueue::Job;
9 1 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our @ISA = qw(Proc::JobQueue::Job);
12  
13 sub new
14 8 ▶{
Subroutine new: called CC=4 SCAR=14.6
Pod undocumented
15 8 my ($pkg, $dependency_graph, $func, %params) = @_;
16 8 ▶ $params{args} ||= [];
Condition50%1/2
$params{"args"} ||= []
l!l
08
MC/DC0%0/1
$params{"args"} ||= []
$params{"args"}
Truth table50%1/2
A
A= $params{"args"}
Aresult
11
00
17  
18 my $cb = (blessed($func) && $func->isa('Callback'))
19 ? $func
20 8 ▶ : Callback->new($func, @{$params{args}});
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($func) && $func->isa('Callback') ? : 0 8 8
Condition33%1/3
builtin::blessed($func) and $func->isa("Callback")
!ll&&!rl&&r
800
MC/DC0%0/2
builtin::blessed($func) and $func->isa("Callback")
builtin::blessed($func) $func->isa("Callback")
Truth table33%1/3
A and B
A= builtin::blessed($func)B= $func->isa("Callback")
ABresult
0X0
100
111
21  
22 8 delete $params{args};
23  
24 8 my $job = $pkg->SUPER::new(
25 dependency_graph => $dependency_graph,
26 dep_cb => $cb,
27 started => 0,
28 runnable => 0,
29 %params,
30 );
31 8 $dependency_graph->add($job);
32 8 return $job;
33 }
34  
35 sub startup
36 8 ▶{
Subroutine startup: called CC=5 SCAR=18.2
Pod documented
37 8 my ($job) = @_;
38  
39 8 my $host = $job->{host};
40 8 my $jobnum = $job->{jobnum};
41 8 my $job_queue = $job->{queue};
42  
43 8 my $cb = $job->{dep_cb};
44 8 $job->{dep_cb} = undef;
45 8 my ($code, $f, @a) = $cb->call($job);
46 8 ▶ if ($code eq 'job-done,dep-keep') {
Branch: 4 branches
BranchTrueFalseTotal
if ($code eq 'job-done,dep-keep') { } 0 8 8
elsif ($code eq 'all-done') { } 2 6 8
elsif ($code eq 'job-keep,dep-done') { } 0 6 6
elsif ($code eq 'all-keep') { } 6 0 6
47 0 $job->{dep_cb} = new Callback ($f, @a);
48 0 $job_queue->jobdone($job);
49 } elsif ($code eq 'all-done') {
50 2 $job->finished(0);
51 } elsif ($code eq 'job-keep,dep-done') {
52 0 $job->{dependency_graph}->remove_dependency($job);
53 0 undef $job->{dependency_graph};
54 } elsif ($code eq 'all-keep') {
55 # okay
56 } else {
57 0 die "unknown code '$code' from $job->{desc}";
58 }
59 }
60  
61 sub job_part_finished
62 0 ▶{
Subroutine job_part_finished: not called CC=2 SCAR=17.9
Pod undocumented
63 0 my ($job, $do_startmore) = @_;
64 0 my $queue = $job->{queue};
65 0 ▶ return unless $queue;
Branch: 1 branch
BranchTrueFalseTotal
unless $queue 0 0 0
66 0 $job->{queue} = undef;
67 0 $queue->job_part_finished($job, $do_startmore);
68 }
69  
70 sub success
71 8 ▶{
Subroutine success: called CC=2 SCAR=8.4
Pod undocumented
72 8 my ($job) = @_;
73 8 ▶ if ($job->{dependency_graph}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($job->{"dependency_graph"}) 0 8 8
74 0 $job->{dependency_graph}->remove_dependency($job);
75 0 undef $job->{dependency_graph};
76 }
77 8 $job->SUPER::success();
78 }
79  
80 sub failed
81 0 ▶{
Subroutine failed: not called CC=2 SCAR=17.9
Pod documented
82 0 my ($job, @exit_code) = @_;
83 0 ▶ if ($job->{dependency_graph}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($job->{"dependency_graph"}) 0 0 0
84 0 $job->{dependency_graph}->stuck_dependency($job);
85 0 undef $job->{dependency_graph};
86 }
87 0 print STDERR "Job $job->{desc} failed, all dependent tasks cancelled\n";
88 }
89  
90 sub failure
91 0 ▶{
Subroutine failure: not called CC=2 SCAR=17.9
Pod documented
92 0 my ($job, @exit_code) = @_;
93 0 ▶ if ($exit_code[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exit_code[0]) { } 0 0 0
94 0 $job->finished(@exit_code);
95 } else {
96 0 $job->finished('FAILED', @exit_code);
97 }
98 }
99  
100 1 1;
101  
102 __END__
« JobQueue/DependencyQueue.pm ↑ Summary JobQueue/RemoteDependencyJob.pm »