blib/lib/ExtUtils/Builder/Plan.pm

filter: Statementstmt 80.3% 53 / 66 Branchbran 45.8% 11 / 24 Conditioncond 50.0% 4 / 8 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 92.8% 13 / 14 Podpod 85.7% 6 / 7 totaltotal 71.7% 89 / 124 CC 19 SCAR 17.7
CC
19
Cov
69%
merge
12.0
_up_to_date
10.1
_node_sorter
7.6
CRAP 5.8
« blib/lib/ExtUtils/Builder/Action/Command.pm ↑ Summary blib/lib/ExtUtils/Builder/Planner.pm »
1 package ExtUtils::Builder::Plan;
2 10 $ExtUtils::Builder::Plan::VERSION = '0.020';
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
10 7 my ($class, %args) = @_;
11 return bless {
12 nodes => $args{nodes} // {}
13 7 ▶ }, $class;
Condition50%1/2
$args{"nodes"} // {}
l!l
70
MC/DC0%0/1
$args{"nodes"} // {}
$args{"nodes"}
Truth table50%1/2
A
A= $args{"nodes"}
Aresult
11
00
14 }
15  
16 4 ▶sub node {
Subroutine node: called CC=1 SCAR=0.0
Pod documented
17 4 my ($self, $name) = @_;
18 4 return $self->{nodes}{$name};
19 }
20  
21 1 ▶sub nodes {
Subroutine nodes: called CC=1 SCAR=0.0
Pod documented
22 1 my $self = shift;
23 1 return @{$self->{nodes}}{ $self->node_names };
24 }
25  
26 6 ▶sub node_names {
Subroutine node_names: called CC=1 SCAR=0.0
Pod documented
27 6 my $self = shift;
28 6 return sort keys %{ $self->{nodes} };
29 }
30  
31 28 ▶sub _node_sorter {
Subroutine _node_sorter: called CC=6 SCAR=20.3
32 28 my ($self, $name, $callback, $seen, $loop) = @_;
33 28 ▶ Carp::croak("$name has a circular dependency, aborting!\n") if exists $loop->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $loop->{$name} 0 28 28
34 28 ▶ return if $seen->{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen->{$name}++ 0 28 28
35 28 ▶ if (my $node = $self->{nodes}{$name}) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $node = $self->{'nodes'}{$name}) { } 28 0 28
elsif (not -e $name) { } 0 0 0
36 28 local $loop->{$name} = 1;
37 28 $self->_node_sorter($_, $callback, $seen, $loop) for $node->dependencies;
38 28 $callback->($name, $node);
39 } elsif (not -e $name) {
40 0 Carp::confess("Node $name doesn't exist")
41 }
42 28 return;
43 }
44  
45 7 ▶sub run {
Subroutine run: called CC=3 SCAR=11.1
Pod documented
46 7 my ($self, $targets, %options) = @_;
47  
48 0 ▶ my @targets = ref($targets) ? @{$targets} : $targets;
Branch: 1 branch
BranchTrueFalseTotal
ref $targets ? : 0 7 7
49 7 my (%seen, %loop);
50 28 ▶ my $run_node = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
51 28 my ($name, $node) = @_;
52 28 ▶ return if $self->_up_to_date($node);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_up_to_date($node) 7 21 28
53 21 $node->execute(%options);
54 7 };
55 7 $self->_node_sorter($_, $run_node, \%seen, \%loop) for @targets;
56 7 return;
57 }
58  
59 28 ▶sub _up_to_date {
Subroutine _up_to_date: called CC=8 SCAR=23.1
60 28 my ($self, $node) = @_;
61 28 ▶ return 0 if $node->type eq 'phony' or not -e $node->target;
Branch: 1 branch
BranchTrueFalseTotal
if $node->type eq "phony" or not -e $node->target 20 8 28
Condition100%3/3
$node->type eq "phony" or not -e $node->target
l!l&&r!l&&!r
2188
MC/DC100%2/2
$node->type eq "phony" or not -e $node->target
$node->type eq "phony" not -e $node->target
Truth table100%3/3
A or not(B)
A= $node->type eq "phony"B= not -e $node->target
ABresult
1X1
011
000
62 8 my $mtime = -M _;
63 8 for my $dep_name (sort $node->dependencies) {
64 6 ▶ if (my $dep = $self->{nodes}{$dep_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dep = $self->{'nodes'}{$dep_name}) { } 6 0 6
65 6 ▶ return 0 unless $dep->newer_than($mtime);
Branch: 1 branch
BranchTrueFalseTotal
unless $dep->newer_than($mtime) 1 5 6
66 } else {
67 0 ▶ return 0 unless -e $dep_name && $mtime <= -M _;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dep_name and $mtime <= -M _ 0 0 0
Condition0%0/3
-e $dep_name and $mtime <= -M _
!ll&&!rl&&r
000
MC/DC0%0/2
-e $dep_name and $mtime <= -M _
-e $dep_name $mtime <= -M _
Truth table0%0/3
A and B
A= -e $dep_nameB= $mtime <= -M _
ABresult
0X0
100
111
68 }
69 }
70 7 return 1;
71 }
72  
73 0 ▶sub merge {
Subroutine merge: not called CC=3 SCAR=24.8
Pod documented
74 0 my ($self, $other) = @_;
75 0 ▶ Carp::croak('Right side of merge is not a Plan') if not $other->isa(__PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
unless $other->isa(__PACKAGE__) 0 0 0
76 0 my $double = join ', ', grep { $other->{nodes}{$_} } keys %{ $self->{nodes} };
77 0 ▶ Carp::croak("Found key(s) $double on both sides of merge") if $double;
Branch: 1 branch
BranchTrueFalseTotal
if $double 0 0 0
78 0 my %nodes = (%{ $self->{nodes} }, %{ $other->{nodes} });
79 0 return ref($self)->new(nodes => [ values %nodes ]);
80 }
81  
82 1 ▶sub phonies {
Subroutine phonies: called CC=1 SCAR=0.0
Pod documented
83 1 my ($self) = @_;
84 1 return sort map { $_->target } grep { $_->phony } values %{ $self->{nodes} };
85 }
86  
87 10 1;
88  
89 # ABSTRACT: An ExtUtils::Builder Plan
90  
91 __END__
« blib/lib/ExtUtils/Builder/Action/Command.pm ↑ Summary blib/lib/ExtUtils/Builder/Planner.pm »