alienfile

filter: Statementstmt 66.0% 70 / 106 Branchbran 25.0% 9 / 36 Conditioncond 30.0% 6 / 20 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 71.4% 10 / 14 Podpod n/a totaltotal 51.3% 95 / 185 CC 21 SCAR 27.5
CC
21
Cov
52%
remove_gitfw_from_path
42.0
pause
20.0
__ANON__
16.8
CRAP 15.6
↑ Summary blib/lib/Alien/sqlite/Install/Files.pm »
1 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use alienfile;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Sort::Versions;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Path::Tiny qw /path/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6
7 1 my $on_windows = $^O =~ /mswin/i;
8 my $on_automated_rig
9 = $ENV{PERL_CPAN_REPORTER_DIR}
10 || $ENV{PERL_CPAN_REPORTER_CONFIG}
11 || $ENV{AUTOMATED_TESTING}
12 || $ENV{TRAVIS}
13 || $ENV{APPVEYOR}
14 1 ▶ || $ENV{CI};
Condition33%5/15
$ENV{'PERL_CPAN_REPORTER_DIR'} || $ENV{'PERL_CPAN_REPORTER_CONFIG'} || $ENV{'AUTOMATED_TESTING'} || $ENV{'TRAVIS'} || $ENV{'APPVEYOR'} || $ENV{'CI'}
l!l&&r!l&&!r
100
$ENV{"PERL_CPAN_REPORTER_DIR"} or $ENV{"PERL_CPAN_REPORTER_CONFIG"} or $ENV{"AUTOMATED_TESTING"} or $ENV{"TRAVIS"} or $ENV{"APPVEYOR"}
l!l&&r!l&&!r
100
$ENV{"PERL_CPAN_REPORTER_DIR"} or $ENV{"PERL_CPAN_REPORTER_CONFIG"} or $ENV{"AUTOMATED_TESTING"} or $ENV{"TRAVIS"}
l!l&&r!l&&!r
100
$ENV{"PERL_CPAN_REPORTER_DIR"} or $ENV{"PERL_CPAN_REPORTER_CONFIG"} or $ENV{"AUTOMATED_TESTING"}
l!l&&r!l&&!r
010
$ENV{"PERL_CPAN_REPORTER_DIR"} or $ENV{"PERL_CPAN_REPORTER_CONFIG"}
l!l&&r!l&&!r
001
MC/DC0%0/6
$ENV{'PERL_CPAN_REPORTER_DIR'} || $ENV{'PERL_CPAN_REPORTER_CONFIG'} || $ENV{'AUTOMATED_TESTING'} || $ENV{'TRAVIS'} || $ENV{'APPVEYOR'} || $ENV{'CI'}
$ENV{"PERL_CPAN_REPORTER_DIR"} $ENV{"PERL_CPAN_REPORTER_CONFIG"} $ENV{"AUTOMATED_TESTING"} $ENV{"TRAVIS"} $ENV{"APPVEYOR"} $ENV{'CI'}
Truth table14%1/7
A or B or C or D or E || F
A= $ENV{"PERL_CPAN_REPORTER_DIR"}B= $ENV{"PERL_CPAN_REPORTER_CONFIG"}C= $ENV{"AUTOMATED_TESTING"}D= $ENV{"TRAVIS"}E= $ENV{"APPVEYOR"}F= $ENV{'CI'}
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
15
16
17 1 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 my $base_dir = getcwd();
19
20 # make libtool noisy for debug purposes
21 #$ENV{LTFLAGS} = "--debug --verbose" if $on_windows;
22
23 1 ▶use Env qw { @PATH };
Subroutine BEGIN: called CC=1 SCAR=0.0
24
25
26 # ubuntu 22.04 LTS has this
27 1 my $min_target_version = '3.37.2';
28
29 1 plugin 'PkgConfig' => (
30 pkg_name => 'sqlite3',
31 minimum_version => $min_target_version,
32 );
33
34 1 plugin 'Probe::CommandLine' => (
35 command => 'sqlite3',
36 #args => [ '--version' ],
37 #match => qr/\d+\.\d+\.\d+ \d{4}-\d{2}-\d{2}/,
38 #version => qr/gzip ([0-9\.]+)/,
39 secondary => 1, # secondary to pkgconf probe
40 );
41
42 # need to check if we have sqlite headers
43 # as dependent aliens like proj need them
44 #probe sub {
45 # my($build) = @_; # $build is the Alien::Build instance.
46 # system 'pkg-config --exists libfoo';
47 # $? == 0 ? 'system' : 'share';
48 #};
49
50
51 1 ▶share {
Subroutine __ANON__: called CC=10 SCAR=28.2
52
53 1 my $with_local = '';
54 1 my $with_cpp11 = '';
55
56 # need to work out how to get latest without updating next lines
57 1 start_url 'https://www.sqlite.org/2026/sqlite-autoconf-3540100.tar.gz';
58 1 plugin Download => (
59 version => '3.54.1',
60 );
61
62
63 1 ▶ my $lib_version = get_lib_version() // 'not yet defined';
Condition50%1/2
get_lib_version() // "not yet defined"
l!l
10
MC/DC0%0/1
get_lib_version() // "not yet defined"
get_lib_version()
Truth table50%1/2
A
A= get_lib_version()
Aresult
11
00
64 1 say "Downloaded version is $lib_version";
65
66 1 plugin Extract => (format => 'tar.gz');
67
68
69 1 plugin 'Build::Autoconf' => (with_pic => 0);
70
71 1 ▶ my $build_static = ($^O =~ /mswin/i) ? '' : '--disable-shared';
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /mswin/i ? : 0 1 1
72 1 $build_static = '';
73 #$build_static = '--enable-static=no'; # override - needed? leftover from gdal
74 1 $build_static = '--disable-static';
75 #$build_static = '' if $ENV{FORCE_DYNAMIC};
76
77
78 1 ▶ if ($^O =~ /bsd/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($^O =~ /bsd/) { } 0 1 1
elsif ($^O =~ /dragonfly/) { } 0 1 1
elsif ($on_windows) { } 0 1 1
79 0 plugin 'Build::Make' => 'gmake';
80 0 ▶ if (-d '/usr/local') {
Branch: 1 branch
BranchTrueFalseTotal
if (-d "/usr/local") 0 0 0
81 0 $with_local = ' --with-local=/usr/local ';
82 }
83 }
84 elsif ($^O =~ /dragonfly/) {
85 # might need to be combined with bsd check above
86 # but not sure if /usr/local is needed yet
87 0 plugin 'Build::Make' => 'gmake';
88 }
89 elsif ($on_windows) {
90 0 plugin 'Build::Make' => 'gmake';
91 }
92
93 1 my $make_cmd = '%{make}';
94 1 my $make_inst_cmd = '%{make} install';
95 1 my @make_clean;
96 # try not to exceed the cpan-testers log limits
97 1 ▶ if ($on_automated_rig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($on_automated_rig) 1 0 1
98 1 say "Running under CI or automated testing";
99 1 $make_cmd .= q/ | perl -ne "BEGIN {$|=1; open our $log, q|>|, q|build.log|}; print qq|\n| if 0 == ($. %% 100); print q|.|; print {$log} $_;" || type build.log/;
100 1 $make_inst_cmd .= q/ | perl -ne "BEGIN {$|=1; open our $log, q|>|, q|install.log|}; print qq|\n| if 0 == ($. %% 100); print q|.|; print {$log} $_;" || type install.log/;
101 1 ▶ if (!$on_windows) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($on_windows) 1 0 1
102 1 $make_cmd =~ s/%%/%/;
103 1 $make_cmd =~ s/type/cat/;
104 1 $make_cmd =~ s/"/'/g;
105 1 $make_inst_cmd =~ s/%%/%/;
106 1 $make_inst_cmd =~ s/type/cat/;
107 1 $make_inst_cmd =~ s/"/'/g;
108 }
109 #if (! ($ENV{TRAVIS} || $ENV{APPVEYOR})) {
110 # push @make_clean, '%{make} clean';
111 #}
112 # clean up the build dir on cpan testers etc
113 1 plugin 'Cleanse::BuildDir';
114 }
115
116 1 meta->around_hook( build => \&remove_gitfw_from_path );
117 meta->around_hook(
118 0 ▶ build => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
119 0 my ($orig, $build, @args) = @_;
120 0 $build->log("Setting CCACHE_BASEDIR to " . getcwd());
121 0 local $ENV{CCACHE_BASEDIR} = getcwd();
122 0 $orig->($build, @args);
123 }
124 1 );
125 1 ▶ if ($on_windows) {
Branch: 1 branch
BranchTrueFalseTotal
if ($on_windows) 0 1 1
126 # avoid some double-path shenanigens on Windows
127 meta->around_hook (
128 0 ▶ build => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
129 0 my ($orig, $build, @args) = @_;
130 local $ENV{DESTDIR} = "$ENV{DESTDIR}/"
131 0 ▶ if not $ENV{DESTDIR} =~ m{/$};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"DESTDIR"} =~ m[/$] 0 0 0
132 0 $build->install_prop->{prefix} = '.';
133 0 local $ENV{CFLAGS} .= ' -D_WIN32_WINNT=0x0600'; # for older Strawberry toolchains
134 0 $orig->($build, @args);
135 }
136 0 );
137 }
138
139 build [
140 1 "%{configure} $build_static $with_local $with_cpp11",
141 #\&pause,
142 $make_cmd,
143 $make_inst_cmd,
144 #@make_clean,
145 ];
146
147 1 };
148
149 # git for windows clashes with MSYS
150 # if its /usr/bin dir is in the path
151 0 ▶sub remove_gitfw_from_path {
Subroutine remove_gitfw_from_path: not called CC=6 SCAR=37.4
152 0 my ($orig, $build, @args) = @_;
153
154 0 ▶ return $orig->($build, @args)
Branch: 1 branch
BranchTrueFalseTotal
unless $on_windows 0 0 0
155 if !$on_windows;
156
157 0 local $ENV{PATH} = $ENV{PATH};
158
159 0 my $msys_path = eval {
160 0 path('Alien::MSYS'->msys_path())
161 };
162 0 ▶ return if !defined $msys_path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $msys_path 0 0 0
163 0 my $count = @PATH;
164
165 @PATH
166 0 ▶ = grep {path($_)->stringify =~ m|/usr/bin$| && path($_) ne $msys_path ? () : $_}
Branch: 1 branch
BranchTrueFalseTotal
path($_)->stringify =~ m[/usr/bin$] && path($_) ne $msys_path ? : 0 0 0
Condition0%0/3
path($_)->stringify =~ m[/usr/bin$] and path($_) ne $msys_path
!ll&&!rl&&r
000
MC/DC0%0/2
path($_)->stringify =~ m[/usr/bin$] and path($_) ne $msys_path
path($_)->stringify =~ m[/usr/bin$] path($_) ne $msys_path
Truth table0%0/3
A and B
A= path($_)->stringify =~ m[/usr/bin$]B= path($_) ne $msys_path
ABresult
0X0
100
111
167 0 grep {defined $_} # undef paths cause issues with Path::Tiny
168 @PATH;
169
170 0 my $removed = $count - @PATH;
171 0 ▶ if ($removed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($removed) 0 0 0
172 0 $build->log ("$removed additional .../usr/bin dirs were removed from the path for compilation");
173 }
174
175 0 $orig->($build, @args);
176 }
177
178 0 ▶sub pause {
Subroutine pause: not called CC=4 SCAR=30.0
179 0 return; # re-enable in case of debug
180 0 ▶ return if $on_automated_rig;
Branch: 1 branch
BranchTrueFalseTotal
if $on_automated_rig 0 0 0
181 0 ▶ return if !$on_windows;
Branch: 1 branch
BranchTrueFalseTotal
unless $on_windows 0 0 0
182
183 0 say "CONTINUE?";
184 0 my $response = <>;
185 0 ▶ while (not $response =~ /yes/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $response =~ /yes/) 0 0 0
186 0 $response = <>;
187 }
188 }
189
190
191 1 ▶sub get_lib_version {
Subroutine get_lib_version: called CC=1 SCAR=0.0
192 1 my $h = get_alien_state_hash();
193 1 return $h->{runtime}{version};
194 }
195
196 1 ▶sub get_alien_state_hash {
Subroutine get_alien_state_hash: called CC=3 SCAR=11.0
197 1 ▶ use JSON::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
198 1 my $root = "$base_dir/_alien";
199 1 my $f = "$root/state.json";
200 1 my $h = {};
201 1 ▶ if (-e $f) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $f) 1 0 1
202 1 ▶ open my $fh, '<', $f or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $f or die $! 1 0 1
203 1 my $d = do {
204 1 local $/ = undef;
205 1 <$fh>;
206 };
207 1 $h = JSON::PP::decode_json($d);
208 }
209 1 return $h;
210 }
211
↑ Summary blib/lib/Alien/sqlite/Install/Files.pm »