PAR/SetupProgname.pm

filter: Statementstmt 58.0% 18 / 31 Branchbran 33.3% 6 / 18 Conditioncond 33.3% 3 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 47.1% 33 / 70 SCAR 37.8
CC
14
Cov
47%
set_progname
70.2
BEGIN
1.0
BEGIN
1.0
CRAP 43.9
« PAR/SetupTemp.pm ↑ Summary
1 package PAR::SetupProgname;
2 $PAR::SetupProgname::VERSION = '1.002';
3  
4 8 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 PAR::SetupProgname - Setup $ENV{PAR_PROGNAME}
12  
13 =head1 SYNOPSIS
14  
15 PAR guts, beware. Check L<PAR>
16  
17 =head1 DESCRIPTION
18  
19 Routines to setup the C<PAR_PROGNAME> environment variable.
20 Read the C<PAR::Environment> manual.
21  
22 The C<set_progname()> subroutine sets up the C<PAR_PROGNAME>
23 environment variable
24  
25 =cut
26  
27 # for PAR internal use only!
28 our $Progname = $ENV{PAR_PROGNAME} || $0;
29  
30 # same code lives in PAR::Packer's par.pl!
31 sub set_progname {
32 7 ▶ require File::Spec;
Subroutine set_progname: called CC=14 SCAR=42.5
Pod undocumented
33  
34 7 ▶ if (defined $ENV{PAR_PROGNAME} and $ENV{PAR_PROGNAME} =~ /(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/) 3 4 7
Condition66%2/3
defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/
!ll&&!rl&&r
403
MC/DC50%1/2
defined $ENV{"PAR_PROGNAME"} and $ENV{"PAR_PROGNAME"} =~ /(.+)/
defined $ENV{"PAR_PROGNAME"} $ENV{"PAR_PROGNAME"} =~ /(.+)/
Truth table66%2/3
A and B
A= defined $ENV{"PAR_PROGNAME"}B= $ENV{"PAR_PROGNAME"} =~ /(.+)/
ABresult
0X0
100
111
35 3 $Progname = $1;
36 }
37 7 ▶ $Progname = $0 if not defined $Progname;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $PAR::SetupProgname::Progname 0 7 7
38  
39 7 ▶ if (( () = File::Spec->splitdir($Progname) ) > 1 or !$ENV{PAR_PROGNAME}) {
Branch: 1 branch
BranchTrueFalseTotal
if ((() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1 or not $ENV{"PAR_PROGNAME"}) 7 0 7
Condition33%1/3
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1 or not $ENV{"PAR_PROGNAME"}
l!l&&r!l&&!r
700
MC/DC0%0/2
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1 or not $ENV{"PAR_PROGNAME"}
(() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1 not $ENV{"PAR_PROGNAME"}
Truth table33%1/3
A or not(B)
A= (() = "File::Spec"->splitdir($PAR::SetupProgname::Progname)) > 1B= not $ENV{"PAR_PROGNAME"}
ABresult
1X1
011
000
40 7 ▶ if (open my $fh, $Progname) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, $PAR::SetupProgname::Progname) 7 0 7
41 7 ▶ return if -s $fh;
Branch: 1 branch
BranchTrueFalseTotal
if -s $fh 7 0 7
42 }
43 0 ▶ if (-s "$Progname$Config{_exe}") {
Branch: 1 branch
BranchTrueFalseTotal
if (-s qq[$PAR::SetupProgname::Progname$PAR::SetupProgname::Config{"_exe"}]) 0 0 0
44 0 $Progname .= $Config{_exe};
45 0 return;
46 }
47 }
48  
49 0 foreach my $dir (split /\Q$Config{path_sep}\E/, $ENV{PATH}) {
50 0 ▶ next if exists $ENV{PAR_TEMP} and $dir eq $ENV{PAR_TEMP};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ENV{"PAR_TEMP"} and $dir eq $ENV{"PAR_TEMP"} 0 0 0
Condition0%0/3
exists $ENV{"PAR_TEMP"} and $dir eq $ENV{"PAR_TEMP"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"PAR_TEMP"} and $dir eq $ENV{"PAR_TEMP"}
exists $ENV{"PAR_TEMP"} $dir eq $ENV{"PAR_TEMP"}
Truth table0%0/3
A and B
A= exists $ENV{"PAR_TEMP"}B= $dir eq $ENV{"PAR_TEMP"}
ABresult
0X0
100
111
51 0 my $name = File::Spec->catfile($dir, "$Progname$Config{_exe}");
52 0 ▶ if (-s $name) { $Progname = $name; last }
Branch: 1 branch
BranchTrueFalseTotal
if (-s $name) 0 0 0
53 0 $name = File::Spec->catfile($dir, "$Progname");
54 0 ▶ if (-s $name) { $Progname = $name; last }
Branch: 1 branch
BranchTrueFalseTotal
if (-s $name) 0 0 0
55 }
56 }
57  
58  
59 1;
60  
61 __END__
« PAR/SetupTemp.pm ↑ Summary