blib/lib/CPAN.pm

filter: Statementstmt 29.0% 372 / 1280 Branchbran 12.9% 87 / 670 Conditioncond 15.8% 50 / 315 MC/DCmcdc 6.0% 11 / 182 Subroutinesub 56.1% 73 / 130 Podpod 45.4% 15 / 33 totaltotal 23.3% 608 / 2610 CC 577 SCAR 66.9
CC
577
Cov
22%
shell
3654.7
shell
3654.7
checklock
1560.0
CRAP 803.8
« blib/lib/CPAN/FTP.pm ↑ Summary blib/lib/CPAN/FirstTime.pm »
1 # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
2 # vim: ts=4 sts=4 sw=4:
3 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 package CPAN;
5 26 $CPAN::VERSION = '2.41';
6 26 $CPAN::VERSION =~ s/_//;
7  
8 # we need to run chdir all over and we would get at wrong libraries
9 # there
10 26 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 26 ▶BEGIN {
Subroutine BEGIN: called CC=5 SCAR=17.4
12 26 ▶ if (File::Spec->can("rel2abs")) {
Branch: 1 branch
BranchTrueFalseTotal
if ("File::Spec"->can("rel2abs")) 26 0 26
13 26 for my $inc (@INC) {
14 236 ▶ $inc = File::Spec->rel2abs($inc) unless ref $inc;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $inc 236 0 236
15 }
16 }
17 26 ▶ $SIG{WINCH} = 'IGNORE' if exists $SIG{WINCH};
Branch: 1 branch
BranchTrueFalseTotal
if exists $SIG{"WINCH"} 26 0 26
18 }
19 26 ▶use CPAN::Author;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 26 ▶use CPAN::HandleConfig;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 26 ▶use CPAN::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 26 ▶use CPAN::Bundle;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 26 ▶use CPAN::CacheMgr;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 26 ▶use CPAN::Complete;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 26 ▶use CPAN::Debug;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 26 ▶use CPAN::Distribution;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 26 ▶use CPAN::Distrostatus;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 26 ▶use CPAN::FTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 26 ▶use CPAN::Index 1.93; # https://rt.cpan.org/Ticket/Display.html?id=43349
Subroutine BEGIN: called CC=1 SCAR=0.0
30 26 ▶use CPAN::InfoObj;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 26 ▶use CPAN::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 26 ▶use CPAN::Prompt;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 26 ▶use CPAN::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 26 ▶use CPAN::Queue;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 26 ▶use CPAN::Tarzip;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 26 ▶use CPAN::DeferredCode;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 26 ▶use CPAN::Shell;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 26 ▶use CPAN::LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 26 ▶use CPAN::Exception::RecursiveDependency;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 26 ▶use CPAN::Exception::yaml_not_installed;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 26 ▶use CPAN::Exception::yaml_process_error;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 26 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
44 26 ▶use Config ();
Subroutine BEGIN: called CC=1 SCAR=0.0
45 26 ▶use Cwd qw(chdir);
Subroutine BEGIN: called CC=1 SCAR=0.0
46 26 ▶use DirHandle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
47 26 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
48 26 ▶use ExtUtils::MakeMaker qw(prompt); # for some unknown reason,
Subroutine BEGIN: called CC=1 SCAR=0.0
49 # 5.005_04 does not work without
50 # this
51 26 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
52 26 ▶use File::Copy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
53 26 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 26 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
55 26 ▶use FileHandle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
56 26 ▶use Fcntl qw(:flock);
Subroutine BEGIN: called CC=1 SCAR=0.0
57 26 ▶use Safe ();
Subroutine BEGIN: called CC=1 SCAR=0.0
58 26 ▶use Sys::Hostname qw(hostname);
Subroutine BEGIN: called CC=1 SCAR=0.0
59 26 ▶use Text::ParseWords ();
Subroutine BEGIN: called CC=1 SCAR=0.0
60 26 ▶use Text::Wrap ();
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 # protect against "called too early"
63 sub find_perl ();
64 sub anycwd ();
65 sub _uniq;
66  
67 26 ▶no lib ".";
Subroutine BEGIN: called CC=1 SCAR=0.0
68  
69 26 ▶if ($ENV{PERL5_CPAN_IS_RUNNING} && $$ != $ENV{PERL5_CPAN_IS_RUNNING}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"PERL5_CPAN_IS_RUNNING"} and $$ != $ENV{"PERL5_CPAN_IS_RUNNING"}) 8 18 26
Condition66%2/3
$ENV{"PERL5_CPAN_IS_RUNNING"} and $$ != $ENV{"PERL5_CPAN_IS_RUNNING"}
!ll&&!rl&&r
1808
MC/DC50%1/2
$ENV{"PERL5_CPAN_IS_RUNNING"} and $$ != $ENV{"PERL5_CPAN_IS_RUNNING"}
$ENV{"PERL5_CPAN_IS_RUNNING"} $$ != $ENV{"PERL5_CPAN_IS_RUNNING"}
Truth table66%2/3
A and B
A= $ENV{"PERL5_CPAN_IS_RUNNING"}B= $$ != $ENV{"PERL5_CPAN_IS_RUNNING"}
ABresult
0X0
100
111
70 8 ▶ $ENV{PERL5_CPAN_IS_RUNNING_IN_RECURSION} ||= $ENV{PERL5_CPAN_IS_RUNNING};
Condition33%1/3
$ENV{"PERL5_CPAN_IS_RUNNING_IN_RECURSION"} ||= $ENV{"PERL5_CPAN_IS_RUNNING"}
l!l&&r!l&&!r
080
MC/DC0%0/2
$ENV{"PERL5_CPAN_IS_RUNNING_IN_RECURSION"} ||= $ENV{"PERL5_CPAN_IS_RUNNING"}
$ENV{"PERL5_CPAN_IS_RUNNING_IN_RECURSION"} $ENV{"PERL5_CPAN_IS_RUNNING"}
Truth table33%1/3
A ||= B
A= $ENV{"PERL5_CPAN_IS_RUNNING_IN_RECURSION"}B= $ENV{"PERL5_CPAN_IS_RUNNING"}
ABresult
1X1
011
000
71 8 my @rec = _uniq split(/,/, $ENV{PERL5_CPAN_IS_RUNNING_IN_RECURSION}), $$;
72 8 $ENV{PERL5_CPAN_IS_RUNNING_IN_RECURSION} = join ",", @rec;
73 # warn "# Note: Recursive call of CPAN.pm detected\n";
74 8 my $w = sprintf "# Note: CPAN.pm is running in process %d now", pop @rec;
75 8 my %sleep = (
76 5 => 30,
77 6 => 60,
78 7 => 120,
79 );
80 8 ▶ my $sleep = @rec > 7 ? 300 : ($sleep{scalar @rec}||0);
Branch: 1 branch
BranchTrueFalseTotal
@rec > 7 ? : 0 8 8
Condition50%1/2
$sleep{scalar @rec} or 0
l!l
08
MC/DC0%0/1
$sleep{scalar @rec} or 0
$sleep{scalar @rec}
Truth table50%1/2
A
A= $sleep{scalar @rec}
Aresult
11
00
81 8 my $verbose = @rec >= 4;
82 8 ▶ while (@rec) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rec) 8 8 16
83 8 $w .= sprintf " which has been called by process %d", pop @rec;
84 }
85 8 ▶ if ($sleep) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sleep) 0 8 8
86 0 $w .= ".\n\n# Sleeping $sleep seconds to protect other processes\n";
87 }
88 8 ▶ if ($verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose) 0 8 8
89 0 warn $w;
90 }
91 8 local $| = 1;
92 8 my $have_been_sleeping = 0;
93 8 ▶ while ($sleep > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sleep > 0) 0 8 8
94 0 printf "\r#%5d", --$sleep;
95 0 sleep 1;
96 0 ++$have_been_sleeping;
97 }
98 8 ▶ print "\n" if $have_been_sleeping;
Branch: 1 branch
BranchTrueFalseTotal
if $have_been_sleeping 0 8 8
99 }
100 26 $ENV{PERL5_CPAN_IS_RUNNING}=$$;
101 26 $ENV{PERL5_CPANPLUS_IS_RUNNING}=$$; # https://rt.cpan.org/Ticket/Display.html?id=23735
102  
103 26 ▶END { $CPAN::End++; &cleanup; }
Subroutine END: called CC=1 SCAR=0.0
104  
105 26 ▶$CPAN::Signal ||= 0;
Condition50%1/2
$CPAN::Signal ||= 0
l!l
026
MC/DC0%0/1
$CPAN::Signal ||= 0
$CPAN::Signal
Truth table50%1/2
A
A= $CPAN::Signal
Aresult
11
00
106 26 ▶$CPAN::Frontend ||= "CPAN::Shell";
Condition50%1/2
$CPAN::Frontend ||= "CPAN::Shell"
l!l
026
MC/DC0%0/1
$CPAN::Frontend ||= "CPAN::Shell"
$CPAN::Frontend
Truth table50%1/2
A
A= $CPAN::Frontend
Aresult
11
00
107 26 ▶unless (@CPAN::Defaultsites) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@CPAN::Defaultsites) 26 0 26
108 @CPAN::Defaultsites = map {
109 26 CPAN::URL->new(TEXT => $_, FROM => "DEF")
110 }
111 "http://www.perl.org/CPAN/",
112 "ftp://ftp.perl.org/pub/CPAN/";
113 }
114 # $CPAN::iCwd (i for initial)
115 26 ▶$CPAN::iCwd ||= CPAN::anycwd();
Condition33%1/3
$CPAN::iCwd ||= &anycwd()
l!l&&r!l&&!r
0260
MC/DC0%0/2
$CPAN::iCwd ||= &anycwd()
$CPAN::iCwd &anycwd()
Truth table33%1/3
A ||= B
A= $CPAN::iCwdB= &anycwd()
ABresult
1X1
011
000
116 26 ▶$CPAN::Perl ||= CPAN::find_perl();
Condition33%1/3
$CPAN::Perl ||= &find_perl()
l!l&&r!l&&!r
0260
MC/DC0%0/2
$CPAN::Perl ||= &find_perl()
$CPAN::Perl &find_perl()
Truth table33%1/3
A ||= B
A= $CPAN::PerlB= &find_perl()
ABresult
1X1
011
000
117 26 ▶$CPAN::Defaultdocs ||= "http://search.cpan.org/perldoc?";
Condition50%1/2
$CPAN::Defaultdocs ||= "http://search.cpan.org/perldoc?"
l!l
026
MC/DC0%0/1
$CPAN::Defaultdocs ||= "http://search.cpan.org/perldoc?"
$CPAN::Defaultdocs
Truth table50%1/2
A
A= $CPAN::Defaultdocs
Aresult
11
00
118 26 ▶$CPAN::Defaultrecent ||= "http://search.cpan.org/uploads.rdf";
Condition50%1/2
$CPAN::Defaultrecent ||= "http://search.cpan.org/uploads.rdf"
l!l
026
MC/DC0%0/1
$CPAN::Defaultrecent ||= "http://search.cpan.org/uploads.rdf"
$CPAN::Defaultrecent
Truth table50%1/2
A
A= $CPAN::Defaultrecent
Aresult
11
00
119 26 ▶$CPAN::Defaultrecent ||= "http://cpan.uwinnipeg.ca/htdocs/cpan.xml";
Condition50%1/2
$CPAN::Defaultrecent ||= "http://cpan.uwinnipeg.ca/htdocs/cpan.xml"
l!l
260
MC/DC0%0/1
$CPAN::Defaultrecent ||= "http://cpan.uwinnipeg.ca/htdocs/cpan.xml"
$CPAN::Defaultrecent
Truth table50%1/2
A
A= $CPAN::Defaultrecent
Aresult
11
00
120  
121 # our globals are getting a mess
122 26 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
123 $AUTOLOAD
124 $Be_Silent
125 $CONFIG_DIRTY
126 $Defaultdocs
127 $Echo_readline
128 $Frontend
129 $GOTOSHELL
130 $HAS_USABLE
131 $Have_warned
132 $MAX_RECURSION
133 $META
134 $RUN_DEGRADED
135 $Signal
136 $SQLite
137 $Suppress_readline
138 $VERSION
139 $autoload_recursion
140 $term
141 @Defaultsites
142 @EXPORT
143 26 );
144  
145 26 $MAX_RECURSION = 32;
146  
147 26 @CPAN::ISA = qw(CPAN::Debug Exporter);
148  
149 # note that these functions live in CPAN::Shell and get executed via
150 # AUTOLOAD when called directly
151 26 @EXPORT = qw(
152 autobundle
153 bundle
154 clean
155 cvs_import
156 expand
157 force
158 fforce
159 get
160 install
161 install_tested
162 is_tested
163 make
164 mkmyconfig
165 notest
166 perldoc
167 readme
168 recent
169 recompile
170 report
171 shell
172 smoke
173 test
174 upgrade
175 );
176  
177 sub soft_chdir_with_alternatives ($);
178  
179 {
180 26 ▶ $autoload_recursion ||= 0;
Condition50%1/2
$CPAN::autoload_recursion ||= 0
l!l
026
MC/DC0%0/1
$CPAN::autoload_recursion ||= 0
$CPAN::autoload_recursion
Truth table50%1/2
A
A= $CPAN::autoload_recursion
Aresult
11
00
181  
182 #-> sub CPAN::AUTOLOAD ;
183 1 ▶ sub AUTOLOAD { ## no critic
Subroutine AUTOLOAD: called CC=5 SCAR=27.4
184 0 ▶ $autoload_recursion++;
Subroutine AUTOLOAD: not called CC=5 SCAR=27.4
185 0 my($l) = $AUTOLOAD;
186 0 $l =~ s/.*:://;
187 0 ▶ if ($CPAN::Signal) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Signal) 0 1 1
if ($CPAN::Signal) 0 0 0
188 0 warn "Refusing to autoload '$l' while signal pending";
189 0 $autoload_recursion--;
190 0 return;
191 }
192 0 ▶ if ($autoload_recursion > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::autoload_recursion > 1) 0 1 1
if ($CPAN::autoload_recursion > 1) 0 0 0
193 0 my $fullcommand = join " ", map { "'$_'" } $l, @_;
194 0 warn "Refusing to autoload $fullcommand in recursion\n";
195 0 $autoload_recursion--;
196 0 return;
197 }
198 0 my(%export);
199 0 @export{@EXPORT} = '';
200 0 ▶ CPAN::HandleConfig->load unless $CPAN::Config_loaded++;
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::Config_loaded++ 1 0 1
unless $CPAN::Config_loaded++ 0 0 0
201 0 ▶ if (exists $export{$l}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $export{$l}) { } 0 1 1
if (exists $export{$l}) { } 0 0 0
202 0 CPAN::Shell->$l(@_);
203 } else {
204 0 die(qq{Unknown CPAN command "$AUTOLOAD". }.
205 qq{Type ? for help.\n});
206 }
207 0 $autoload_recursion--;
208 }
209 }
210  
211 {
212 26 my $x = *SAVEOUT; # avoid warning
213 26 ▶ open($x,">&STDOUT") or die "dup failed";
Branch: 1 branch
BranchTrueFalseTotal
open $x, ">&STDOUT" or die "dup failed" 26 0 26
214 26 my $redir = 0;
215 0 ▶ sub _redirect(@) {
Subroutine _redirect: not called CC=10 SCAR=47.0
216 #die if $redir;
217 0 ▶ local $_;
Subroutine _redirect: not called CC=10 SCAR=47.0
218 0 push(@_,undef);
219 0 ▶ while(defined($_=shift)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined($_ = shift())) 0 0 0
if (defined($_ = shift())) 0 0 0
220 0 ▶ if (s/^\s*>//){
Branch: 4 branches
BranchTrueFalseTotal
if (s/^\s*>//) { } 0 0 0
elsif (s/^\s*\|\s*//) { } 0 0 0
if (s/^\s*>//) { } 0 0 0
elsif (s/^\s*\|\s*//) { } 0 0 0
221 0 ▶ my ($m) = s/^>// ? ">" : "";
Branch: 2 branches
BranchTrueFalseTotal
s/^>// ? : 0 0 0
s/^>// ? : 0 0 0
222 0 s/\s+//;
223 0 ▶ $_=shift unless length;
Branch: 2 branches
BranchTrueFalseTotal
unless length $_ 0 0 0
unless length $_ 0 0 0
224 0 ▶ die "no dest" unless defined;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $_ 0 0 0
unless defined $_ 0 0 0
225 0 ▶ open(STDOUT,">$m$_") or die "open:$_:$!\n";
Branch: 2 branches
BranchTrueFalseTotal
open STDOUT, ">$m$_" or die "open:${_}:$!\n" 0 0 0
open STDOUT, ">$m$_" or die "open:${_}:$!\n" 0 0 0
226 0 $redir=1;
227 } elsif ( s/^\s*\|\s*// ) {
228 0 my $pipe="| $_";
229 0 ▶ while(defined($_[0])){
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_[0]) 0 0 0
if (defined $_[0]) 0 0 0
230 0 $pipe .= ' ' . shift;
231 }
232 0 ▶ open(STDOUT,$pipe) or die "open:$pipe:$!\n";
Branch: 2 branches
BranchTrueFalseTotal
open STDOUT, $pipe or die "open:${pipe}:$!\n" 0 0 0
open STDOUT, $pipe or die "open:${pipe}:$!\n" 0 0 0
233 0 $redir=1;
234 } else {
235 0 push(@_,$_);
236 }
237 }
238 0 return @_;
239 }
240 0 ▶ sub _unredirect {
Subroutine _unredirect: not called CC=3 SCAR=24.8
241 0 ▶ return unless $redir;
Subroutine _unredirect: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
unless $redir 0 0 0
unless $redir 0 0 0
242 0 $redir = 0;
243 ## redirect: unredirect and propagate errors. explicit close to wait for pipe.
244 0 close(STDOUT);
245 0 open(STDOUT,">&SAVEOUT");
246 0 ▶ die "$@" if "$@";
Branch: 2 branches
BranchTrueFalseTotal
if "$@" 0 0 0
if "$@" 0 0 0
247 ## redirect: done
248 }
249 }
250  
251 26 ▶sub _uniq {
Subroutine _uniq: called CC=1 SCAR=0.8
252 0 ▶ my(@list) = @_;
Subroutine _uniq: not called CC=1 SCAR=1.2
253 0 my %seen;
254 0 return grep { !$seen{$_}++ } @list;
255 }
256  
257 #-> sub CPAN::shell ;
258 0 ▶sub shell {
Subroutine shell: not called CC=61 SCAR=82.0
Pod documented
259 0 ▶ my($self) = @_;
Subroutine shell: not called CC=61 SCAR=82.0
Pod documented
260 0 ▶ $Suppress_readline = ! -t STDIN unless defined $Suppress_readline;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $CPAN::Suppress_readline 0 0 0
unless defined $CPAN::Suppress_readline 0 0 0
261 0 ▶ CPAN::HandleConfig->load unless $CPAN::Config_loaded++;
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::Config_loaded++ 0 0 0
unless $CPAN::Config_loaded++ 0 0 0
262  
263 0 ▶ my $oprompt = shift || CPAN::Prompt->new;
Condition0%0/6
shift() || 'CPAN::Prompt'->new
l!l&&r!l&&!r
000
shift() || 'CPAN::Prompt'->new
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || 'CPAN::Prompt'->new
shift() 'CPAN::Prompt'->new
MC/DC0%0/2
shift() || 'CPAN::Prompt'->new
shift() 'CPAN::Prompt'->new
Truth table0%0/3
A || B
A= shift()B= 'CPAN::Prompt'->new
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= shift()B= 'CPAN::Prompt'->new
ABresult
1X1
011
000
264 0 my $prompt = $oprompt;
265 0 ▶ my $commandline = shift || "";
Condition0%0/4
shift() || ''
l!l
00
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
266 0 ▶ $CPAN::CurrentCommandId ||= 1;
Condition0%0/4
$CPAN::CurrentCommandId ||= 1
l!l
00
$CPAN::CurrentCommandId ||= 1
l!l
00
MC/DC0%0/1
$CPAN::CurrentCommandId ||= 1
$CPAN::CurrentCommandId
MC/DC0%0/1
$CPAN::CurrentCommandId ||= 1
$CPAN::CurrentCommandId
Truth table0%0/2
A
A= $CPAN::CurrentCommandId
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::CurrentCommandId
Aresult
11
00
267  
268 0 local($^W) = 1;
269 0 ▶ unless ($Suppress_readline) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::Suppress_readline) 0 0 0
unless ($CPAN::Suppress_readline) 0 0 0
270 0 require Term::ReadLine;
271 0 ▶ if (! $term
Branch: 2 branches
BranchTrueFalseTotal
if (not $CPAN::term or $CPAN::term->ReadLine eq "Term::ReadLine::Stub") 0 0 0
if (not $CPAN::term or $CPAN::term->ReadLine eq "Term::ReadLine::Stub") 0 0 0
Condition0%0/6
not $CPAN::term or $CPAN::term->ReadLine eq "Term::ReadLine::Stub"
l!l&&r!l&&!r
000
not $CPAN::term or $CPAN::term->ReadLine eq "Term::ReadLine::Stub"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $CPAN::term or $CPAN::term->ReadLine eq "Term::ReadLine::Stub"
not $CPAN::term $CPAN::term->ReadLine eq "Term::ReadLine::Stub"
MC/DC0%0/2
not $CPAN::term or $CPAN::term->ReadLine eq "Term::ReadLine::Stub"
not $CPAN::term $CPAN::term->ReadLine eq "Term::ReadLine::Stub"
Truth table0%0/3
not(A) or B
A= not $CPAN::termB= $CPAN::term->ReadLine eq "Term::ReadLine::Stub"
ABresult
1X1
011
000
Truth table0%0/3
not(A) or B
A= not $CPAN::termB= $CPAN::term->ReadLine eq "Term::ReadLine::Stub"
ABresult
1X1
011
000
272 or
273 $term->ReadLine eq "Term::ReadLine::Stub"
274 ) {
275 0 $term = Term::ReadLine->new('CPAN Monitor');
276 }
277 0 ▶ if ($term->ReadLine eq "Term::ReadLine::Gnu") {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::term->ReadLine eq 'Term::ReadLine::Gnu') { } 0 0 0
if ($CPAN::term->ReadLine eq 'Term::ReadLine::Gnu') { } 0 0 0
278 0 my $attribs = $term->Attribs;
279 0 ▶ $attribs->{attempted_completion_function} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
280 0 ▶ &CPAN::Complete::gnu_cpl;
Subroutine __ANON__: not called CC=1 SCAR=6.9
281 }
282 0 } else {
283 0 $readline::rl_completion_function =
284 $readline::rl_completion_function = 'CPAN::Complete::cpl';
285 }
286 0 ▶ if (my $histfile = $CPAN::Config->{'histfile'}) {{
Branch: 2 branches
BranchTrueFalseTotal
if (my $histfile = $CPAN::Config->{"histfile"}) 0 0 0
if (my $histfile = $CPAN::Config->{"histfile"}) 0 0 0
287 0 ▶ unless ($term->can("AddHistory")) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::term->can("AddHistory")) 0 0 0
unless ($CPAN::term->can("AddHistory")) 0 0 0
288 0 $CPAN::Frontend->mywarn("Terminal does not support AddHistory.\n");
289 0 ▶ unless ($CPAN::META->has_inst('Term::ReadLine::Perl')) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::META->has_inst("Term::ReadLine::Perl")) 0 0 0
unless ($CPAN::META->has_inst("Term::ReadLine::Perl")) 0 0 0
290 0 $CPAN::Frontend->mywarn("\nTo fix that, maybe try> install Term::ReadLine::Perl\n\n");
291 }
292 0 last;
293 }
294 0 $META->readhist($term,$histfile);
295 }}
296 0 for ($CPAN::Config->{term_ornaments}) { # alias
297 0 local $Term::ReadLine::termcap_nowarn = 1;
298 0 ▶ $term->ornaments($_) if defined;
Branch: 2 branches
BranchTrueFalseTotal
if defined $_ 0 0 0
if defined $_ 0 0 0
299 }
300 # $term->OUT is autoflushed anyway
301 0 my $odef = select STDERR;
302 0 $| = 1;
303 0 select STDOUT;
304 0 $| = 1;
305 0 select $odef;
306 }
307  
308 0 $META->checklock();
309 0 ▶ my @cwd = grep { defined $_ and length $_ }
Branch: 2 branches
BranchTrueFalseTotal
'File::Spec'->can('tmpdir') ? : 0 0 0
'File::Spec'->can('tmpdir') ? : 0 0 0
Condition0%0/6
defined $_ && length $_
!ll&&!rl&&r
000
defined $_ && length $_
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && length $_
defined $_ length $_
MC/DC0%0/2
defined $_ && length $_
defined $_ length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
310 CPAN::anycwd(),
311 File::Spec->can("tmpdir") ? File::Spec->tmpdir() : (),
312 File::Spec->rootdir();
313 0 my $try_detect_readline;
314 0 ▶ $try_detect_readline = $term->ReadLine eq "Term::ReadLine::Stub" if $term;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::term 0 0 0
if $CPAN::term 0 0 0
315 0 ▶ unless ($CPAN::Config->{inhibit_startup_message}) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::Config->{"inhibit_startup_message"}) 0 0 0
unless ($CPAN::Config->{"inhibit_startup_message"}) 0 0 0
316 0 ▶ my $rl_avail = $Suppress_readline ? "suppressed" :
Branch: 4 branches
BranchTrueFalseTotal
$CPAN::Suppress_readline ? : 0 0 0
$CPAN::term->ReadLine ne 'Term::ReadLine::Stub' ? : 0 0 0
$CPAN::Suppress_readline ? : 0 0 0
$CPAN::term->ReadLine ne 'Term::ReadLine::Stub' ? : 0 0 0
317 ($term->ReadLine ne "Term::ReadLine::Stub") ? "enabled" :
318 "available (maybe install Bundle::CPAN or Bundle::CPANxxl?)";
319 0 $CPAN::Frontend->myprint(
320 sprintf qq{
321 cpan shell -- CPAN exploration and modules installation (v%s)
322 Enter 'h' for help.
323  
324 },
325 $CPAN::VERSION,
326 )
327 }
328 0 my($continuation) = "";
329 0 my $last_term_ornaments;
330 0 SHELLCOMMAND: while () {
331 0 ▶ if ($Suppress_readline) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Suppress_readline) { } 0 0 0
if ($CPAN::Suppress_readline) { } 0 0 0
332 0 ▶ if ($Echo_readline) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Echo_readline) 0 0 0
if ($CPAN::Echo_readline) 0 0 0
333 0 $|=1;
334 }
335 0 print $prompt;
336 0 ▶ last SHELLCOMMAND unless defined ($_ = <> );
Branch: 2 branches
BranchTrueFalseTotal
unless defined($_ = readline ARGV) 0 0 0
unless defined($_ = readline ARGV) 0 0 0
337 0 ▶ if ($Echo_readline) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Echo_readline) 0 0 0
if ($CPAN::Echo_readline) 0 0 0
338 # backdoor: I could not find a way to record sessions
339 0 print $_;
340 }
341 0 chomp;
342 } else {
343 last SHELLCOMMAND unless
344 0 ▶ defined ($_ = $term->readline($prompt, $commandline));
Branch: 2 branches
BranchTrueFalseTotal
unless defined($_ = $CPAN::term->readline($prompt, $commandline)) 0 0 0
unless defined($_ = $CPAN::term->readline($prompt, $commandline)) 0 0 0
345 }
346 0 ▶ $_ = "$continuation$_" if $continuation;
Branch: 2 branches
BranchTrueFalseTotal
if $continuation 0 0 0
if $continuation 0 0 0
347 0 s/^\s+//;
348 0 ▶ next SHELLCOMMAND if /^$/;
Branch: 2 branches
BranchTrueFalseTotal
if /^$/ 0 0 0
if /^$/ 0 0 0
349 0 s/^\s*\?\s*/help /;
350 0 ▶ if (/^(?:q(?:uit)?|bye|exit)\s*$/i) {
Branch: 8 branches
BranchTrueFalseTotal
if (/^(?:q(?:uit)?|bye|exit)\s*$/i) { } 0 0 0
elsif (s/\\$//s) { } 0 0 0
elsif (/^\!/) { } 0 0 0
elsif (/./) { } 0 0 0
if (/^(?:q(?:uit)?|bye|exit)\s*$/i) { } 0 0 0
elsif (s/\\$//s) { } 0 0 0
elsif (/^\!/) { } 0 0 0
elsif (/./) { } 0 0 0
351 0 last SHELLCOMMAND;
352 } elsif (s/\\$//s) {
353 0 chomp;
354 0 $continuation = $_;
355 0 $prompt = " > ";
356 } elsif (/^\!/) {
357 0 s/^\!//;
358 0 my($eval) = $_;
359 package
360 CPAN::Eval; # hide from the indexer
361 26 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
362 26 ▶ use vars qw($import_done);
Subroutine BEGIN: called CC=1 SCAR=0.0
363 0 ▶ CPAN->import(':DEFAULT') unless $import_done++;
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::Eval::import_done++ 0 0 0
unless $CPAN::Eval::import_done++ 0 0 0
364 0 ▶ CPAN->debug("eval[$eval]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
365 0 eval($eval);
366 0 ▶ warn $@ if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 0 0
if $@ 0 0 0
367 0 $continuation = "";
368 0 $prompt = $oprompt;
369 } elsif (/./) {
370 0 my(@line);
371 0 eval { @line = Text::ParseWords::shellwords($_) };
372 0 ▶ warn($@), next SHELLCOMMAND if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 0 0
if $@ 0 0 0
373 0 ▶ warn("Text::Parsewords could not parse the line [$_]"),
Branch: 2 branches
BranchTrueFalseTotal
unless @line 0 0 0
unless @line 0 0 0
374 next SHELLCOMMAND unless @line;
375 0 ▶ $CPAN::META->debug("line[".join("|",@line)."]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
376 0 my $command = shift @line;
377 0 eval {
378 0 local (*STDOUT)=*STDOUT;
379 0 @line = _redirect(@line);
380 0 CPAN::Shell->$command(@line)
381 };
382 0 my $command_error = $@;
383 0 _unredirect;
384 0 my $reported_error;
385 0 ▶ if ($command_error) {
Branch: 2 branches
BranchTrueFalseTotal
if ($command_error) 0 0 0
if ($command_error) 0 0 0
386 0 my $err = $command_error;
387 0 ▶ if (ref $err and $err->isa('CPAN::Exception::blocked_urllist')) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $err and $err->isa('CPAN::Exception::blocked_urllist')) { } 0 0 0
if (ref $err and $err->isa('CPAN::Exception::blocked_urllist')) { } 0 0 0
Condition0%0/6
ref $err and $err->isa("CPAN::Exception::blocked_urllist")
!ll&&!rl&&r
000
ref $err and $err->isa("CPAN::Exception::blocked_urllist")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $err and $err->isa("CPAN::Exception::blocked_urllist")
ref $err $err->isa("CPAN::Exception::blocked_urllist")
MC/DC0%0/2
ref $err and $err->isa("CPAN::Exception::blocked_urllist")
ref $err $err->isa("CPAN::Exception::blocked_urllist")
Truth table0%0/3
A and B
A= ref $errB= $err->isa("CPAN::Exception::blocked_urllist")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $errB= $err->isa("CPAN::Exception::blocked_urllist")
ABresult
0X0
100
111
388 0 $CPAN::Frontend->mywarn("Client not fully configured, please proceed with configuring.$err");
389 0 $reported_error = ref $err;
390 } else {
391 # I'd prefer never to arrive here and make all errors exception objects
392 0 ▶ if ($err =~ /\S/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($err =~ /\S/) 0 0 0
if ($err =~ /\S/) 0 0 0
393 0 require Carp;
394 0 require Dumpvalue;
395 0 my $dv = Dumpvalue->new(tick => '"');
396 0 Carp::cluck(sprintf "Catching error: %s", $dv->stringify($err));
397 }
398 }
399 }
400 0 ▶ if ($command =~ /^(
Branch: 2 branches
BranchTrueFalseTotal
if ($command =~ /^( # classic commands make |test |install |clean # pragmas for classic commands |ff?orce |notest # compounds |report |smoke |upgrade )$/x) 0 0 0
if ($command =~ /^( # classic commands make |test |install |clean # pragmas for classic commands |ff?orce |notest # compounds |report |smoke |upgrade )$/x) 0 0 0
401 # classic commands
402 make
403 |test
404 |install
405 |clean
406  
407 # pragmas for classic commands
408 |ff?orce
409 |notest
410  
411 # compounds
412 |report
413 |smoke
414 |upgrade
415 )$/x) {
416 # only commands that tell us something about failed distros
417 # eval necessary for people without an urllist
418 0 eval {CPAN::Shell->failed($CPAN::CurrentCommandId,1);};
419 0 ▶ if (my $err = $@) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $err = $@) 0 0 0
if (my $err = $@) 0 0 0
420 0 ▶ unless (ref $err and $reported_error eq ref $err) {
Branch: 2 branches
BranchTrueFalseTotal
unless (ref $err and $reported_error eq ref $err) 0 0 0
unless (ref $err and $reported_error eq ref $err) 0 0 0
Condition0%0/6
ref $err and $reported_error eq ref $err
!ll&&!rl&&r
000
ref $err and $reported_error eq ref $err
!ll&&!rl&&r
000
MC/DC0%0/2
ref $err and $reported_error eq ref $err
ref $err $reported_error eq ref $err
MC/DC0%0/2
ref $err and $reported_error eq ref $err
ref $err $reported_error eq ref $err
Truth table0%0/3
A and B
A= ref $errB= $reported_error eq ref $err
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $errB= $reported_error eq ref $err
ABresult
0X0
100
111
421 0 die $@;
422 }
423 }
424 }
425 0 soft_chdir_with_alternatives(\@cwd);
426 0 $CPAN::Frontend->myprint("\n");
427 0 $continuation = "";
428 0 $CPAN::CurrentCommandId++;
429 0 $prompt = $oprompt;
430 }
431 } continue {
432 0 $commandline = ""; # I do want to be able to pass a default to
433 # shell, but on the second command I see no
434 # use in that
435 0 $Signal=0;
436 0 CPAN::Queue->nullify_queue;
437 0 ▶ if ($try_detect_readline) {
Branch: 2 branches
BranchTrueFalseTotal
if ($try_detect_readline) 0 0 0
if ($try_detect_readline) 0 0 0
438 0 ▶ if ($CPAN::META->has_inst("Term::ReadLine::Gnu")
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_inst("Term::ReadLine::Gnu") or $CPAN::META->has_inst("Term::ReadLine::Perl")) 0 0 0
if ($CPAN::META->has_inst("Term::ReadLine::Gnu") or $CPAN::META->has_inst("Term::ReadLine::Perl")) 0 0 0
Condition0%0/6
$CPAN::META->has_inst("Term::ReadLine::Gnu") or $CPAN::META->has_inst("Term::ReadLine::Perl")
l!l&&r!l&&!r
000
$CPAN::META->has_inst("Term::ReadLine::Gnu") or $CPAN::META->has_inst("Term::ReadLine::Perl")
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::META->has_inst("Term::ReadLine::Gnu") or $CPAN::META->has_inst("Term::ReadLine::Perl")
$CPAN::META->has_inst("Term::ReadLine::Gnu") $CPAN::META->has_inst("Term::ReadLine::Perl")
MC/DC0%0/2
$CPAN::META->has_inst("Term::ReadLine::Gnu") or $CPAN::META->has_inst("Term::ReadLine::Perl")
$CPAN::META->has_inst("Term::ReadLine::Gnu") $CPAN::META->has_inst("Term::ReadLine::Perl")
Truth table0%0/3
A or B
A= $CPAN::META->has_inst("Term::ReadLine::Gnu")B= $CPAN::META->has_inst("Term::ReadLine::Perl")
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $CPAN::META->has_inst("Term::ReadLine::Gnu")B= $CPAN::META->has_inst("Term::ReadLine::Perl")
ABresult
1X1
011
000
439 ||
440 $CPAN::META->has_inst("Term::ReadLine::Perl")
441 ) {
442 0 delete $INC{"Term/ReadLine.pm"};
443 0 my $redef = 0;
444 0 local($SIG{__WARN__}) = CPAN::Shell::paintdots_onreload(\$redef);
445 0 require Term::ReadLine;
446 0 $CPAN::Frontend->myprint("\n$redef subroutines in ".
447 "Term::ReadLine redefined\n");
448 0 $GOTOSHELL = 1;
449 }
450 }
451 0 ▶ if ($term and $term->can("ornaments")) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::term and $CPAN::term->can("ornaments")) 0 0 0
if ($CPAN::term and $CPAN::term->can("ornaments")) 0 0 0
Condition0%0/6
$CPAN::term and $CPAN::term->can("ornaments")
!ll&&!rl&&r
000
$CPAN::term and $CPAN::term->can("ornaments")
!ll&&!rl&&r
000
MC/DC0%0/2
$CPAN::term and $CPAN::term->can("ornaments")
$CPAN::term $CPAN::term->can("ornaments")
MC/DC0%0/2
$CPAN::term and $CPAN::term->can("ornaments")
$CPAN::term $CPAN::term->can("ornaments")
Truth table0%0/3
A and B
A= $CPAN::termB= $CPAN::term->can("ornaments")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $CPAN::termB= $CPAN::term->can("ornaments")
ABresult
0X0
100
111
452 0 for ($CPAN::Config->{term_ornaments}) { # alias
453 0 ▶ if (defined $_) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_) { } 0 0 0
if (defined $_) { } 0 0 0
454 0 ▶ if (not defined $last_term_ornaments
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $last_term_ornaments or $_ != $last_term_ornaments) 0 0 0
if (not defined $last_term_ornaments or $_ != $last_term_ornaments) 0 0 0
Condition0%0/6
not defined $last_term_ornaments or $_ != $last_term_ornaments
l!l&&r!l&&!r
000
not defined $last_term_ornaments or $_ != $last_term_ornaments
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $last_term_ornaments or $_ != $last_term_ornaments
not defined $last_term_ornaments $_ != $last_term_ornaments
MC/DC0%0/2
not defined $last_term_ornaments or $_ != $last_term_ornaments
not defined $last_term_ornaments $_ != $last_term_ornaments
Truth table0%0/3
not(A) or B
A= not defined $last_term_ornamentsB= $_ != $last_term_ornaments
ABresult
1X1
011
000
Truth table0%0/3
not(A) or B
A= not defined $last_term_ornamentsB= $_ != $last_term_ornaments
ABresult
1X1
011
000
455 or $_ != $last_term_ornaments
456 ) {
457 0 local $Term::ReadLine::termcap_nowarn = 1;
458 0 $term->ornaments($_);
459 0 $last_term_ornaments = $_;
460 }
461 } else {
462 0 undef $last_term_ornaments;
463 }
464 }
465 }
466 0 for my $class (qw(Module Distribution)) {
467 # again unsafe meta access?
468 0 for my $dm (sort keys %{$CPAN::META->{readwrite}{"CPAN::$class"}}) {
469 0 ▶ next unless $CPAN::META->{readwrite}{"CPAN::$class"}{$dm}{incommandcolor};
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::META->{"readwrite"}{"CPAN::$class"}{$dm}{"incommandcolor"} 0 0 0
unless $CPAN::META->{"readwrite"}{"CPAN::$class"}{$dm}{"incommandcolor"} 0 0 0
470 0 CPAN->debug("BUG: $class '$dm' was in command state, resetting");
471 0 delete $CPAN::META->{readwrite}{"CPAN::$class"}{$dm}{incommandcolor};
472 }
473 }
474 0 ▶ if ($GOTOSHELL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::GOTOSHELL) 0 0 0
if ($CPAN::GOTOSHELL) 0 0 0
475 0 $GOTOSHELL = 0; # not too often
476 0 ▶ $META->savehist if $CPAN::term && $CPAN::term->can("GetHistory");
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::term and $CPAN::term->can("GetHistory") 0 0 0
if $CPAN::term and $CPAN::term->can("GetHistory") 0 0 0
Condition0%0/6
$CPAN::term and $CPAN::term->can("GetHistory")
!ll&&!rl&&r
000
$CPAN::term and $CPAN::term->can("GetHistory")
!ll&&!rl&&r
000
MC/DC0%0/2
$CPAN::term and $CPAN::term->can("GetHistory")
$CPAN::term $CPAN::term->can("GetHistory")
MC/DC0%0/2
$CPAN::term and $CPAN::term->can("GetHistory")
$CPAN::term $CPAN::term->can("GetHistory")
Truth table0%0/3
A and B
A= $CPAN::termB= $CPAN::term->can("GetHistory")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $CPAN::termB= $CPAN::term->can("GetHistory")
ABresult
0X0
100
111
477 0 @_ = ($oprompt,"");
478 0 goto &shell;
479 }
480 }
481 0 soft_chdir_with_alternatives(\@cwd);
482 }
483  
484 #-> CPAN::soft_chdir_with_alternatives ;
485 0 ▶sub soft_chdir_with_alternatives ($) {
Subroutine soft_chdir_with_alternatives: not called CC=4 SCAR=30.0
Pod undocumented
486 0 ▶ my($cwd) = @_;
Subroutine soft_chdir_with_alternatives: not called CC=4 SCAR=30.0
Pod undocumented
487 0 ▶ unless (@$cwd) {
Branch: 2 branches
BranchTrueFalseTotal
unless (@$cwd) 0 0 0
unless (@$cwd) 0 0 0
488 0 my $root = File::Spec->rootdir();
489 0 $CPAN::Frontend->mywarn(qq{Warning: no good directory to chdir to!
490 Trying '$root' as temporary haven.
491 });
492 0 push @$cwd, $root;
493 }
494 0 while () {
495 0 ▶ if (chdir "$cwd->[0]") {
Branch: 2 branches
BranchTrueFalseTotal
if (CPAN::chdir("$cwd->[0]")) { } 0 0 0
if (CPAN::chdir("$cwd->[0]")) { } 0 0 0
496 0 return;
497 } else {
498 0 ▶ if (@$cwd>1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@$cwd > 1) { } 0 0 0
if (@$cwd > 1) { } 0 0 0
499 0 $CPAN::Frontend->mywarn(qq{Could not chdir to "$cwd->[0]": $!
500 Trying to chdir to "$cwd->[1]" instead.
501 });
502 0 shift @$cwd;
503 } else {
504 0 $CPAN::Frontend->mydie(qq{Could not chdir to "$cwd->[0]": $!});
505 }
506 }
507 }
508 }
509  
510 96 ▶sub _flock {
Subroutine _flock: called CC=4 SCAR=25.5
511 0 ▶ my($fh,$mode) = @_;
Subroutine _flock: not called CC=4 SCAR=25.5
512 0 ▶ if ( $Config::Config{d_flock} || $Config::Config{d_fcntl_can_lock} ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($Config::Config{'d_flock'} or $Config::Config{'d_fcntl_can_lock'}) { } 96 0 96
elsif (not $CPAN::Have_warned->{'d_flock'}++) { } 0 0 0
if ($Config::Config{'d_flock'} or $Config::Config{'d_fcntl_can_lock'}) { } 0 0 0
elsif (not $CPAN::Have_warned->{'d_flock'}++) { } 0 0 0
Condition16%1/6
$Config::Config{"d_flock"} or $Config::Config{"d_fcntl_can_lock"}
l!l&&r!l&&!r
9600
$Config::Config{"d_flock"} or $Config::Config{"d_fcntl_can_lock"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Config::Config{"d_flock"} or $Config::Config{"d_fcntl_can_lock"}
$Config::Config{"d_flock"} $Config::Config{"d_fcntl_can_lock"}
MC/DC0%0/2
$Config::Config{"d_flock"} or $Config::Config{"d_fcntl_can_lock"}
$Config::Config{"d_flock"} $Config::Config{"d_fcntl_can_lock"}
Truth table33%1/3
A or B
A= $Config::Config{"d_flock"}B= $Config::Config{"d_fcntl_can_lock"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $Config::Config{"d_flock"}B= $Config::Config{"d_fcntl_can_lock"}
ABresult
1X1
011
000
513 0 return flock $fh, $mode;
514 } elsif (!$Have_warned->{"d_flock"}++) {
515 0 $CPAN::Frontend->mywarn("Your OS does not seem to support locking; continuing and ignoring all locking issues\n");
516 0 $CPAN::Frontend->mysleep(5);
517 0 return 1;
518 } else {
519 0 return 1;
520 }
521 }
522  
523 171 ▶sub _yaml_module () {
Subroutine _yaml_module: called CC=8 SCAR=36.5
524 0 ▶ my $yaml_module = $CPAN::Config->{yaml_module} || "YAML";
Subroutine _yaml_module: not called CC=8 SCAR=36.5
Condition25%1/4
$CPAN::Config->{'yaml_module'} || 'YAML'
l!l
0171
$CPAN::Config->{'yaml_module'} || 'YAML'
l!l
00
MC/DC0%0/1
$CPAN::Config->{'yaml_module'} || 'YAML'
$CPAN::Config->{'yaml_module'}
MC/DC0%0/1
$CPAN::Config->{'yaml_module'} || 'YAML'
$CPAN::Config->{'yaml_module'}
Truth table50%1/2
A
A= $CPAN::Config->{'yaml_module'}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::Config->{'yaml_module'}
Aresult
11
00
525 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($yaml_module ne "YAML" and not $CPAN::META->has_inst($yaml_module)) 0 171 171
if ($yaml_module ne "YAML" and not $CPAN::META->has_inst($yaml_module)) 0 0 0
Condition16%1/6
$yaml_module ne "YAML" and not $CPAN::META->has_inst($yaml_module)
!ll&&!rl&&r
17100
$yaml_module ne "YAML" and not $CPAN::META->has_inst($yaml_module)
!ll&&!rl&&r
000
MC/DC0%0/2
$yaml_module ne "YAML" and not $CPAN::META->has_inst($yaml_module)
$yaml_module ne "YAML" not $CPAN::META->has_inst($yaml_module)
MC/DC0%0/2
$yaml_module ne "YAML" and not $CPAN::META->has_inst($yaml_module)
$yaml_module ne "YAML" not $CPAN::META->has_inst($yaml_module)
Truth table33%1/3
A and not(B)
A= $yaml_module ne "YAML"B= not $CPAN::META->has_inst($yaml_module)
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $yaml_module ne "YAML"B= not $CPAN::META->has_inst($yaml_module)
ABresult
0X0
100
111
526 $yaml_module ne "YAML"
527 &&
528 !$CPAN::META->has_inst($yaml_module)
529 ) {
530 # $CPAN::Frontend->mywarn("'$yaml_module' not installed, falling back to 'YAML'\n");
531 0 $yaml_module = "YAML";
532 }
533 0 ▶ if ($yaml_module eq "YAML"
Branch: 2 branches
BranchTrueFalseTotal
if ($yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module) and $YAML::VERSION < "0.6" and not $CPAN::Have_warned->{"YAML"}++) 0 171 171
if ($yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module) and $YAML::VERSION < "0.6" and not $CPAN::Have_warned->{"YAML"}++) 0 0 0
Condition16%3/18
$yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module) and $YAML::VERSION < "0.6" and not $CPAN::Have_warned->{"YAML"}++
!ll&&!rl&&r
17100
$yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module) and $YAML::VERSION < "0.6"
!ll&&!rl&&r
01710
$yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module)
!ll&&!rl&&r
00171
$yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module) and $YAML::VERSION < "0.6" and not $CPAN::Have_warned->{"YAML"}++
!ll&&!rl&&r
000
$yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module) and $YAML::VERSION < "0.6"
!ll&&!rl&&r
000
$yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module)
!ll&&!rl&&r
000
MC/DC0%0/4
$yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module) and $YAML::VERSION < "0.6" and not $CPAN::Have_warned->{"YAML"}++
$yaml_module eq "YAML" $CPAN::META->has_inst($yaml_module) $YAML::VERSION < "0.6" not $CPAN::Have_warned->{"YAML"}++
MC/DC0%0/4
$yaml_module eq "YAML" and $CPAN::META->has_inst($yaml_module) and $YAML::VERSION < "0.6" and not $CPAN::Have_warned->{"YAML"}++
$yaml_module eq "YAML" $CPAN::META->has_inst($yaml_module) $YAML::VERSION < "0.6" not $CPAN::Have_warned->{"YAML"}++
Truth table20%1/5
A and B and C and not(D)
A= $yaml_module eq "YAML"B= $CPAN::META->has_inst($yaml_module)C= $YAML::VERSION < "0.6"D= not $CPAN::Have_warned->{"YAML"}++
ABCDresult
0XXX0
10XX0
110X0
11100
11111
Truth table0%0/5
A and B and C and not(D)
A= $yaml_module eq "YAML"B= $CPAN::META->has_inst($yaml_module)C= $YAML::VERSION < "0.6"D= not $CPAN::Have_warned->{"YAML"}++
ABCDresult
0XXX0
10XX0
110X0
11100
11111
534 &&
535 $CPAN::META->has_inst($yaml_module)
536 &&
537 $YAML::VERSION < 0.60
538 &&
539 !$Have_warned->{"YAML"}++
540 ) {
541 0 $CPAN::Frontend->mywarn("Warning: YAML version '$YAML::VERSION' is too low, please upgrade!\n".
542 "I'll continue but problems are *very* likely to happen.\n"
543 );
544 0 $CPAN::Frontend->mysleep(5);
545 }
546 0 return $yaml_module;
547 }
548  
549 # CPAN::_yaml_loadfile
550 48 ▶sub _yaml_loadfile {
Subroutine _yaml_loadfile: called CC=12 SCAR=41.4
551 0 ▶ my($self,$local_file,$opt) = @_;
Subroutine _yaml_loadfile: not called CC=12 SCAR=41.4
552 0 ▶ return +[] unless -s $local_file;
Branch: 2 branches
BranchTrueFalseTotal
unless -s $local_file 3 45 48
unless -s $local_file 0 0 0
553 0 ▶ my $opt_loadblessed = $opt->{loadblessed} || $CPAN::Config->{yaml_load_code} || 0;
Condition20%2/10
$opt->{'loadblessed'} || $CPAN::Config->{'yaml_load_code'} || 0
l!l
450
$opt->{"loadblessed"} or $CPAN::Config->{"yaml_load_code"}
l!l&&r!l&&!r
4500
$opt->{'loadblessed'} || $CPAN::Config->{'yaml_load_code'} || 0
l!l
00
$opt->{"loadblessed"} or $CPAN::Config->{"yaml_load_code"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opt->{'loadblessed'} || $CPAN::Config->{'yaml_load_code'} || 0
$opt->{"loadblessed"} $CPAN::Config->{"yaml_load_code"}
MC/DC0%0/2
$opt->{'loadblessed'} || $CPAN::Config->{'yaml_load_code'} || 0
$opt->{"loadblessed"} $CPAN::Config->{"yaml_load_code"}
Truth table33%1/3
A or B
A= $opt->{"loadblessed"}B= $CPAN::Config->{"yaml_load_code"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $opt->{"loadblessed"}B= $CPAN::Config->{"yaml_load_code"}
ABresult
1X1
011
000
554 0 my $yaml_module = _yaml_module;
555 0 ▶ if ($CPAN::META->has_inst($yaml_module)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_inst($yaml_module)) { } 45 0 45
if ($CPAN::META->has_inst($yaml_module)) { } 0 0 0
556 # temporarily enable yaml code deserialisation
557 26 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
558 # 5.6.2 could not do the local() with the reference
559 # so we do it manually instead
560 0 my $old_loadcode = ${"$yaml_module\::LoadCode"};
561 0 my $old_loadblessed = ${"$yaml_module\::LoadBlessed"};
562 0 ▶ ${ "$yaml_module\::LoadCode" } = $CPAN::Config->{yaml_load_code} || 0;
Condition25%1/4
$CPAN::Config->{'yaml_load_code'} || 0
l!l
045
$CPAN::Config->{'yaml_load_code'} || 0
l!l
00
MC/DC0%0/1
$CPAN::Config->{'yaml_load_code'} || 0
$CPAN::Config->{'yaml_load_code'}
MC/DC0%0/1
$CPAN::Config->{'yaml_load_code'} || 0
$CPAN::Config->{'yaml_load_code'}
Truth table50%1/2
A
A= $CPAN::Config->{'yaml_load_code'}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::Config->{'yaml_load_code'}
Aresult
11
00
563 0 ▶ ${ "$yaml_module\::LoadBlessed" } = $opt_loadblessed ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$opt_loadblessed ? : 45 0 45
$opt_loadblessed ? : 0 0 0
564  
565 0 my ($code, @yaml);
566 0 ▶ if ($code = UNIVERSAL::can($yaml_module, "LoadFile")) {
Branch: 4 branches
BranchTrueFalseTotal
if ($code = UNIVERSAL::can($yaml_module, 'LoadFile')) { } 45 0 45
elsif ($code = UNIVERSAL::can($yaml_module, 'Load')) { } 0 0 0
if ($code = UNIVERSAL::can($yaml_module, 'LoadFile')) { } 0 0 0
elsif ($code = UNIVERSAL::can($yaml_module, 'Load')) { } 0 0 0
567 0 eval { @yaml = $code->($local_file); };
568 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 45 45
if ($@) 0 0 0
569 # this shall not be done by the frontend
570 0 die CPAN::Exception::yaml_process_error->new($yaml_module,$local_file,"parse",$@);
571 }
572 } elsif ($code = UNIVERSAL::can($yaml_module, "Load")) {
573 0 local *FH;
574 0 ▶ if (open FH, $local_file) {
Branch: 2 branches
BranchTrueFalseTotal
if (open FH, $local_file) { } 0 0 0
if (open FH, $local_file) { } 0 0 0
575 0 local $/;
576 0 my $ystream = <FH>;
577 0 eval { @yaml = $code->($ystream); };
578 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
579 # this shall not be done by the frontend
580 0 die CPAN::Exception::yaml_process_error->new($yaml_module,$local_file,"parse",$@);
581 }
582 } else {
583 0 $CPAN::Frontend->mywarn("Could not open '$local_file': $!");
584 }
585 }
586 0 ${"$yaml_module\::LoadCode"} = $old_loadcode;
587 0 ${"$yaml_module\::LoadBlessed"} = $old_loadblessed;
588 0 return \@yaml;
589 } else {
590 # this shall not be done by the frontend
591 0 die CPAN::Exception::yaml_not_installed->new($yaml_module, $local_file, "parse");
592 }
593 0 return +[];
594 }
595  
596 # CPAN::_yaml_dumpfile
597 62 ▶sub _yaml_dumpfile {
Subroutine _yaml_dumpfile: called CC=8 SCAR=37.3
598 0 ▶ my($self,$local_file,@what) = @_;
Subroutine _yaml_dumpfile: not called CC=8 SCAR=37.3
599 0 my $yaml_module = _yaml_module;
600 0 ▶ if ($CPAN::META->has_inst($yaml_module)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_inst($yaml_module)) { } 62 0 62
if ($CPAN::META->has_inst($yaml_module)) { } 0 0 0
601 0 my $code;
602 0 ▶ if (UNIVERSAL::isa($local_file, "FileHandle")) {
Branch: 6 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($local_file, 'FileHandle')) { } 0 62 62
elsif ($code = UNIVERSAL::can($yaml_module, 'DumpFile')) { } 62 0 62
elsif ($code = UNIVERSAL::can($yaml_module, 'Dump')) { } 0 0 0
if (UNIVERSAL::isa($local_file, 'FileHandle')) { } 0 0 0
elsif ($code = UNIVERSAL::can($yaml_module, 'DumpFile')) { } 0 0 0
elsif ($code = UNIVERSAL::can($yaml_module, 'Dump')) { } 0 0 0
603 0 $code = UNIVERSAL::can($yaml_module, "Dump");
604 0 eval { print $local_file $code->(@what) };
605 } elsif ($code = UNIVERSAL::can($yaml_module, "DumpFile")) {
606 0 eval { $code->($local_file,@what); };
607 } elsif ($code = UNIVERSAL::can($yaml_module, "Dump")) {
608 0 local *FH;
609 0 ▶ open FH, ">$local_file" or die "Could not open '$local_file': $!";
Branch: 2 branches
BranchTrueFalseTotal
open FH, ">$local_file" or die "Could not open '${local_file}': $!" 0 0 0
open FH, ">$local_file" or die "Could not open '${local_file}': $!" 0 0 0
610 0 print FH $code->(@what);
611 }
612 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 62 62
if ($@) 0 0 0
613 0 die CPAN::Exception::yaml_process_error->new($yaml_module,$local_file,"dump",$@);
614 }
615 } else {
616 0 ▶ if (UNIVERSAL::isa($local_file, "FileHandle")) {
Branch: 2 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($local_file, 'FileHandle')) { } 0 0 0
if (UNIVERSAL::isa($local_file, 'FileHandle')) { } 0 0 0
617 # I think this case does not justify a warning at all
618 } else {
619 0 die CPAN::Exception::yaml_not_installed->new($yaml_module, $local_file, "dump");
620 }
621 }
622 }
623  
624 0 ▶sub _init_sqlite () {
Subroutine _init_sqlite: not called CC=4 SCAR=30.0
625 0 ▶ unless ($CPAN::META->has_inst("CPAN::SQLite")) {
Subroutine _init_sqlite: not called CC=4 SCAR=30.0
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::META->has_inst("CPAN::SQLite")) 0 0 0
unless ($CPAN::META->has_inst("CPAN::SQLite")) 0 0 0
626 $CPAN::Frontend->mywarn(qq{CPAN::SQLite not installed, trying to work without\n})
627 0 ▶ unless $Have_warned->{"CPAN::SQLite"}++;
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::Have_warned->{"CPAN::SQLite"}++ 0 0 0
unless $CPAN::Have_warned->{"CPAN::SQLite"}++ 0 0 0
628 0 return;
629 }
630 0 require CPAN::SQLite::META; # not needed since CVS version of 2006-12-17
631 0 ▶ $CPAN::SQLite ||= CPAN::SQLite::META->new($CPAN::META);
Condition0%0/6
$CPAN::SQLite ||= "CPAN::SQLite::META"->new($CPAN::META)
l!l&&r!l&&!r
000
$CPAN::SQLite ||= "CPAN::SQLite::META"->new($CPAN::META)
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::SQLite ||= "CPAN::SQLite::META"->new($CPAN::META)
$CPAN::SQLite "CPAN::SQLite::META"->new($CPAN::META)
MC/DC0%0/2
$CPAN::SQLite ||= "CPAN::SQLite::META"->new($CPAN::META)
$CPAN::SQLite "CPAN::SQLite::META"->new($CPAN::META)
Truth table0%0/3
A ||= B
A= $CPAN::SQLiteB= "CPAN::SQLite::META"->new($CPAN::META)
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $CPAN::SQLiteB= "CPAN::SQLite::META"->new($CPAN::META)
ABresult
1X1
011
000
632 }
633  
634 {
635 26 my $negative_cache = {};
636 618 ▶ sub _sqlite_running {
Subroutine _sqlite_running: called CC=6 SCAR=28.4
637 0 ▶ if ($negative_cache->{time} && time < $negative_cache->{time} + 60) {
Subroutine _sqlite_running: not called CC=6 SCAR=28.4
Branch: 2 branches
BranchTrueFalseTotal
if ($negative_cache->{'time'} and time < $negative_cache->{'time'} + 60) { } 609 9 618
if ($negative_cache->{'time'} and time < $negative_cache->{'time'} + 60) { } 0 0 0
Condition33%2/6
$negative_cache->{"time"} and time < $negative_cache->{"time"} + 60
!ll&&!rl&&r
90609
$negative_cache->{"time"} and time < $negative_cache->{"time"} + 60
!ll&&!rl&&r
000
MC/DC50%1/2
$negative_cache->{"time"} and time < $negative_cache->{"time"} + 60
$negative_cache->{"time"} time < $negative_cache->{"time"} + 60
MC/DC0%0/2
$negative_cache->{"time"} and time < $negative_cache->{"time"} + 60
$negative_cache->{"time"} time < $negative_cache->{"time"} + 60
Truth table66%2/3
A and B
A= $negative_cache->{"time"}B= time < $negative_cache->{"time"} + 60
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $negative_cache->{"time"}B= time < $negative_cache->{"time"} + 60
ABresult
0X0
100
111
638 # need to cache the result, otherwise too slow
639 0 return $negative_cache->{fact};
640 } else {
641 0 $negative_cache = {}; # reset
642 }
643 0 ▶ my $ret = $CPAN::Config->{use_sqlite} && ($CPAN::SQLite || _init_sqlite());
Condition8%1/12
$CPAN::Config->{'use_sqlite'} && ($CPAN::SQLite || &_init_sqlite())
!ll&&!rl&&r
900
$CPAN::SQLite or &_init_sqlite()
l!l&&r!l&&!r
000
$CPAN::Config->{'use_sqlite'} && ($CPAN::SQLite || &_init_sqlite())
!ll&&!rl&&r
000
$CPAN::SQLite or &_init_sqlite()
l!l&&r!l&&!r
000
MC/DC0%0/3
$CPAN::Config->{'use_sqlite'} && ($CPAN::SQLite || &_init_sqlite())
$CPAN::Config->{'use_sqlite'} $CPAN::SQLite &_init_sqlite()
MC/DC0%0/3
$CPAN::Config->{'use_sqlite'} && ($CPAN::SQLite || &_init_sqlite())
$CPAN::Config->{'use_sqlite'} $CPAN::SQLite &_init_sqlite()
Truth table25%1/4
A && B or C
A= $CPAN::Config->{'use_sqlite'}B= $CPAN::SQLiteC= &_init_sqlite()
ABCresult
0XX0
1000
11X1
1011
Truth table0%0/4
A && B or C
A= $CPAN::Config->{'use_sqlite'}B= $CPAN::SQLiteC= &_init_sqlite()
ABCresult
0XX0
1000
11X1
1011
644 0 ▶ return $ret if $ret; # fast anyway
Branch: 2 branches
BranchTrueFalseTotal
if $ret 0 9 9
if $ret 0 0 0
645 0 $negative_cache->{time} = time;
646 0 return $negative_cache->{fact} = $ret;
647 }
648 }
649  
650 26 ▶$META ||= CPAN->new; # In case we re-eval ourselves we need the ||
Condition33%1/3
$CPAN::META ||= "CPAN"->new
l!l&&r!l&&!r
0260
MC/DC0%0/2
$CPAN::META ||= "CPAN"->new
$CPAN::META "CPAN"->new
Truth table33%1/3
A ||= B
A= $CPAN::METAB= "CPAN"->new
ABresult
1X1
011
000
651  
652 # from here on only subs.
653 ################################################################################
654  
655 21 ▶sub _perl_fingerprint {
Subroutine _perl_fingerprint: called CC=8 SCAR=36.4
656 0 ▶ my($self,$other_fingerprint) = @_;
Subroutine _perl_fingerprint: not called CC=8 SCAR=36.4
657 0 my $dll = eval {OS2::DLLname()};
658 0 my $mtime_dll = 0;
659 0 ▶ if (defined $dll) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $dll) 0 21 21
if (defined $dll) 0 0 0
660 0 ▶ $mtime_dll = (-f $dll ? (stat(_))[9] : '-1');
Branch: 2 branches
BranchTrueFalseTotal
-f $dll ? : 0 0 0
-f $dll ? : 0 0 0
661 }
662 0 ▶ my $mtime_perl = (-f CPAN::find_perl ? (stat(_))[9] : '-1');
Branch: 2 branches
BranchTrueFalseTotal
-f &find_perl() ? : 21 0 21
-f &find_perl() ? : 0 0 0
663 my $this_fingerprint = {
664 '$^X' => CPAN::find_perl,
665 sitearchexp => $Config::Config{sitearchexp},
666 0 'mtime_$^X' => $mtime_perl,
667 'mtime_dll' => $mtime_dll,
668 };
669 0 ▶ if ($other_fingerprint) {
Branch: 2 branches
BranchTrueFalseTotal
if ($other_fingerprint) { } 0 21 21
if ($other_fingerprint) { } 0 0 0
670 0 ▶ if (exists $other_fingerprint->{'stat($^X)'}) { # repair fp from rev. 1.88_57
Branch: 2 branches
BranchTrueFalseTotal
if (exists $other_fingerprint->{"stat(\$^X)"}) 0 0 0
if (exists $other_fingerprint->{"stat(\$^X)"}) 0 0 0
671 0 $other_fingerprint->{'mtime_$^X'} = $other_fingerprint->{'stat($^X)'}[9];
672 }
673 # mandatory keys since 1.88_57
674 0 for my $key (qw($^X sitearchexp mtime_dll mtime_$^X)) {
675 0 ▶ return unless $other_fingerprint->{$key} eq $this_fingerprint->{$key};
Branch: 2 branches
BranchTrueFalseTotal
unless $other_fingerprint->{$key} eq $this_fingerprint->{$key} 0 0 0
unless $other_fingerprint->{$key} eq $this_fingerprint->{$key} 0 0 0
676 }
677 0 return 1;
678 } else {
679 0 return $this_fingerprint;
680 }
681 }
682  
683 0 ▶sub suggest_myconfig () {
Subroutine suggest_myconfig: not called CC=3 SCAR=24.8
Pod undocumented
684 0 ▶ SUGGEST_MYCONFIG: if(!$INC{'CPAN/MyConfig.pm'}) {
Subroutine suggest_myconfig: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
if (not $INC{"CPAN/MyConfig.pm"}) 0 0 0
if (not $INC{"CPAN/MyConfig.pm"}) 0 0 0
685 0 $CPAN::Frontend->myprint("You don't seem to have a user ".
686 "configuration (MyConfig.pm) yet.\n");
687 0 my $new = CPAN::Shell::colorable_makemaker_prompt("Do you want to create a ".
688 "user configuration now? (Y/n)",
689 "yes");
690 0 ▶ if($new =~ m{^y}i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($new =~ /^y/i) { } 0 0 0
if ($new =~ /^y/i) { } 0 0 0
691 0 CPAN::Shell->mkmyconfig();
692 0 return &checklock;
693 } else {
694 0 $CPAN::Frontend->mydie("OK, giving up.");
695 }
696 }
697 }
698  
699 #-> sub CPAN::all_objects ;
700 0 ▶sub all_objects {
Subroutine all_objects: not called CC=3 SCAR=24.8
Pod undocumented
701 0 ▶ my($mgr,$class) = @_;
Subroutine all_objects: not called CC=3 SCAR=24.8
Pod undocumented
702 0 ▶ CPAN::HandleConfig->load unless $CPAN::Config_loaded++;
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::Config_loaded++ 0 0 0
unless $CPAN::Config_loaded++ 0 0 0
703 0 ▶ CPAN->debug("mgr[$mgr] class[$class]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
704 0 CPAN::Index->reload;
705 0 values %{ $META->{readwrite}{$class} }; # unsafe meta access, ok
706 }
707  
708 # Called by shell, not in batch mode. In batch mode I see no risk in
709 # having many processes updating something as installations are
710 # continually checked at runtime. In shell mode I suspect it is
711 # unintentional to open more than one shell at a time
712  
713 #-> sub CPAN::checklock ;
714 0 ▶sub checklock {
Subroutine checklock: not called CC=39 SCAR=73.5
Pod undocumented
715 0 ▶ my($self) = @_;
Subroutine checklock: not called CC=39 SCAR=73.5
Pod undocumented
716 0 my $lockfile = File::Spec->catfile($CPAN::Config->{cpan_home},".lock");
717 0 ▶ if (-f $lockfile && -M _ > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f $lockfile and -M _ > 0) 0 0 0
if (-f $lockfile and -M _ > 0) 0 0 0
Condition0%0/6
-f $lockfile and -M _ > 0
!ll&&!rl&&r
000
-f $lockfile and -M _ > 0
!ll&&!rl&&r
000
MC/DC0%0/2
-f $lockfile and -M _ > 0
-f $lockfile -M _ > 0
MC/DC0%0/2
-f $lockfile and -M _ > 0
-f $lockfile -M _ > 0
Truth table0%0/3
A and B
A= -f $lockfileB= -M _ > 0
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= -f $lockfileB= -M _ > 0
ABresult
0X0
100
111
718 0 ▶ my $fh = FileHandle->new($lockfile) or
Branch: 2 branches
BranchTrueFalseTotal
my $fh = "FileHandle"->new($lockfile) or $CPAN::Frontend->mydie("Could not open lockfile '${lockfile}': $!") 0 0 0
my $fh = "FileHandle"->new($lockfile) or $CPAN::Frontend->mydie("Could not open lockfile '${lockfile}': $!") 0 0 0
719 $CPAN::Frontend->mydie("Could not open lockfile '$lockfile': $!");
720 0 my $otherpid = <$fh>;
721 0 my $otherhost = <$fh>;
722 0 $fh->close;
723 0 ▶ if (defined $otherpid && length $otherpid) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $otherpid and length $otherpid) 0 0 0
if (defined $otherpid and length $otherpid) 0 0 0
Condition0%0/6
defined $otherpid and length $otherpid
!ll&&!rl&&r
000
defined $otherpid and length $otherpid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $otherpid and length $otherpid
defined $otherpid length $otherpid
MC/DC0%0/2
defined $otherpid and length $otherpid
defined $otherpid length $otherpid
Truth table0%0/3
A and B
A= defined $otherpidB= length $otherpid
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $otherpidB= length $otherpid
ABresult
0X0
100
111
724 0 chomp $otherpid;
725 }
726 0 ▶ if (defined $otherhost && length $otherhost) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $otherhost and length $otherhost) 0 0 0
if (defined $otherhost and length $otherhost) 0 0 0
Condition0%0/6
defined $otherhost and length $otherhost
!ll&&!rl&&r
000
defined $otherhost and length $otherhost
!ll&&!rl&&r
000
MC/DC0%0/2
defined $otherhost and length $otherhost
defined $otherhost length $otherhost
MC/DC0%0/2
defined $otherhost and length $otherhost
defined $otherhost length $otherhost
Truth table0%0/3
A and B
A= defined $otherhostB= length $otherhost
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $otherhostB= length $otherhost
ABresult
0X0
100
111
727 0 chomp $otherhost;
728 }
729 0 my $thishost = hostname();
730 0 my $ask_if_degraded_wanted = 0;
731 0 ▶ if (defined $otherhost && defined $thishost &&
Branch: 8 branches
BranchTrueFalseTotal
if (defined $otherhost and defined $thishost and $otherhost ne '' and $thishost ne '' and $otherhost ne $thishost) { } 0 0 0
elsif ($CPAN::RUN_DEGRADED) { } 0 0 0
elsif (defined $otherpid and $otherpid) { } 0 0 0
elsif ($^O eq 'MSWin32') { } 0 0 0
if (defined $otherhost and defined $thishost and $otherhost ne '' and $thishost ne '' and $otherhost ne $thishost) { } 0 0 0
elsif ($CPAN::RUN_DEGRADED) { } 0 0 0
elsif (defined $otherpid and $otherpid) { } 0 0 0
elsif ($^O eq 'MSWin32') { } 0 0 0
Condition0%0/24
defined $otherhost and defined $thishost and $otherhost ne "" and $thishost ne "" and $otherhost ne $thishost
!ll&&!rl&&r
000
defined $otherhost and defined $thishost and $otherhost ne "" and $thishost ne ""
!ll&&!rl&&r
000
defined $otherhost and defined $thishost and $otherhost ne ""
!ll&&!rl&&r
000
defined $otherhost and defined $thishost
!ll&&!rl&&r
000
defined $otherhost and defined $thishost and $otherhost ne "" and $thishost ne "" and $otherhost ne $thishost
!ll&&!rl&&r
000
defined $otherhost and defined $thishost and $otherhost ne "" and $thishost ne ""
!ll&&!rl&&r
000
defined $otherhost and defined $thishost and $otherhost ne ""
!ll&&!rl&&r
000
defined $otherhost and defined $thishost
!ll&&!rl&&r
000
MC/DC0%0/5
defined $otherhost and defined $thishost and $otherhost ne "" and $thishost ne "" and $otherhost ne $thishost
defined $otherhost defined $thishost $otherhost ne "" $thishost ne "" $otherhost ne $thishost
MC/DC0%0/5
defined $otherhost and defined $thishost and $otherhost ne "" and $thishost ne "" and $otherhost ne $thishost
defined $otherhost defined $thishost $otherhost ne "" $thishost ne "" $otherhost ne $thishost
Truth table0%0/6
A and B and C and D and E
A= defined $otherhostB= defined $thishostC= $otherhost ne ""D= $thishost ne ""E= $otherhost ne $thishost
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
Truth table0%0/6
A and B and C and D and E
A= defined $otherhostB= defined $thishostC= $otherhost ne ""D= $thishost ne ""E= $otherhost ne $thishost
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
732 $otherhost ne '' && $thishost ne '' &&
733 $otherhost ne $thishost) {
734 0 $CPAN::Frontend->mydie(sprintf("CPAN.pm panic: Lockfile '$lockfile'\n".
735 "reports other host $otherhost and other ".
736 "process $otherpid.\n".
737 "Cannot proceed.\n"));
738 } elsif ($RUN_DEGRADED) {
739 0 $CPAN::Frontend->mywarn("Running in downgraded mode (experimental)\n");
740 ▶ } elsif (defined $otherpid && $otherpid) {
Condition0%0/6
defined $otherpid and $otherpid
!ll&&!rl&&r
000
defined $otherpid and $otherpid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $otherpid and $otherpid
defined $otherpid $otherpid
MC/DC0%0/2
defined $otherpid and $otherpid
defined $otherpid $otherpid
Truth table0%0/3
A and B
A= defined $otherpidB= $otherpid
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $otherpidB= $otherpid
ABresult
0X0
100
111
741 0 ▶ return if $$ == $otherpid; # should never happen
Branch: 2 branches
BranchTrueFalseTotal
if $$ == $otherpid 0 0 0
if $$ == $otherpid 0 0 0
742 0 $CPAN::Frontend->mywarn(
743 qq{
744 There seems to be running another CPAN process (pid $otherpid). Contacting...
745 });
746 0 ▶ if (kill 0, $otherpid or $!{EPERM}) {
Branch: 4 branches
BranchTrueFalseTotal
if (kill 0, $otherpid or $!{'EPERM'}) { } 0 0 0
elsif (-w $lockfile) { } 0 0 0
if (kill 0, $otherpid or $!{'EPERM'}) { } 0 0 0
elsif (-w $lockfile) { } 0 0 0
Condition0%0/6
kill 0, $otherpid or $!{"EPERM"}
l!l&&r!l&&!r
000
kill 0, $otherpid or $!{"EPERM"}
l!l&&r!l&&!r
000
MC/DC0%0/2
kill 0, $otherpid or $!{"EPERM"}
kill 0, $otherpid $!{"EPERM"}
MC/DC0%0/2
kill 0, $otherpid or $!{"EPERM"}
kill 0, $otherpid $!{"EPERM"}
Truth table0%0/3
A or B
A= kill 0, $otherpidB= $!{"EPERM"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= kill 0, $otherpidB= $!{"EPERM"}
ABresult
1X1
011
000
747 0 $CPAN::Frontend->mywarn(qq{Other job is running.\n});
748 0 $ask_if_degraded_wanted = 1;
749 } elsif (-w $lockfile) {
750 0 my($ans) =
751 CPAN::Shell::colorable_makemaker_prompt
752 (qq{Other job not responding. Shall I overwrite }.
753 qq{the lockfile '$lockfile'? (Y/n)},"y");
754 0 ▶ $CPAN::Frontend->myexit("Ok, bye\n")
Branch: 2 branches
BranchTrueFalseTotal
unless $ans =~ /^y/i 0 0 0
unless $ans =~ /^y/i 0 0 0
755 unless $ans =~ /^y/i;
756 } else {
757 0 Carp::croak(
758 qq{Lockfile '$lockfile' not writable by you. }.
759 qq{Cannot proceed.\n}.
760 qq{ On UNIX try:\n}.
761 qq{ rm '$lockfile'\n}.
762 qq{ and then rerun us.\n}
763 );
764 }
765 } elsif ($^O eq "MSWin32") {
766 0 $CPAN::Frontend->mywarn(
767 qq{
768 There seems to be running another CPAN process according to '$lockfile'.
769 });
770 0 $ask_if_degraded_wanted = 1;
771 } else {
772 0 $CPAN::Frontend->mydie(sprintf("CPAN.pm panic: Found invalid lockfile ".
773 "'$lockfile', please remove. Cannot proceed.\n"));
774 }
775 0 ▶ if ($ask_if_degraded_wanted) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ask_if_degraded_wanted) 0 0 0
if ($ask_if_degraded_wanted) 0 0 0
776 0 my($ans) =
777 CPAN::Shell::colorable_makemaker_prompt
778 (qq{Shall I try to run in downgraded }.
779 qq{mode? (Y/n)},"y");
780 0 ▶ if ($ans =~ /^y/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ans =~ /^y/i) { } 0 0 0
if ($ans =~ /^y/i) { } 0 0 0
781 0 $CPAN::Frontend->mywarn("Running in downgraded mode (experimental).
782 Please report if something unexpected happens\n");
783 0 $RUN_DEGRADED = 1;
784 0 for ($CPAN::Config) {
785 # XXX
786 # $_->{build_dir_reuse} = 0; # 2006-11-17 akoenig Why was that?
787 0 $_->{commandnumber_in_prompt} = 0; # visibility
788 0 $_->{histfile} = ""; # who should win otherwise?
789 0 $_->{cache_metadata} = 0; # better would be a lock?
790 0 $_->{use_sqlite} = 0; # better would be a write lock!
791 0 $_->{auto_commit} = 0; # we are violent, do not persist
792 0 $_->{test_report} = 0; # Oliver Paukstadt had sent wrong reports in degraded mode
793 }
794 } else {
795 0 my $msg = "You may want to kill the other job and delete the lockfile.";
796 0 ▶ if (defined $otherpid) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $otherpid) 0 0 0
if (defined $otherpid) 0 0 0
797 0 $msg .= " Something like:
798 kill $otherpid
799 rm $lockfile
800 ";
801 }
802 0 $CPAN::Frontend->mydie("\n$msg");
803 }
804 }
805 }
806 0 my $dotcpan = $CPAN::Config->{cpan_home};
807 0 eval { File::Path::mkpath($dotcpan);};
808 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
809 # A special case at least for Jarkko.
810 0 my $firsterror = $@;
811 0 my $seconderror;
812 my $symlinkcpan;
813 0 ▶ if (-l $dotcpan) {
Branch: 2 branches
BranchTrueFalseTotal
if (-l $dotcpan) 0 0 0
if (-l $dotcpan) 0 0 0
814 0 $symlinkcpan = readlink $dotcpan;
815 0 ▶ die "readlink $dotcpan failed: $!" unless defined $symlinkcpan;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $symlinkcpan 0 0 0
unless defined $symlinkcpan 0 0 0
816 0 eval { File::Path::mkpath($symlinkcpan); };
817 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) { } 0 0 0
if ($@) { } 0 0 0
818 0 $seconderror = $@;
819 } else {
820 0 $CPAN::Frontend->mywarn(qq{
821 Working directory $symlinkcpan created.
822 });
823 }
824 }
825 0 ▶ unless (-d $dotcpan) {
Branch: 2 branches
BranchTrueFalseTotal
unless (-d $dotcpan) 0 0 0
unless (-d $dotcpan) 0 0 0
826 0 my $mess = qq{
827 Your configuration suggests "$dotcpan" as your
828 CPAN.pm working directory. I could not create this directory due
829 to this error: $firsterror\n};
830 0 ▶ $mess .= qq{
Branch: 2 branches
BranchTrueFalseTotal
if $seconderror 0 0 0
if $seconderror 0 0 0
831 As "$dotcpan" is a symlink to "$symlinkcpan",
832 I tried to create that, but I failed with this error: $seconderror
833 } if $seconderror;
834 0 $mess .= qq{
835 Please make sure the directory exists and is writable.
836 };
837 0 $CPAN::Frontend->mywarn($mess);
838 0 return suggest_myconfig;
839 }
840 } # $@ after eval mkpath $dotcpan
841 0 if (0) { # to test what happens when a race condition occurs
842 for (reverse 1..10) {
843 print $_, "\n";
844 sleep 1;
845 }
846 }
847 # locking
848 0 ▶ if (!$RUN_DEGRADED && !$self->{LOCKFH}) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::RUN_DEGRADED or $self->{"LOCKFH"}) 0 0 0
unless ($CPAN::RUN_DEGRADED or $self->{"LOCKFH"}) 0 0 0
Condition0%0/6
$CPAN::RUN_DEGRADED or $self->{"LOCKFH"}
l!l&&r!l&&!r
000
$CPAN::RUN_DEGRADED or $self->{"LOCKFH"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::RUN_DEGRADED or $self->{"LOCKFH"}
$CPAN::RUN_DEGRADED $self->{"LOCKFH"}
MC/DC0%0/2
$CPAN::RUN_DEGRADED or $self->{"LOCKFH"}
$CPAN::RUN_DEGRADED $self->{"LOCKFH"}
Truth table0%0/3
A or B
A= $CPAN::RUN_DEGRADEDB= $self->{"LOCKFH"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $CPAN::RUN_DEGRADEDB= $self->{"LOCKFH"}
ABresult
1X1
011
000
849 0 my $fh;
850 0 ▶ unless ($fh = FileHandle->new("+>>$lockfile")) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($fh = "FileHandle"->new("+>>$lockfile")) 0 0 0
unless ($fh = "FileHandle"->new("+>>$lockfile")) 0 0 0
851 0 $CPAN::Frontend->mywarn(qq{
852  
853 Your configuration suggests that CPAN.pm should use a working
854 directory of
855 $CPAN::Config->{cpan_home}
856 Unfortunately we could not create the lock file
857 $lockfile
858 due to '$!'.
859  
860 Please make sure that the configuration variable
861 \$CPAN::Config->{cpan_home}
862 points to a directory where you can write a .lock file. You can set
863 this variable in either a CPAN/MyConfig.pm or a CPAN/Config.pm in your
864 \@INC path;
865 });
866 0 return suggest_myconfig;
867 }
868 0 my $sleep = 1;
869 0 ▶ while (!CPAN::_flock($fh, LOCK_EX|LOCK_NB)) {
Branch: 2 branches
BranchTrueFalseTotal
unless (_flock($fh, 6)) 0 0 0
unless (_flock($fh, 6)) 0 0 0
870 0 ▶ my $err = $! || "unknown error";
Condition0%0/4
$! || 'unknown error'
l!l
00
$! || 'unknown error'
l!l
00
MC/DC0%0/1
$! || 'unknown error'
$!
MC/DC0%0/1
$! || 'unknown error'
$!
Truth table0%0/2
A
A= $!
Aresult
11
00
Truth table0%0/2
A
A= $!
Aresult
11
00
871 0 ▶ if ($sleep>3) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sleep > 3) 0 0 0
if ($sleep > 3) 0 0 0
872 0 $CPAN::Frontend->mydie("Could not lock '$lockfile' with flock: $err; giving up\n");
873 }
874 0 $CPAN::Frontend->mysleep($sleep+=0.1);
875 0 $CPAN::Frontend->mywarn("Could not lock '$lockfile' with flock: $err; retrying\n");
876 }
877  
878 0 seek $fh, 0, 0;
879 0 truncate $fh, 0;
880 0 $fh->autoflush(1);
881 0 $fh->print($$, "\n");
882 0 $fh->print(hostname(), "\n");
883 0 $self->{LOCK} = $lockfile;
884 0 $self->{LOCKFH} = $fh;
885 }
886 0 ▶ $SIG{TERM} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
887 0 ▶ my $sig = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
888 0 &cleanup;
889 0 $CPAN::Frontend->mydie("Got SIG$sig, leaving");
890 0 };
891 0 ▶ $SIG{INT} = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
892 # no blocks!!!
893 0 ▶ my $sig = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
894 0 ▶ &cleanup if $Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
895 0 ▶ die "Got yet another signal" if $Signal > 1;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal > 1 0 0 0
if $CPAN::Signal > 1 0 0 0
896 0 ▶ $CPAN::Frontend->mydie("Got another SIG$sig") if $Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
897 0 $CPAN::Frontend->mywarn("Caught SIG$sig, trying to continue\n");
898 0 $Signal++;
899 0 };
900  
901 # From: Larry Wall <larry@wall.org>
902 # Subject: Re: deprecating SIGDIE
903 # To: perl5-porters@perl.org
904 # Date: Thu, 30 Sep 1999 14:58:40 -0700 (PDT)
905 #
906 # The original intent of __DIE__ was only to allow you to substitute one
907 # kind of death for another on an application-wide basis without respect
908 # to whether you were in an eval or not. As a global backstop, it should
909 # not be used any more lightly (or any more heavily :-) than class
910 # UNIVERSAL. Any attempt to build a general exception model on it should
911 # be politely squashed. Any bug that causes every eval {} to have to be
912 # modified should be not so politely squashed.
913 #
914 # Those are my current opinions. It is also my opinion that polite
915 # arguments degenerate to personal arguments far too frequently, and that
916 # when they do, it's because both people wanted it to, or at least didn't
917 # sufficiently want it not to.
918 #
919 # Larry
920  
921 # global backstop to cleanup if we should really die
922 0 $SIG{__DIE__} = \&cleanup;
923 0 ▶ $self->debug("Signal handler set.") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
924 }
925  
926 #-> sub CPAN::DESTROY ;
927 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=6.9
928 0 ▶ &cleanup; # need an eval?
Subroutine DESTROY: not called CC=1 SCAR=6.9
929 }
930  
931 #-> sub CPAN::anycwd ;
932 34 ▶sub anycwd () {
Subroutine anycwd: called CC=2 SCAR=9.2
Pod documented
933 0 ▶ my $getcwd;
Subroutine anycwd: not called CC=2 SCAR=9.2
Pod documented
934 0 ▶ $getcwd = $CPAN::Config->{'getcwd'} || 'cwd';
Condition50%2/4
$CPAN::Config->{'getcwd'} || 'cwd'
l!l
1420
$CPAN::Config->{'getcwd'} || 'cwd'
l!l
00
MC/DC100%1/1
$CPAN::Config->{'getcwd'} || 'cwd'
$CPAN::Config->{'getcwd'}
MC/DC0%0/1
$CPAN::Config->{'getcwd'} || 'cwd'
$CPAN::Config->{'getcwd'}
Truth table100%2/2
A
A= $CPAN::Config->{'getcwd'}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::Config->{'getcwd'}
Aresult
11
00
935 0 CPAN->$getcwd();
936 }
937  
938 #-> sub CPAN::cwd ;
939 34 ▶sub cwd {Cwd::cwd();}
Subroutine cwd: called CC=1 SCAR=0.0
Pod documented
940  
941 #-> sub CPAN::getcwd ;
942 0 ▶sub getcwd {Cwd::getcwd();}
Subroutine getcwd: not called CC=1 SCAR=6.9
Pod documented
943  
944 #-> sub CPAN::fastcwd ;
945 0 ▶sub fastcwd {Cwd::fastcwd();}
Subroutine fastcwd: not called CC=1 SCAR=6.9
Pod documented
946  
947 #-> sub CPAN::getdcwd ;
948 0 ▶sub getdcwd {Cwd::getdcwd();}
Subroutine getdcwd: not called CC=1 SCAR=6.9
Pod documented
949  
950 #-> sub CPAN::backtickcwd ;
951 0 ▶sub backtickcwd {my $cwd = `cwd`; chomp $cwd; $cwd}
Subroutine backtickcwd: not called CC=1 SCAR=6.9
Pod documented
952  
953 # Adapted from Probe::Perl
954 #-> sub CPAN::_perl_is_same
955 0 ▶sub _perl_is_same {
Subroutine _perl_is_same: not called CC=2 SCAR=17.9
956 0 my ($perl) = @_;
957 0 ▶ return MM->maybe_command($perl)
Condition0%0/3
'MM'->maybe_command($perl) && `$perl -MConfig=myconfig -e print -e myconfig` eq 'Config'->myconfig
!ll&&!rl&&r
000
MC/DC0%0/2
'MM'->maybe_command($perl) && `$perl -MConfig=myconfig -e print -e myconfig` eq 'Config'->myconfig
'MM'->maybe_command($perl) `$perl -MConfig=myconfig -e print -e myconfig` eq 'Config'->myconfig
Truth table0%0/3
A && B
A= 'MM'->maybe_command($perl)B= `$perl -MConfig=myconfig -e print -e myconfig` eq 'Config'->myconfig
ABresult
0X0
100
111
958 && `$perl -MConfig=myconfig -e print -e myconfig` eq Config->myconfig;
959 }
960  
961 # Adapted in part from Probe::Perl
962 #-> sub CPAN::find_perl ;
963 68 ▶sub find_perl () {
Subroutine find_perl: called CC=15 SCAR=52.8
Pod undocumented
964 68 ▶ if ( File::Spec->file_name_is_absolute($^X) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('File::Spec'->file_name_is_absolute($^X)) { } 68 0 68
965 68 return $^X;
966 }
967 else {
968 0 my $exe = $Config::Config{exe_ext};
969 my @candidates = (
970 File::Spec->catfile($CPAN::iCwd,$^X),
971 0 $Config::Config{'perlpath'},
972 );
973 0 for my $perl_name ($^X, 'perl', 'perl5', "perl$]") {
974 0 for my $path (File::Spec->path(), $Config::Config{'binexp'}) {
975 0 ▶ if ( defined($path) && length $path && -d $path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $path and length $path and -d $path) 0 0 0
Condition0%0/6
defined $path and length $path and -d $path
!ll&&!rl&&r
000
defined $path and length $path
!ll&&!rl&&r
000
MC/DC0%0/3
defined $path and length $path and -d $path
defined $path length $path -d $path
Truth table0%0/4
A and B and C
A= defined $pathB= length $pathC= -d $path
ABCresult
0XX0
10X0
1100
1111
976 0 my $perl = File::Spec->catfile($path,$perl_name);
977 0 push @candidates, $perl;
978 # try with extension if not provided already
979 0 ▶ if ($^O eq 'VMS') {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O eq 'VMS') { } 0 0 0
elsif (defined $exe and length $exe) { } 0 0 0
980 # VMS might have a file version at the end
981 0 ▶ push @candidates, $perl . $exe
Branch: 1 branch
BranchTrueFalseTotal
unless $perl =~ /$exe(;\d+)?$/i 0 0 0
982 unless $perl =~ m/$exe(;\d+)?$/i;
983 ▶ } elsif (defined $exe && length $exe) {
Condition0%0/3
defined $exe and length $exe
!ll&&!rl&&r
000
MC/DC0%0/2
defined $exe and length $exe
defined $exe length $exe
Truth table0%0/3
A and B
A= defined $exeB= length $exe
ABresult
0X0
100
111
984 0 ▶ push @candidates, $perl . $exe
Branch: 1 branch
BranchTrueFalseTotal
unless $perl =~ /$exe$/i 0 0 0
985 unless $perl =~ m/$exe$/i;
986 }
987 }
988 }
989 }
990 0 for my $perl ( @candidates ) {
991 0 ▶ if (MM->maybe_command($perl) && _perl_is_same($perl)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("MM"->maybe_command($perl) and _perl_is_same($perl)) 0 0 0
Condition0%0/3
"MM"->maybe_command($perl) and _perl_is_same($perl)
!ll&&!rl&&r
000
MC/DC0%0/2
"MM"->maybe_command($perl) and _perl_is_same($perl)
"MM"->maybe_command($perl) _perl_is_same($perl)
Truth table0%0/3
A and B
A= "MM"->maybe_command($perl)B= _perl_is_same($perl)
ABresult
0X0
100
111
992 0 $^X = $perl;
993 0 return $perl;
994 }
995 }
996 }
997 0 return $^X; # default fall back
998 }
999  
1000 #-> sub CPAN::exists ;
1001 163 ▶sub exists {
Subroutine exists: called CC=7 SCAR=21.1
Pod undocumented
1002 163 my($mgr,$class,$id) = @_;
1003 163 ▶ CPAN::HandleConfig->load unless $CPAN::Config_loaded++;
Branch: 1 branch
BranchTrueFalseTotal
unless $CPAN::Config_loaded++ 0 163 163
1004 163 CPAN::Index->reload;
1005 ### Carp::croak "exists called without class argument" unless $class;
1006 163 ▶ $id ||= "";
Condition50%1/2
$id ||= ""
l!l
1630
MC/DC0%0/1
$id ||= ""
$id
Truth table50%1/2
A
A= $id
Aresult
11
00
1007 163 ▶ $id =~ s/:+/::/g if $class eq "CPAN::Module";
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "CPAN::Module" 64 99 163
1008 163 my $exists;
1009 163 ▶ if (CPAN::_sqlite_running) {
Branch: 1 branch
BranchTrueFalseTotal
if (_sqlite_running()) { } 0 163 163
1010 0 ▶ $exists = (exists $META->{readonly}{$class}{$id} or
Condition0%0/3
exists $CPAN::META->{'readonly'}{$class}{$id} || $CPAN::SQLite->set($class, $id)
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $CPAN::META->{'readonly'}{$class}{$id} || $CPAN::SQLite->set($class, $id)
exists $CPAN::META->{'readonly'}{$class}{$id} $CPAN::SQLite->set($class, $id)
Truth table0%0/3
A || B
A= exists $CPAN::META->{'readonly'}{$class}{$id}B= $CPAN::SQLite->set($class, $id)
ABresult
1X1
011
000
1011 $CPAN::SQLite->set($class, $id));
1012 } else {
1013 163 $exists = exists $META->{readonly}{$class}{$id};
1014 }
1015 163 ▶ $exists ||= exists $META->{readwrite}{$class}{$id}; # unsafe meta access, ok
Condition100%3/3
$exists ||= exists $CPAN::META->{"readwrite"}{$class}{$id}
l!l&&r!l&&!r
102457
MC/DC100%2/2
$exists ||= exists $CPAN::META->{"readwrite"}{$class}{$id}
$exists exists $CPAN::META->{"readwrite"}{$class}{$id}
Truth table100%3/3
A ||= B
A= $existsB= exists $CPAN::META->{"readwrite"}{$class}{$id}
ABresult
1X1
011
000
1016 }
1017  
1018 #-> sub CPAN::delete ;
1019 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
Pod undocumented
1020 0 my($mgr,$class,$id) = @_;
1021 0 delete $META->{readonly}{$class}{$id}; # unsafe meta access, ok
1022 0 delete $META->{readwrite}{$class}{$id}; # unsafe meta access, ok
1023 }
1024  
1025 #-> sub CPAN::has_usable
1026 # has_inst is sometimes too optimistic, we should replace it with this
1027 # has_usable whenever a case is given
1028 273 ▶sub has_usable {
Subroutine has_usable: called CC=8 SCAR=34.2
Pod documented
1029 273 my($self,$mod,$message) = @_;
1030 273 ▶ return 1 if $HAS_USABLE->{$mod};
Branch: 1 branch
BranchTrueFalseTotal
if $CPAN::HAS_USABLE->{$mod} 204 69 273
1031 69 my $has_inst = $self->has_inst($mod,$message);
1032 69 ▶ return unless $has_inst;
Branch: 1 branch
BranchTrueFalseTotal
unless $has_inst 13 56 69
1033 56 my $usable;
1034 $usable = {
1035  
1036 #
1037 # most of these subroutines warn on the frontend, then
1038 # die if the installed version is unusable for some
1039 # reason; has_usable() then returns false when it caught
1040 # an exception, otherwise returns true and caches that;
1041 #
1042 'CPAN::Meta' => [
1043 9 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=15.4
1044 9 require CPAN::Meta;
1045 9 ▶ unless (CPAN::Version->vge(CPAN::Meta->VERSION, 2.110350)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("CPAN::Meta"->VERSION, "2.11035")) 0 9 9
1046 0 for ("Will not use CPAN::Meta, need version 2.110350\n") {
1047 0 $CPAN::Frontend->mywarn($_);
1048 0 die $_;
1049 }
1050 }
1051 },
1052 ],
1053  
1054 'CPAN::Meta::Requirements' => [
1055 7 ▶ sub {
Subroutine __ANON__: called CC=5 SCAR=22.7
1056 7 ▶ if (defined $CPAN::Meta::Requirements::VERSION
Branch: 1 branch
BranchTrueFalseTotal
if (defined $CPAN::Meta::Requirements::VERSION and "CPAN::Version"->vlt($CPAN::Meta::Requirements::VERSION, "2.120920")) 0 7 7
Condition33%1/3
defined $CPAN::Meta::Requirements::VERSION and "CPAN::Version"->vlt($CPAN::Meta::Requirements::VERSION, "2.120920")
!ll&&!rl&&r
070
MC/DC0%0/2
defined $CPAN::Meta::Requirements::VERSION and "CPAN::Version"->vlt($CPAN::Meta::Requirements::VERSION, "2.120920")
defined $CPAN::Meta::Requirements::VERSION "CPAN::Version"->vlt($CPAN::Meta::Requirements::VERSION, "2.120920")
Truth table33%1/3
A and B
A= defined $CPAN::Meta::Requirements::VERSIONB= "CPAN::Version"->vlt($CPAN::Meta::Requirements::VERSION, "2.120920")
ABresult
0X0
100
111
1057 && CPAN::Version->vlt($CPAN::Meta::Requirements::VERSION, "2.120920")
1058 ) {
1059 0 delete $INC{"CPAN/Meta/Requirements.pm"};
1060 }
1061 7 require CPAN::Meta::Requirements;
1062 7 ▶ unless (CPAN::Version->vge(CPAN::Meta::Requirements->VERSION, 2.120920)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("CPAN::Meta::Requirements"->VERSION, "2.12092")) 0 7 7
1063 0 for ("Will not use CPAN::Meta::Requirements, need version 2.120920\n") {
1064 0 $CPAN::Frontend->mywarn($_);
1065 0 die $_;
1066 }
1067 }
1068 },
1069 ],
1070  
1071 'CPAN::Reporter' => [
1072 0 ▶ sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1073 0 ▶ if (defined $CPAN::Reporter::VERSION
Branch: 1 branch
BranchTrueFalseTotal
if (defined $CPAN::Reporter::VERSION and "CPAN::Version"->vlt($CPAN::Reporter::VERSION, "1.2011")) 0 0 0
Condition0%0/3
defined $CPAN::Reporter::VERSION and "CPAN::Version"->vlt($CPAN::Reporter::VERSION, "1.2011")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $CPAN::Reporter::VERSION and "CPAN::Version"->vlt($CPAN::Reporter::VERSION, "1.2011")
defined $CPAN::Reporter::VERSION "CPAN::Version"->vlt($CPAN::Reporter::VERSION, "1.2011")
Truth table0%0/3
A and B
A= defined $CPAN::Reporter::VERSIONB= "CPAN::Version"->vlt($CPAN::Reporter::VERSION, "1.2011")
ABresult
0X0
100
111
1074 && CPAN::Version->vlt($CPAN::Reporter::VERSION, "1.2011")
1075 ) {
1076 0 delete $INC{"CPAN/Reporter.pm"};
1077 }
1078 0 require CPAN::Reporter;
1079 0 ▶ unless (CPAN::Version->vge(CPAN::Reporter->VERSION, "1.2011")) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("CPAN::Reporter"->VERSION, "1.2011")) 0 0 0
1080 0 for ("Will not use CPAN::Reporter, need version 1.2011\n") {
1081 0 $CPAN::Frontend->mywarn($_);
1082 0 die $_;
1083 }
1084 }
1085 },
1086 ],
1087  
1088 LWP => [ # we frequently had "Can't locate object
1089 # method "new" via package "LWP::UserAgent" at
1090 # (eval 69) line 2006
1091 0 ▶ sub {require LWP},
Subroutine __ANON__: not called CC=1 SCAR=6.9
1092 0 ▶ sub {require LWP::UserAgent},
Subroutine __ANON__: not called CC=1 SCAR=6.9
1093 0 ▶ sub {require HTTP::Request},
Subroutine __ANON__: not called CC=1 SCAR=6.9
1094 0 ▶ sub {require URI::URL;
Subroutine __ANON__: not called CC=3 SCAR=24.8
1095 0 ▶ unless (CPAN::Version->vge(URI::URL::->VERSION,0.08)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("URI::URL"->VERSION, "0.08")) 0 0 0
1096 0 for ("Will not use URI::URL, need 0.08\n") {
1097 0 $CPAN::Frontend->mywarn($_);
1098 0 die $_;
1099 }
1100 }
1101 },
1102 ],
1103 'Net::FTP' => [
1104 0 ▶ sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1105 0 ▶ my $var = $CPAN::Config->{ftp_proxy} || $ENV{ftp_proxy};
Condition0%0/3
$CPAN::Config->{'ftp_proxy'} || $ENV{'ftp_proxy'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{'ftp_proxy'} || $ENV{'ftp_proxy'}
$CPAN::Config->{'ftp_proxy'} $ENV{'ftp_proxy'}
Truth table0%0/3
A || B
A= $CPAN::Config->{'ftp_proxy'}B= $ENV{'ftp_proxy'}
ABresult
1X1
011
000
1106 0 ▶ if ($var and $var =~ /^http:/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($var and $var =~ /^http:/i) 0 0 0
Condition0%0/3
$var and $var =~ /^http:/i
!ll&&!rl&&r
000
MC/DC0%0/2
$var and $var =~ /^http:/i
$var $var =~ /^http:/i
Truth table0%0/3
A and B
A= $varB= $var =~ /^http:/i
ABresult
0X0
100
111
1107 # rt #110833
1108 0 for ("Net::FTP cannot handle http proxy") {
1109 0 $CPAN::Frontend->mywarn($_);
1110 0 die $_;
1111 }
1112 }
1113 },
1114 0 ▶ sub {require Net::FTP},
Subroutine __ANON__: not called CC=1 SCAR=6.9
1115 0 ▶ sub {require Net::Config},
Subroutine __ANON__: not called CC=1 SCAR=6.9
1116 ],
1117 'IO::Socket::SSL' => [
1118 0 ▶ sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1119 0 require IO::Socket::SSL;
1120 0 ▶ unless (CPAN::Version->vge(IO::Socket::SSL::->VERSION,1.56)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("IO::Socket::SSL"->VERSION, "1.56")) 0 0 0
1121 0 for ("Will not use IO::Socket::SSL, need 1.56\n") {
1122 0 $CPAN::Frontend->mywarn($_);
1123 0 die $_;
1124 }
1125 }
1126 }
1127 ],
1128 'Net::SSLeay' => [
1129 0 ▶ sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1130 0 require Net::SSLeay;
1131 0 ▶ unless (CPAN::Version->vge(Net::SSLeay::->VERSION,1.49)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("Net::SSLeay"->VERSION, "1.49")) 0 0 0
1132 0 for ("Will not use Net::SSLeay, need 1.49\n") {
1133 0 $CPAN::Frontend->mywarn($_);
1134 0 die $_;
1135 }
1136 }
1137 }
1138 ],
1139 'HTTP::Tiny' => [
1140 0 ▶ sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1141 0 require HTTP::Tiny;
1142 0 ▶ unless (CPAN::Version->vge(HTTP::Tiny->VERSION, 0.005)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("HTTP::Tiny"->VERSION, "0.005")) 0 0 0
1143 0 for ("Will not use HTTP::Tiny, need version 0.005\n") {
1144 0 $CPAN::Frontend->mywarn($_);
1145 0 die $_;
1146 }
1147 }
1148 },
1149 ],
1150 'File::HomeDir' => [
1151 0 ▶ sub {require File::HomeDir;
Subroutine __ANON__: not called CC=3 SCAR=24.8
1152 0 ▶ unless (CPAN::Version->vge(File::HomeDir::->VERSION, 0.52)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("File::HomeDir"->VERSION, "0.52")) 0 0 0
1153 0 for ("Will not use File::HomeDir, need 0.52\n") {
1154 0 $CPAN::Frontend->mywarn($_);
1155 0 die $_;
1156 }
1157 }
1158 },
1159 ],
1160 'Archive::Tar' => [
1161 8 ▶ sub {require Archive::Tar;
Subroutine __ANON__: called CC=3 SCAR=14.2
1162 8 my $demand = "1.50";
1163 8 ▶ unless (CPAN::Version->vge(Archive::Tar::->VERSION, $demand)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("Archive::Tar"->VERSION, $demand)) 0 8 8
1164 0 my $atv = Archive::Tar->VERSION;
1165 0 for ("You have Archive::Tar $atv, but $demand or later is recommended. Please upgrade.\n") {
1166 0 $CPAN::Frontend->mywarn($_);
1167 # don't die, because we may need
1168 # Archive::Tar to upgrade
1169 }
1170  
1171 }
1172 },
1173 ],
1174 'File::Temp' => [
1175 # XXX we should probably delete from
1176 # %INC too so we can load after we
1177 # installed a new enough version --
1178 # I'm not sure.
1179 0 ▶ sub {require File::Temp;
Subroutine __ANON__: not called CC=3 SCAR=24.8
1180 0 ▶ unless (CPAN::Version->vge(File::Temp::->VERSION,0.16)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("CPAN::Version"->vge("File::Temp"->VERSION, "0.16")) 0 0 0
1181 0 for ("Will not use File::Temp, need 0.16\n") {
1182 0 $CPAN::Frontend->mywarn($_);
1183 0 die $_;
1184 }
1185 }
1186 },
1187 56 ]
1188 };
1189 56 ▶ if ($usable->{$mod}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($usable->{$mod}) 24 32 56
1190 24 local @INC = @INC;
1191 24 ▶ pop @INC if $INC[-1] eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if $INC[-1] eq "." 0 24 24
1192 24 for my $c (0..$#{$usable->{$mod}}) {
1193 24 my $code = $usable->{$mod}[$c];
1194 24 my $ret = eval { &$code() };
1195 24 ▶ $ret = "" unless defined $ret;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ret 0 24 24
1196 24 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 24 24
1197 # warn "DEBUG: c[$c]\$\@[$@]ret[$ret]";
1198 0 return;
1199 }
1200 }
1201 }
1202 56 return $HAS_USABLE->{$mod} = 1;
1203 }
1204  
1205 0 ▶sub frontend {
Subroutine frontend: not called CC=2 SCAR=17.9
Pod documented
1206 0 shift;
1207 0 ▶ $CPAN::Frontend = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
1208 0 $CPAN::Frontend;
1209 }
1210  
1211 14 ▶sub use_inst {
Subroutine use_inst: called CC=2 SCAR=8.1
Pod documented
1212 14 my ($self, $module) = @_;
1213  
1214 14 ▶ unless ($self->has_inst($module)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_inst($module)) 0 14 14
1215 0 $self->frontend->mydie("$module not installed, cannot continue");
1216 }
1217 }
1218  
1219 #-> sub CPAN::has_inst
1220 795 ▶sub has_inst {
Subroutine has_inst: called CC=24 SCAR=42.2
Pod documented
1221 795 my($self,$mod,$message) = @_;
1222 795 ▶ Carp::croak("CPAN->has_inst() called without an argument")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mod 0 795 795
1223 unless defined $mod;
1224 15 ▶ my %dont = map { $_ => 1 } keys %{$CPAN::META->{dontload_hash}||{}},
Condition100%2/2
$CPAN::META->{'dontload_hash'} || {}
l!l
7788
MC/DC100%1/1
$CPAN::META->{'dontload_hash'} || {}
$CPAN::META->{'dontload_hash'}
Truth table100%2/2
A
A= $CPAN::META->{'dontload_hash'}
Aresult
11
00
1225 795 ▶ keys %{$CPAN::Config->{dontload_hash}||{}},
Condition100%2/2
$CPAN::Config->{'dontload_hash'} || {}
l!l
669126
MC/DC100%1/1
$CPAN::Config->{'dontload_hash'} || {}
$CPAN::Config->{'dontload_hash'}
Truth table100%2/2
A
A= $CPAN::Config->{'dontload_hash'}
Aresult
11
00
1226 795 ▶ @{$CPAN::Config->{dontload_list}||[]};
Condition50%1/2
$CPAN::Config->{'dontload_list'} || []
l!l
0795
MC/DC0%0/1
$CPAN::Config->{'dontload_list'} || []
$CPAN::Config->{'dontload_list'}
Truth table50%1/2
A
A= $CPAN::Config->{'dontload_list'}
Aresult
11
00
1227 795 ▶ if (defined $message && $message eq "no" # as far as I remember only used by Nox
Branch: 1 branch
BranchTrueFalseTotal
if (defined $message and $message eq "no" or $dont{$mod}) 9 786 795
Condition83%5/6
defined $message and $message eq "no" or $dont{$mod}
l!l&&r!l&&!r
63786
defined $message and $message eq "no"
!ll&&!rl&&r
78906
MC/DC66%2/3
defined $message and $message eq "no" or $dont{$mod}
defined $message $message eq "no" $dont{$mod}
Truth table60%3/5
A and B or C
A= defined $messageB= $message eq "no"C= $dont{$mod}
ABCresult
11X1
0X11
1011
0X00
1000
1228 ||
1229 $dont{$mod}
1230 ) {
1231 9 ▶ $CPAN::META->{dontload_hash}{$mod}||=1; # unsafe meta access, ok
Condition100%2/2
$CPAN::META->{"dontload_hash"}{$mod} ||= 1
l!l
36
MC/DC100%1/1
$CPAN::META->{"dontload_hash"}{$mod} ||= 1
$CPAN::META->{"dontload_hash"}{$mod}
Truth table100%2/2
A
A= $CPAN::META->{"dontload_hash"}{$mod}
Aresult
11
00
1232 9 return 0;
1233 }
1234 786 local @INC = @INC;
1235 786 ▶ pop @INC if $INC[-1] eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if $INC[-1] eq "." 0 786 786
1236 786 my $file = $mod;
1237 786 my $obj;
1238 786 $file =~ s|::|/|g;
1239 786 $file .= ".pm";
1240 786 ▶ if ($INC{$file}) {
Branch: 5 branches
BranchTrueFalseTotal
if ($INC{$file}) { } 692 94 786
elsif (eval { do { require $file } }) { } 69 25 94
elsif ($mod eq 'Net::FTP') { } 0 25 25
elsif ($mod eq 'Digest::SHA') { } 0 25 25
elsif ($mod eq 'Module::Signature') { } 0 25 25
1241 # checking %INC is wrong, because $INC{LWP} may be true
1242 # although $INC{"URI/URL.pm"} may have failed. But as
1243 # I really want to say "blah loaded OK", I have to somehow
1244 # cache results.
1245 ### warn "$file in %INC"; #debug
1246 692 return 1;
1247 94 } elsif (eval { require $file }) {
1248 # eval is good: if we haven't yet read the database it's
1249 # perfect and if we have installed the module in the meantime,
1250 # it tries again. The second require is only a NOOP returning
1251 # 1 if we had success, otherwise it's retrying
1252  
1253 69 my $mtime = (stat $INC{$file})[9];
1254 # privileged files loaded by has_inst; Note: we use $mtime
1255 # as a proxy for a checksum.
1256 69 $CPAN::Shell::reload->{$file} = $mtime;
1257 69 my $v = eval "\$$mod\::VERSION";
1258 69 ▶ $v = $v ? " (v$v)" : "";
Branch: 1 branch
BranchTrueFalseTotal
$v ? : 69 0 69
1259 69 CPAN::Shell->optprint("load_module","CPAN: $mod loaded ok$v\n");
1260 69 ▶ if ($mod eq "CPAN::WAIT") {
Branch: 1 branch
BranchTrueFalseTotal
if ($mod eq "CPAN::WAIT") 0 69 69
1261 0 push @CPAN::Shell::ISA, 'CPAN::WAIT';
1262 }
1263 69 return 1;
1264 } elsif ($mod eq "Net::FTP") {
1265 $CPAN::Frontend->mywarn(qq{
1266 Please, install Net::FTP as soon as possible. CPAN.pm installs it for you
1267 if you just type
1268 install Bundle::libnet
1269  
1270 0 ▶}) unless $Have_warned->{"Net::FTP"}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $CPAN::Have_warned->{"Net::FTP"}++ 0 0 0
1271 0 $CPAN::Frontend->mysleep(3);
1272 } elsif ($mod eq "Digest::SHA") {
1273 0 ▶ if ($Have_warned->{"Digest::SHA"}++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPAN::Have_warned->{'Digest::SHA'}++) { } 0 0 0
1274 0 $CPAN::Frontend->mywarn(qq{CPAN: checksum security checks disabled }.
1275 qq{because Digest::SHA not installed.\n});
1276 } else {
1277 0 $CPAN::Frontend->mywarn(qq{
1278 CPAN: checksum security checks disabled because Digest::SHA not installed.
1279 Please consider installing the Digest::SHA module.
1280  
1281 });
1282 0 $CPAN::Frontend->mysleep(2);
1283 }
1284 } elsif ($mod eq "Module::Signature") {
1285 # NOT prefs_lookup, we are not a distro
1286 0 my $check_sigs = $CPAN::Config->{check_sigs};
1287 0 ▶ if (not $check_sigs) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $check_sigs) { } 0 0 0
elsif (not $CPAN::Have_warned->{'Module::Signature'}++) { } 0 0 0
1288 # they do not want us:-(
1289 } elsif (not $Have_warned->{"Module::Signature"}++) {
1290 # No point in complaining unless the user can
1291 # reasonably install and use it.
1292 0 ▶ if (eval { require Crypt::OpenPGP; 1 } ||
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Crypt::OpenPGP; 1 } } or defined $CPAN::Config->{"gpg"} and $CPAN::Config->{"gpg"} =~ /\S/) 0 0 0
Condition0%0/6
eval { do { require Crypt::OpenPGP; 1 } } or defined $CPAN::Config->{"gpg"} and $CPAN::Config->{"gpg"} =~ /\S/
l!l&&r!l&&!r
000
defined $CPAN::Config->{"gpg"} and $CPAN::Config->{"gpg"} =~ /\S/
!ll&&!rl&&r
000
MC/DC0%0/3
eval { do { require Crypt::OpenPGP; 1 } } or defined $CPAN::Config->{"gpg"} and $CPAN::Config->{"gpg"} =~ /\S/
eval { do { require Crypt::OpenPGP; 1 } } defined $CPAN::Config->{"gpg"} $CPAN::Config->{"gpg"} =~ /\S/
Truth table0%0/4
A or B and C
A= eval { do { require Crypt::OpenPGP; 1 } }B= defined $CPAN::Config->{"gpg"}C= $CPAN::Config->{"gpg"} =~ /\S/
ABCresult
1XX1
0111
00X0
0100
1293 (
1294 defined $CPAN::Config->{'gpg'}
1295 &&
1296 $CPAN::Config->{'gpg'} =~ /\S/
1297 )
1298 ) {
1299 0 $CPAN::Frontend->mywarn(qq{
1300 CPAN: Module::Signature security checks disabled because Module::Signature
1301 not installed. Please consider installing the Module::Signature module.
1302 You may also need to be able to connect over the Internet to the public
1303 key servers like pool.sks-keyservers.net or pgp.mit.edu.
1304  
1305 });
1306 0 $CPAN::Frontend->mysleep(2);
1307 }
1308 }
1309 } else {
1310 25 delete $INC{$file}; # if it inc'd LWP but failed during, say, URI
1311 }
1312 25 return 0;
1313 }
1314  
1315 #-> sub CPAN::instance ;
1316 200 ▶sub instance {
Subroutine instance: called CC=4 SCAR=14.5
Pod documented
1317 200 my($mgr,$class,$id) = @_;
1318 200 CPAN::Index->reload;
1319 200 ▶ $id ||= "";
Condition50%1/2
$id ||= ""
l!l
2000
MC/DC0%0/1
$id ||= ""
$id
Truth table50%1/2
A
A= $id
Aresult
11
00
1320 # unsafe meta access, ok?
1321 200 ▶ return $META->{readwrite}{$class}{$id} if exists $META->{readwrite}{$class}{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $CPAN::META->{"readwrite"}{$class}{$id} 98 102 200
1322 102 ▶ $META->{readwrite}{$class}{$id} ||= $class->new(ID => $id);
Condition33%1/3
$CPAN::META->{"readwrite"}{$class}{$id} ||= $class->new("ID", $id)
l!l&&r!l&&!r
01020
MC/DC0%0/2
$CPAN::META->{"readwrite"}{$class}{$id} ||= $class->new("ID", $id)
$CPAN::META->{"readwrite"}{$class}{$id} $class->new("ID", $id)
Truth table33%1/3
A ||= B
A= $CPAN::META->{"readwrite"}{$class}{$id}B= $class->new("ID", $id)
ABresult
1X1
011
000
1323 }
1324  
1325 #-> sub CPAN::new ;
1326 26 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
1327 26 bless {}, shift;
1328 }
1329  
1330 #-> sub CPAN::_exit_messages ;
1331 0 ▶sub _exit_messages {
Subroutine _exit_messages: not called CC=2 SCAR=17.9
1332 0 my ($self) = @_;
1333 0 ▶ $self->{exit_messages} ||= [];
Condition0%0/2
$self->{"exit_messages"} ||= []
l!l
00
MC/DC0%0/1
$self->{"exit_messages"} ||= []
$self->{"exit_messages"}
Truth table0%0/2
A
A= $self->{"exit_messages"}
Aresult
11
00
1334 }
1335  
1336 #-> sub CPAN::cleanup ;
1337 26 ▶sub cleanup {
Subroutine cleanup: called CC=10 SCAR=34.7
Pod undocumented
1338 # warn "cleanup called with arg[@_] End[$CPAN::End] Signal[$Signal]";
1339 26 local $SIG{__DIE__} = '';
1340 26 my($message) = @_;
1341 26 my $i = 0;
1342 26 my $ineval = 0;
1343 26 my($subroutine);
1344 26 ▶ while ((undef,undef,undef,$subroutine) = caller(++$i)) {
Branch: 1 branch
BranchTrueFalseTotal
if ((undef, undef, undef, $subroutine) = caller ++$i) 52 0 52
1345 52 ▶ $ineval = 1, last if
Branch: 1 branch
BranchTrueFalseTotal
if $subroutine eq "(eval)" 26 26 52
1346 $subroutine eq '(eval)';
1347 }
1348 26 ▶ return if $ineval && !$CPAN::End;
Branch: 1 branch
BranchTrueFalseTotal
if $ineval and not $CPAN::End 0 26 26
Condition33%1/3
$ineval and not $CPAN::End
!ll&&!rl&&r
0260
MC/DC0%0/2
$ineval and not $CPAN::End
$ineval not $CPAN::End
Truth table33%1/3
A and not(B)
A= $inevalB= not $CPAN::End
ABresult
0X0
100
111
1349 26 ▶ return unless defined $META->{LOCK};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $CPAN::META->{"LOCK"} 26 0 26
1350 0 ▶ return unless -f $META->{LOCK};
Branch: 1 branch
BranchTrueFalseTotal
unless -f $CPAN::META->{"LOCK"} 0 0 0
1351 0 $META->savehist;
1352 0 ▶ $META->{cachemgr} ||= CPAN::CacheMgr->new('atexit');
Condition0%0/3
$CPAN::META->{"cachemgr"} ||= "CPAN::CacheMgr"->new("atexit")
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::META->{"cachemgr"} ||= "CPAN::CacheMgr"->new("atexit")
$CPAN::META->{"cachemgr"} "CPAN::CacheMgr"->new("atexit")
Truth table0%0/3
A ||= B
A= $CPAN::META->{"cachemgr"}B= "CPAN::CacheMgr"->new("atexit")
ABresult
1X1
011
000
1353 0 close $META->{LOCKFH};
1354 0 unlink $META->{LOCK};
1355 # require Carp;
1356 # Carp::cluck("DEBUGGING");
1357 0 ▶ if ( $CPAN::CONFIG_DIRTY ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPAN::CONFIG_DIRTY) 0 0 0
1358 0 $CPAN::Frontend->mywarn("Warning: Configuration not saved.\n");
1359 }
1360 0 $CPAN::Frontend->myprint("Lockfile removed.\n");
1361 0 for my $msg ( @{ $META->_exit_messages } ) {
1362 0 $CPAN::Frontend->myprint($msg);
1363 }
1364 }
1365  
1366 #-> sub CPAN::readhist
1367 0 ▶sub readhist {
Subroutine readhist: not called CC=5 SCAR=34.0
Pod undocumented
1368 0 my($self,$term,$histfile) = @_;
1369 0 ▶ my $histsize = $CPAN::Config->{'histsize'} || 100;
Condition0%0/2
$CPAN::Config->{'histsize'} || 100
l!l
00
MC/DC0%0/1
$CPAN::Config->{'histsize'} || 100
$CPAN::Config->{'histsize'}
Truth table0%0/2
A
A= $CPAN::Config->{'histsize'}
Aresult
11
00
1370 0 ▶ $term->Attribs->{'MaxHistorySize'} = $histsize if (defined($term->Attribs->{'MaxHistorySize'}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $term->Attribs->{"MaxHistorySize"} 0 0 0
1371 0 my($fh) = FileHandle->new;
1372 0 ▶ open $fh, "<$histfile" or return;
Branch: 1 branch
BranchTrueFalseTotal
open $fh, "<$histfile" or return 0 0 0
1373 0 local $/ = "\n";
1374 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
1375 0 chomp;
1376 0 $term->AddHistory($_);
1377 }
1378 0 close $fh;
1379 }
1380  
1381 #-> sub CPAN::savehist
1382 0 ▶sub savehist {
Subroutine savehist: not called CC=7 SCAR=40.3
Pod undocumented
1383 0 my($self) = @_;
1384 0 my($histfile,$histsize);
1385 0 ▶ unless ($histfile = $CPAN::Config->{'histfile'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($histfile = $CPAN::Config->{"histfile"}) 0 0 0
1386 0 $CPAN::Frontend->mywarn("No history written (no histfile specified).\n");
1387 0 return;
1388 }
1389 0 ▶ $histsize = $CPAN::Config->{'histsize'} || 100;
Condition0%0/2
$CPAN::Config->{'histsize'} || 100
l!l
00
MC/DC0%0/1
$CPAN::Config->{'histsize'} || 100
$CPAN::Config->{'histsize'}
Truth table0%0/2
A
A= $CPAN::Config->{'histsize'}
Aresult
11
00
1390 0 ▶ if ($CPAN::term) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPAN::term) { } 0 0 0
1391 0 ▶ unless ($CPAN::term->can("GetHistory")) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::term->can("GetHistory")) 0 0 0
1392 0 $CPAN::Frontend->mywarn("Terminal does not support GetHistory.\n");
1393 0 return;
1394 }
1395 } else {
1396 0 return;
1397 }
1398 0 my @h = $CPAN::term->GetHistory;
1399 0 ▶ splice @h, 0, @h-$histsize if @h>$histsize;
Branch: 1 branch
BranchTrueFalseTotal
if @h > $histsize 0 0 0
1400 0 my($fh) = FileHandle->new;
1401 0 ▶ open $fh, ">$histfile" or $CPAN::Frontend->mydie("Couldn't open >$histfile: $!");
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">$histfile" or $CPAN::Frontend->mydie("Couldn't open >${histfile}: $!") 0 0 0
1402 0 local $\ = local $, = "\n";
1403 0 print $fh @h;
1404 0 close $fh;
1405 }
1406  
1407 #-> sub CPAN::is_tested
1408 1 ▶sub is_tested {
Subroutine is_tested: called CC=2 SCAR=8.4
Pod documented
1409 1 my($self,$what,$when) = @_;
1410 1 ▶ unless ($what) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($what) 0 1 1
1411 0 Carp::cluck("DEBUG: empty what");
1412 0 return;
1413 }
1414 1 $self->{is_tested}{$what} = $when;
1415 }
1416  
1417 #-> sub CPAN::reset_tested
1418 # forget all distributions tested -- resets what gets included in PERL5LIB
1419 0 ▶sub reset_tested {
Subroutine reset_tested: not called CC=1 SCAR=6.9
Pod undocumented
1420 0 my ($self) = @_;
1421 0 $self->{is_tested} = {};
1422 }
1423  
1424 #-> sub CPAN::is_installed
1425 # unsets the is_tested flag: as soon as the thing is installed, it is
1426 # not needed in set_perl5lib anymore
1427 1 ▶sub is_installed {
Subroutine is_installed: called CC=1 SCAR=0.0
Pod undocumented
1428 1 my($self,$what) = @_;
1429 1 delete $self->{is_tested}{$what};
1430 }
1431  
1432 1 ▶sub _list_sorted_descending_is_tested {
Subroutine _list_sorted_descending_is_tested: called CC=10 SCAR=38.3
1433 1 my($self) = @_;
1434 1 my $foul = 0;
1435 my @sorted = sort
1436 0 ▶ { ($self->{is_tested}{$b}||0) <=> ($self->{is_tested}{$a}||0) }
Condition0%0/4
$self->{'is_tested'}{$b} || 0
l!l
00
$self->{'is_tested'}{$a} || 0
l!l
00
MC/DC0%0/1
$self->{'is_tested'}{$b} || 0
$self->{'is_tested'}{$b}
MC/DC0%0/1
$self->{'is_tested'}{$a} || 0
$self->{'is_tested'}{$a}
Truth table0%0/2
A
A= $self->{'is_tested'}{$b}
Aresult
11
00
Truth table0%0/2
A
A= $self->{'is_tested'}{$a}
Aresult
11
00
1437 grep
1438 0 ▶ { if ($foul){ 0 } elsif (-e) { 1 } else { $foul = $_; 0 } }
Branch: 2 branches
BranchTrueFalseTotal
if ($foul) { } 0 1 1
elsif (-e $_) { } 1 0 1
1439 1 keys %{$self->{is_tested}};
1440 1 ▶ if ($foul) {
Branch: 1 branch
BranchTrueFalseTotal
if ($foul) { } 0 1 1
1441 0 $CPAN::Frontend->mywarn("Lost build_dir detected ($foul), giving up all cached test results of currently running session.\n");
1442 0 for my $dbd (sort keys %{$self->{is_tested}}) { # distro-build-dir
1443 0 SEARCH: for my $d (sort { $a->id cmp $b->id } $CPAN::META->all_objects("CPAN::Distribution")) {
1444 0 ▶ if ($d->{build_dir} && $d->{build_dir} eq $dbd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d->{"build_dir"} and $d->{"build_dir"} eq $dbd) 0 0 0
Condition0%0/3
$d->{"build_dir"} and $d->{"build_dir"} eq $dbd
!ll&&!rl&&r
000
MC/DC0%0/2
$d->{"build_dir"} and $d->{"build_dir"} eq $dbd
$d->{"build_dir"} $d->{"build_dir"} eq $dbd
Truth table0%0/3
A and B
A= $d->{"build_dir"}B= $d->{"build_dir"} eq $dbd
ABresult
0X0
100
111
1445 0 $CPAN::Frontend->mywarn(sprintf "Flushing cache for %s\n", $d->pretty_id);
1446 0 $d->fforce("");
1447 0 last SEARCH;
1448 }
1449 }
1450 0 delete $self->{is_tested}{$dbd};
1451 }
1452 0 return ();
1453 } else {
1454 1 return @sorted;
1455 }
1456 }
1457  
1458 #-> sub CPAN::set_perl5lib
1459 # Notes on max environment variable length:
1460 # - Win32 : XP or later, 8191; Win2000 or NT4, 2047
1461 {
1462 26 my $fh;
1463 23 ▶sub set_perl5lib {
Subroutine set_perl5lib: called CC=10 SCAR=28.7
Pod undocumented
1464 23 my($self,$for) = @_;
1465 23 ▶ unless ($for) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($for) 23 0 23
1466 23 (undef,undef,undef,$for) = caller(1);
1467 23 $for =~ s/.*://;
1468 }
1469 23 ▶ $self->{is_tested} ||= {};
Condition100%2/2
$self->{"is_tested"} ||= {}
l!l
167
MC/DC100%1/1
$self->{"is_tested"} ||= {}
$self->{"is_tested"}
Truth table100%2/2
A
A= $self->{"is_tested"}
Aresult
11
00
1470 23 ▶ return unless %{$self->{is_tested}};
Branch: 1 branch
BranchTrueFalseTotal
unless %{$self->{"is_tested"};} 22 1 23
1471 1 my $env = $ENV{PERL5LIB};
1472 1 ▶ $env = $ENV{PERLLIB} unless defined $env;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $env 0 1 1
1473 1 my @env;
1474 1 ▶ push @env, split /\Q$Config::Config{path_sep}\E/, $env if defined $env and length $env;
Branch: 1 branch
BranchTrueFalseTotal
if defined $env and length $env 1 0 1
Condition33%1/3
defined $env and length $env
!ll&&!rl&&r
001
MC/DC0%0/2
defined $env and length $env
defined $env length $env
Truth table33%1/3
A and B
A= defined $envB= length $env
ABresult
0X0
100
111
1475 #my @dirs = map {("$_/blib/arch", "$_/blib/lib")} keys %{$self->{is_tested}};
1476 #$CPAN::Frontend->myprint("Prepending @dirs to PERL5LIB.\n");
1477  
1478 1 my @dirs = map {("$_/blib/arch", "$_/blib/lib")} $self->_list_sorted_descending_is_tested;
1479 1 ▶ return if !@dirs;
Branch: 1 branch
BranchTrueFalseTotal
unless @dirs 0 1 1
1480  
1481 1 ▶ if (@dirs < 12) {
Branch: 2 branches
BranchTrueFalseTotal
if (@dirs < 12) { } 1 0 1
elsif (@dirs < 24) { } 0 0 0
1482 1 $CPAN::Frontend->optprint('perl5lib', "Prepending @dirs to PERL5LIB for '$for'\n");
1483 1 $ENV{PERL5LIB} = join $Config::Config{path_sep}, @dirs, @env;
1484 } elsif (@dirs < 24 ) {
1485 0 my @d = map {my $cp = $_;
1486 0 $cp =~ s/^\Q$CPAN::Config->{build_dir}\E/%BUILDDIR%/;
1487 0 $cp
1488 } @dirs;
1489 0 $CPAN::Frontend->optprint('perl5lib', "Prepending @d to PERL5LIB; ".
1490 "%BUILDDIR%=$CPAN::Config->{build_dir} ".
1491 "for '$for'\n"
1492 );
1493 0 $ENV{PERL5LIB} = join $Config::Config{path_sep}, @dirs, @env;
1494 } else {
1495 0 my $cnt = keys %{$self->{is_tested}};
1496 0 my $newenv = join $Config::Config{path_sep}, @dirs, @env;
1497 0 $CPAN::Frontend->optprint('perl5lib', sprintf ("Prepending blib/arch and blib/lib of ".
1498 "%d build dirs to PERL5LIB, reaching size %d; ".
1499 "for '%s'\n", $cnt, length($newenv), $for)
1500 );
1501 0 $ENV{PERL5LIB} = $newenv;
1502 }
1503 }}
1504  
1505  
1506 26 1;
1507  
1508  
1509 __END__
« blib/lib/CPAN/FTP.pm ↑ Summary blib/lib/CPAN/FirstTime.pm »