blib/lib/Perl/Dist/Util/Toolchain.pm

filter: Statementstmt 91.7% 123 / 134 Branchbran 61.7% 21 / 34 Conditioncond 66.6% 8 / 12 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 90.9% 20 / 22 Podpod 44.4% 4 / 9 totaltotal 81.2% 178 / 219 CC 23 SCAR 18.9
CC
23
Cov
84%
new
15.3
run
10.2
prepare
3.0
CRAP 6.6
« blib/lib/Perl/Dist/Asset/Distribution.pm ↑ Summary blib/lib/Perl/Dist/Inno/Registry.pm »
1 package Perl::Dist::Util::Toolchain;
2  
3 5 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Params::Util qw{ _HASH _ARRAY };
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Module::CoreList ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use IO::Capture::Stdout ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use IO::Capture::Stderr ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Process::Delegatable ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Process::Storable ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Process ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 5 ▶use vars qw{$VERSION @ISA @DELEGATE};
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
16 5 $VERSION = '1.16';
17 5 @ISA = qw{
18 Process::Delegatable
19 Process::Storable
20 Process
21 };
22 5 @DELEGATE = ();
23  
24 # Automatically handle delegation within the test suite
25 5 ▶ if ( $ENV{HARNESS_ACTIVE} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"HARNESS_ACTIVE"}) 5 0 5
26 5 require Probe::Perl;
27 5 @DELEGATE = (
28 Probe::Perl->find_perl_interpreter, '-Mblib',
29 );
30 }
31 }
32  
33 5 my %MODULES = (
34 '5.008008' => [ qw{
35 ExtUtils::MakeMaker
36 File::Path
37 ExtUtils::Command
38 Win32API::File
39 ExtUtils::Install
40 ExtUtils::Manifest
41 Test::Harness
42 Test::Simple
43 ExtUtils::CBuilder
44 ExtUtils::ParseXS
45 version
46 Scalar::Util
47 Compress::Raw::Zlib
48 Compress::Raw::Bzip2
49 IO::Compress::Base
50 Compress::Bzip2
51 IO::Zlib
52 File::Spec
53 File::Temp
54 Win32::WinError
55 Win32API::Registry
56 Win32::TieRegistry
57 File::HomeDir
58 File::Which
59 Archive::Zip
60 Package::Constants
61 IO::String
62 Archive::Tar
63 Compress::unLZMA
64 Parse::CPAN::Meta
65 YAML
66 Net::FTP
67 Digest::MD5
68 Digest::SHA1
69 Digest::SHA
70 Module::Build
71 Term::Cap
72 CPAN
73 Term::ReadKey
74 Term::ReadLine::Perl
75 Text::Glob
76 Data::Dumper
77 URI
78 HTML::Tagset
79 HTML::Parser
80 LWP::UserAgent
81 } ],
82 );
83 5 $MODULES{'5.010000'} = $MODULES{'5.008008'};
84 5 $MODULES{'5.008009'} = $MODULES{'5.008008'};
85  
86 5 my %CORELIST = (
87 '5.008008' => '5.008008',
88 '5.008009' => '5.008008',
89 '5.010000' => '5.010000',
90 );
91  
92  
93  
94  
95  
96 #####################################################################
97 # Constructor and Accessors
98  
99 8 ▶sub new {
Subroutine new: called CC=10 SCAR=27.3
Pod documented
100 8 my $class = shift;
101 8 my $self = bless { @_ }, $class;
102  
103 # Check the Perl version
104 8 ▶ unless ( defined $self->perl_version ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->perl_version) 0 8 8
105 0 Carp::croak("Did not provide a perl_version param");
106 }
107 8 ▶ unless ( defined $self->{cpan} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"cpan"}) 0 8 8
108 0 Carp::croak("Did not provide a cpan param");
109 }
110 8 ▶ unless ( $MODULES{$self->perl_version} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($MODULES{$self->perl_version}) 0 8 8
111 0 Carp::croak("Perl version '" . $self->perl_version . "' is not supported in $class");
112 }
113 8 ▶ unless ( $CORELIST{$self->perl_version} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CORELIST{$self->perl_version}) 0 8 8
114 0 Carp::croak("Perl version '" . $self->perl_version . "' is not supported in $class");
115 }
116  
117 # Populate the modules array if needed
118 8 ▶ unless ( _ARRAY($self->{modules}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_ARRAY($self->{"modules"})) 5 3 8
119 5 $self->{modules} = $MODULES{$self->perl_version};
120 }
121  
122 # Confirm we can find the corelist for the Perl version
123 8 my $corelist_version = $CORELIST{$self->perl_version};
124 $self->{corelist} = $Module::CoreList::version{$corelist_version}
125 8 ▶ || $Module::CoreList::version{$corelist_version+0};
Condition33%1/3
$Module::CoreList::version{$corelist_version} || $Module::CoreList::version{$corelist_version + 0}
l!l&&r!l&&!r
800
MC/DC0%0/2
$Module::CoreList::version{$corelist_version} || $Module::CoreList::version{$corelist_version + 0}
$Module::CoreList::version{$corelist_version} $Module::CoreList::version{$corelist_version + 0}
Truth table33%1/3
A || B
A= $Module::CoreList::version{$corelist_version}B= $Module::CoreList::version{$corelist_version + 0}
ABresult
1X1
011
000
126 8 ▶ unless ( _HASH($self->{corelist}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_HASH($self->{"corelist"})) 0 8 8
127 0 Carp::croak("Failed to find module core versions for Perl " . $self->perl_version);
128 }
129  
130 # Check forced dists, if applicable
131 8 ▶ if ( $self->{force} and ! _HASH($self->{force}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"force"} and not &_HASH($self->{"force"})) 0 8 8
Condition66%2/3
$self->{"force"} and not &_HASH($self->{"force"})
!ll&&!rl&&r
710
MC/DC0%0/2
$self->{"force"} and not &_HASH($self->{"force"})
$self->{"force"} not &_HASH($self->{"force"})
Truth table66%2/3
A and not(B)
A= $self->{"force"}B= not &_HASH($self->{"force"})
ABresult
0X0
100
111
132 0 Carp::croak("The force param must be a HASH reference");
133 }
134  
135 # Create the distribution array
136 8 $self->{dists} = [];
137  
138 8 return $self;
139 }
140  
141 45 ▶sub perl_version {
Subroutine perl_version: called CC=1 SCAR=0.0
Pod undocumented
142 45 $_[0]->{perl_version};
143 }
144  
145 6 ▶sub modules {
Subroutine modules: called CC=1 SCAR=0.0
Pod undocumented
146 6 @{$_[0]->{modules}};
147 }
148  
149 12 ▶sub dists {
Subroutine dists: called CC=1 SCAR=0.0
Pod undocumented
150 12 @{$_[0]->{dists}};
151 }
152  
153 8 ▶sub errstr {
Subroutine errstr: called CC=1 SCAR=0.0
Pod undocumented
154 8 $_[0]->{errstr};
155 }
156  
157 10 ▶sub prepare {
Subroutine prepare: called CC=3 SCAR=11.0
Pod documented
158 10 my $self = shift;
159  
160 # Squash all output that CPAN might spew during this process
161 10 my $stdout = IO::Capture::Stdout->new;
162 10 my $stderr = IO::Capture::Stderr->new;
163 10 $stdout->start;
164 10 $stderr->start;
165  
166 # Load the CPAN client
167 10 require CPAN;
168 10 CPAN->import();
169  
170 # Load the latest index
171 10 eval {
172 0 ▶ local $SIG{__WARN__} = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=1.2
173 10 ▶ CPAN::HandleConfig->load unless $CPAN::Config_loaded++;
Branch: 1 branch
BranchTrueFalseTotal
unless $CPAN::Config_loaded++ 4 6 10
174 10 $CPAN::Config->{'urllist'} = [ $self->{cpan} ];
175 10 $CPAN::Config->{'use_sqlite'} = q[0];
176 10 CPAN::Index->reload;
177 };
178  
179 10 $stdout->stop;
180 10 $stderr->stop;
181  
182 10 ▶ return $@ ? '' : 1;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 10 10
183 }
184  
185 8 ▶sub run {
Subroutine run: called CC=10 SCAR=23.3
Pod documented
186 8 my $self = shift;
187  
188 # Squash all output that CPAN might spew during this process
189 8 my $stdout = IO::Capture::Stdout->new;
190 8 my $stderr = IO::Capture::Stderr->new;
191
192 # Find the module
193 8 my $core = delete $self->{corelist};
194
195 8 $stdout->start; $stderr->start;
196 8 ▶ CPAN::HandleConfig->load unless $CPAN::Config_loaded++;
Branch: 1 branch
BranchTrueFalseTotal
unless $CPAN::Config_loaded++ 0 8 8
197 8 $CPAN::Config->{'urllist'} = [ $self->{cpan} ];
198 8 $CPAN::Config->{'use_sqlite'} = q[0];
199 8 $stdout->stop; $stderr->stop;
200  
201 8 foreach my $name ( @{$self->{modules}} ) {
202 # Shortcut if forced
203 233 ▶ if ( $self->{force}->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"force"}{$name}) 1 232 233
204 1 push @{$self->{dists}}, $self->{force}->{$name};
205 1 next;
206 }
207  
208 # Get the CPAN object for the module, covering any output.
209 232 $stdout->start; $stderr->start;
210 232 my $module = CPAN::Shell->expand('Module', $name);
211 232 $stdout->stop; $stderr->stop;
212 232 ▶ unless ( $module ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($module) 0 232 232
213 0 die "Failed to find '$name'";
214 }
215  
216 # Ignore modules that don't need to be updated
217 232 my $core_version = $core->{$name};
218 232 ▶ if ( defined $core_version and $core_version =~ /_/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $core_version and $core_version =~ /_/) 18 214 232
Condition100%3/3
defined $core_version and $core_version =~ /_/
!ll&&!rl&&r
1338118
MC/DC100%2/2
defined $core_version and $core_version =~ /_/
defined $core_version $core_version =~ /_/
Truth table100%3/3
A and B
A= defined $core_versionB= $core_version =~ /_/
ABresult
0X0
100
111
219 # Sometimes, the core contains a developer
220 # version. For the purposes of this comparison
221 # it should be safe to "round down".
222 18 $core_version =~ s/_.+$//;
223 }
224 232 my $cpan_version = $module->cpan_version;
225 232 ▶ unless ( defined $cpan_version ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cpan_version) 0 232 232
226 0 next;
227 }
228 232 ▶ if ( defined $core_version and $core_version >= $cpan_version ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $core_version and $core_version >= $cpan_version) 0 232 232
Condition66%2/3
defined $core_version and $core_version >= $cpan_version
!ll&&!rl&&r
133990
MC/DC0%0/2
defined $core_version and $core_version >= $cpan_version
defined $core_version $core_version >= $cpan_version
Truth table66%2/3
A and B
A= defined $core_versionB= $core_version >= $cpan_version
ABresult
0X0
100
111
229 0 next;
230 }
231  
232 # Filter out already seen dists
233 232 my $file = $module->cpan_file;
234 232 $file =~ s/^[A-Z]\/[A-Z][A-Z]\///;
235 232 push @{$self->{dists}}, $file;
236 }
237  
238 # Remove duplicates
239 8 my %seen = ();
240 8 @{$self->{dists}} = grep { ! $seen{$_}++ } @{$self->{dists}};
241  
242 8 return 1;
243 }
244  
245 3 ▶sub delegate {
Subroutine delegate: called CC=2 SCAR=7.0
Pod documented
246 3 my $self = shift;
247 3 ▶ unless ( $self->{delegated} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"delegated"}) 3 0 3
248 3 $self->SUPER::delegate( @DELEGATE );
249 3 $self->{delegated} = 1;
250 }
251 3 return 1;
252 }
253  
254 0 ▶sub delegated {
Subroutine delegated: not called CC=1 SCAR=6.9
Pod undocumented
255 0 $_[0]->{delegated};
256 }
257  
258 5 1;
259  
« blib/lib/Perl/Dist/Asset/Distribution.pm ↑ Summary blib/lib/Perl/Dist/Inno/Registry.pm »