blib/lib/ExtUtils/Builder/Util.pm

filter: Statementstmt 75.2% 67 / 89 Branchbran 34.3% 11 / 32 Conditioncond 20.0% 3 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 89.4% 17 / 19 Podpod 100% 8 / 8 totaltotal 61.2% 106 / 173 CC 22 SCAR 37.1
CC
22
Cov
60%
_glob_to_regex_string
91.5
get_perl
10.1
glob_to_regex
2.1
CRAP 40.7
↑ Summary blib/lib/ExtUtils/Builder/Action/Command.pm »
1 package ExtUtils::Builder::Util;
2 16 $ExtUtils::Builder::Util::VERSION = '0.020';
3 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 16 ▶use Exporter 5.57 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 our @EXPORT_OK = qw/get_perl require_module unix_to_native_path native_to_unix_path command code function split_like_shell/;
8  
9 16 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 16 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 16 ▶use ExtUtils::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 16 ▶use ExtUtils::Helpers 0.027 'split_like_shell';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 16 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 16 ▶use File::Spec::Unix;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 16 ▶use Scalar::Util 'tainted';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 5 ▶sub get_perl {
Subroutine get_perl: called CC=5 SCAR=23.1
Pod documented
18 5 my (%opts) = @_;
19 5 ▶ my $config = $opts{config} // ExtUtils::Config->new;
Condition33%1/3
$opts{"config"} // "ExtUtils::Config"->new
l!l&&r!l&&!r
050
MC/DC0%0/2
$opts{"config"} // "ExtUtils::Config"->new
$opts{"config"} "ExtUtils::Config"->new
Truth table33%1/3
A // B
A= $opts{"config"}B= "ExtUtils::Config"->new
ABresult
1X1
011
000
20  
21 5 ▶ if (File::Spec->file_name_is_absolute($^X) and not tainted($^X)) {
Branch: 2 branches
BranchTrueFalseTotal
if ('File::Spec'->file_name_is_absolute($^X) and not &tainted($^X)) { } 5 0 5
elsif ($config->get('userelocatableinc')) { } 0 0 0
Condition33%1/3
"File::Spec"->file_name_is_absolute($^X) and not &tainted($^X)
!ll&&!rl&&r
005
MC/DC0%0/2
"File::Spec"->file_name_is_absolute($^X) and not &tainted($^X)
"File::Spec"->file_name_is_absolute($^X) not &tainted($^X)
Truth table33%1/3
A and not(B)
A= "File::Spec"->file_name_is_absolute($^X)B= not &tainted($^X)
ABresult
0X0
100
111
22 5 return $^X;
23 }
24 elsif ($config->get('userelocatableinc')) {
25 0 require Devel::FindPerl;
26 0 return Devel::FindPerl::find_perl_interpreter($config);
27 }
28 else {
29 0 return $config->get('perlpath');
30 }
31 }
32  
33 4 ▶sub require_module {
Subroutine require_module: called CC=1 SCAR=0.0
Pod documented
34 4 my $module = shift;
35 4 (my $filename = "$module.pm") =~ s{::}{/}g;
36 4 require $filename;
37 4 return $module;
38 }
39  
40 1 ▶sub command {
Subroutine command: called CC=1 SCAR=0.0
Pod documented
41 1 my (@command) = @_;
42 1 require ExtUtils::Builder::Action::Command;
43 1 return ExtUtils::Builder::Action::Command->new(command => \@command);
44 }
45  
46 10 ▶sub code {
Subroutine code: called CC=1 SCAR=0.0
Pod documented
47 10 my %args = @_;
48 10 require ExtUtils::Builder::Action::Code;
49 10 return ExtUtils::Builder::Action::Code->new(%args);
50 }
51  
52 0 ▶sub function {
Subroutine function: not called CC=1 SCAR=6.9
Pod documented
53 0 my %args = @_;
54 0 require ExtUtils::Builder::Action::Function;
55 0 return ExtUtils::Builder::Action::Function->new(%args);
56 }
57  
58 16 my %cache;
59 1 ▶sub glob_to_regex {
Subroutine glob_to_regex: called CC=2 SCAR=7.4
Pod documented
60 1 my $input = shift;
61 1 ▶ return $cache{$input} ||= do {
Condition33%1/3
$cache{$input} ||= do { my $regex = _glob_to_regex_string($input); qr/^$regex$/ }
l!l&&r!l&&!r
010
MC/DC0%0/2
$cache{$input} ||= do { my $regex = _glob_to_regex_string($input); qr/^$regex$/ }
$cache{$input} do { my $regex = _glob_to_regex_string($input); qr/^$regex$/ }
Truth table33%1/3
A ||= B
A= $cache{$input}B= do { my $regex = _glob_to_regex_string($input); qr/^$regex$/ }
ABresult
1X1
011
000
62 1 my $regex = _glob_to_regex_string($input);
63 1 qr/^$regex$/;
64 };
65 }
66  
67 1 ▶sub _glob_to_regex_string {
Subroutine _glob_to_regex_string: called CC=17 SCAR=45.2
68 1 my $glob = shift;
69 1 my $in_curlies;
70 1 local $_ = $glob;
71  
72 1 ▶ my $regex = !/\A(?=\.)/ ? '(?=[^\.])' : '';
Branch: 1 branch
BranchTrueFalseTotal
!/\A(?=\.)/ ? : 1 0 1
73 1 ▶ while (!/\G\z/mgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/\G\z/cgm) 3 1 4
74 3 ▶ if (/\G([^\/.()|+^\$@%\\*?{},\[\]]+)/gc) {
Branch: 11 branches
BranchTrueFalseTotal
if (m(\G([^/.()|+^\$\@%\\*?{},\[\]]+))cg) { } 1 2 3
elsif (m[\G/]cg) { } 0 2 2
elsif (/ \G ( [.()|+^\$\@%] ) /cgmx) { } 1 1 2
elsif (/ \G \\ ( [*?{}\\,] ) /cgmx) { } 0 1 1
elsif (/\G\*/cgm) { } 1 0 1
elsif (/\G\?/cgm) { } 0 0 0
elsif (/\G\{/cgm) { } 0 0 0
elsif (/\G \[ ( [^\]]+ ) \] /cgx) { } 0 0 0
elsif ($in_curlies and /\G\}/cgm) { } 0 0 0
elsif ($in_curlies and /\G,/cgm) { } 0 0 0
elsif (/\G([},]+)/cg) { } 0 0 0
75 1 $regex .= $1;
76 }
77 elsif (m{\G/}gc) {
78 0 ▶ $regex .= !/\G(?=\.)/gc ? '/(?=[^\.])' : '/'
Branch: 1 branch
BranchTrueFalseTotal
!/\G(?=\.)/cg ? : 0 0 0
79 }
80 elsif (/ \G ( [.()|+^\$@%] ) /xmgc) {
81 1 $regex .= quotemeta $1;
82 }
83 elsif (/ \G \\ ( [*?{}\\,] ) /xmgc) {
84 0 $regex .= quotemeta $1;
85 }
86 elsif (/\G\*/mgc) {
87 1 $regex .= "[^/]*";
88 }
89 elsif (/\G\?/mgc) {
90 0 $regex .= "[^/]";
91 }
92 elsif (/\G\{/mgc) {
93 0 $regex .= "(";
94 0 ++$in_curlies;
95 }
96 elsif (/\G \[ ( [^\]]+ ) \] /xgc) {
97 0 $regex .= "[\Q$1\E]";
98 }
99 ▶ elsif ($in_curlies && /\G\}/mgc) {
Condition0%0/3
$in_curlies and /\G\}/cgm
!ll&&!rl&&r
000
MC/DC0%0/2
$in_curlies and /\G\}/cgm
$in_curlies /\G\}/cgm
Truth table0%0/3
A and B
A= $in_curliesB= /\G\}/cgm
ABresult
0X0
100
111
100 0 $regex .= ")";
101 0 --$in_curlies;
102 }
103 ▶ elsif ($in_curlies && /\G,/mgc) {
Condition0%0/3
$in_curlies and /\G,/cgm
!ll&&!rl&&r
000
MC/DC0%0/2
$in_curlies and /\G,/cgm
$in_curlies /\G,/cgm
Truth table0%0/3
A and B
A= $in_curliesB= /\G,/cgm
ABresult
0X0
100
111
104 0 $regex .= "|";
105 }
106 elsif (/\G([},]+)/gc) {
107 0 $regex .= $1;
108 }
109 else {
110 0 croak sprintf "Couldn't parse at %s|%s", substr($_, 0 , pos), substr $_, pos;
111 }
112 }
113  
114 1 return $regex;
115 }
116  
117 2 ▶sub unix_to_native_path {
Subroutine unix_to_native_path: called CC=1 SCAR=0.0
Pod documented
118 2 my ($input) = @_;
119 2 my ($volume, $unix_dir, $file) = File::Spec::Unix->splitpath($input);
120 2 my @splitdir = File::Spec::Unix->splitdir($unix_dir);
121 2 my $catdir = File::Spec->catdir(@splitdir);
122 2 return File::Spec->catpath($volume, $catdir, $file);
123 }
124  
125 0 ▶sub native_to_unix_path {
Subroutine native_to_unix_path: not called CC=1 SCAR=6.9
Pod documented
126 0 my ($input) = @_;
127 0 my ($volume, $unix_dir, $file) = File::Spec->splitpath($input);
128 0 my @splitdir = File::Spec->splitdir($unix_dir);
129 0 my $catdir = File::Spec::Unix->catdir(@splitdir);
130 0 return File::Spec::Unix->catpath($volume, $catdir, $file);
131 }
132  
133 16 1;
134  
135 # ABSTRACT: Utility functions for ExtUtils::Builder
136  
137 __END__
↑ Summary blib/lib/ExtUtils/Builder/Action/Command.pm »