blib/lib/Test/Alien/Build.pm

filter: Statementstmt 91.9% 319 / 347 Branchbran 69.2% 72 / 104 Conditioncond 59.0% 39 / 66 MC/DCmcdc 26.8% 11 / 41 Subroutinesub 97.3% 36 / 37 Podpod 92.8% 13 / 14 totaltotal 80.4% 490 / 609 CC 89 SCAR 21.5
CC
89
Cov
83%
alien_build_clean
20.0
alien_clean_install
15.0
alien_extract_ok
13.8
CRAP 8.6
« blib/lib/Alien/Build/Plugin/Extract/Negotiate.pm ↑ Summary blib/lib/Alien/Build/Plugin/Build/CMake.pm »
1 package Test::Alien::Build;
2  
3 63 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 63 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 63 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 63 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 63 ▶use Path::Tiny qw( path );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 63 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 63 ▶use Test2::API qw( context run_subtest );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 63 ▶use Capture::Tiny qw( capture_merged );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 63 ▶use Alien::Build::Util qw( _mirror );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 63 ▶use List::Util 1.33 qw( any );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 63 ▶use Alien::Build::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 63 our @EXPORT = qw(
16 alienfile
17 alienfile_ok
18 alienfile_skip_if_missing_prereqs
19 alien_download_ok
20 alien_extract_ok
21 alien_build_ok
22 alien_build_clean
23 alien_clean_install
24 alien_install_type_is
25 alien_checkpoint_ok
26 alien_resume_ok
27 alien_subtest
28 alien_rc
29 );
30  
31 # ABSTRACT: Tools for testing Alien::Build + alienfile
32 63 our $VERSION = '2.88'; # VERSION
33  
34  
35 63 my $build;
36 my $build_alienfile;
37 63 my $build_root;
38 63 my $build_targ;
39  
40 sub alienfile::targ
41 1 ▶{
Subroutine targ: called CC=1 SCAR=0.0
Pod undocumented
42 1 $build_targ;
43 }
44  
45 sub alienfile
46 355 ▶{
Subroutine alienfile: called CC=11 SCAR=24.3
Pod documented
47 355 my($package, $filename, $line) = caller;
48 355 ▶ ($package, $filename, $line) = caller(2) if $package eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $package eq __PACKAGE__ 224 131 355
49 355 $filename = path($filename)->absolute;
50 355 ▶ my %args = @_ == 0 ? (filename => 'alienfile') : @_ % 2 ? ( source => do { '# line '. $line . ' "' . path($filename)->absolute . qq("\n) . $_[0] }) : @_;
Branch: 2 branches
BranchTrueFalseTotal
@_ == 0 ? : 0 355 355
@_ % 2 ? : 302 53 355
51  
52 355 require alienfile;
53 355 ▶ push @alienfile::EXPORT, 'targ' unless any { /^targ$/ } @alienfile::EXPORT;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
unless &any(sub { /^targ$/; } , @alienfile::EXPORT) 55 300 355
54  
55 355 my $temp = Alien::Build::Temp->newdir;
56 355 my $get_temp_root = do{
57 355 my $root; # may be undef;
58 1368 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
59 1368 ▶ $root ||= Path::Tiny->new($temp);
Condition66%2/3
$root ||= "Path::Tiny"->new($temp)
l!l&&r!l&&!r
10133550
MC/DC0%0/2
$root ||= "Path::Tiny"->new($temp)
$root "Path::Tiny"->new($temp)
Truth table66%2/3
A ||= B
A= $rootB= "Path::Tiny"->new($temp)
ABresult
1X1
011
000
60  
61 1368 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 1065 303 1368
62 {
63 1065 my $path = $root->child(@_);
64 1065 $path->mkpath;
65 1065 $path;
66 }
67 else
68 {
69 303 return $root;
70 }
71 355 };
72 };
73  
74 355 ▶ if($args{source})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'source'}) { } 303 52 355
75 {
76 303 my $file = $get_temp_root->()->child('alienfile');
77 303 $file->spew_utf8($args{source});
78 303 $args{filename} = $file->stringify;
79 }
80 else
81 {
82 52 ▶ unless(defined $args{filename})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"filename"}) 0 52 52
83 {
84 0 croak "You must specify at least one of filename or source";
85 }
86 52 $args{filename} = path($args{filename})->absolute->stringify;
87 }
88  
89 355 ▶ $args{stage} ||= $get_temp_root->('stage')->stringify;
Condition33%1/3
$args{"stage"} ||= &$get_temp_root("stage")->stringify
l!l&&r!l&&!r
03550
MC/DC0%0/2
$args{"stage"} ||= &$get_temp_root("stage")->stringify
$args{"stage"} &$get_temp_root("stage")->stringify
Truth table33%1/3
A ||= B
A= $args{"stage"}B= &$get_temp_root("stage")->stringify
ABresult
1X1
011
000
90 355 ▶ $args{prefix} ||= $get_temp_root->('prefix')->stringify;
Condition33%1/3
$args{"prefix"} ||= &$get_temp_root("prefix")->stringify
l!l&&r!l&&!r
03550
MC/DC0%0/2
$args{"prefix"} ||= &$get_temp_root("prefix")->stringify
$args{"prefix"} &$get_temp_root("prefix")->stringify
Truth table33%1/3
A ||= B
A= $args{"prefix"}B= &$get_temp_root("prefix")->stringify
ABresult
1X1
011
000
91 355 ▶ $args{root} ||= $get_temp_root->('root')->stringify;
Condition33%1/3
$args{"root"} ||= &$get_temp_root("root")->stringify
l!l&&r!l&&!r
03550
MC/DC0%0/2
$args{"root"} ||= &$get_temp_root("root")->stringify
$args{"root"} &$get_temp_root("root")->stringify
Truth table33%1/3
A ||= B
A= $args{"root"}B= &$get_temp_root("root")->stringify
ABresult
1X1
011
000
92  
93 355 require Alien::Build;
94  
95 355 _alienfile_clear();
96 355 ▶ my $out = capture_merged {
Subroutine __ANON__: called CC=1 SCAR=0.0
97 355 $build_targ = $args{targ};
98 355 $build = Alien::Build->load($args{filename}, root => $args{root});
99 338 $build->set_stage($args{stage});
100 338 $build->set_prefix($args{prefix});
101 355 };
102  
103 338 my $ctx = context();
104 338 ▶ $ctx->note($out) if $out;
Branch: 1 branch
BranchTrueFalseTotal
if $out 8 330 338
105 338 $ctx->release;
106  
107 338 $build_alienfile = $args{filename};
108 338 $build_root = $temp;
109 338 $build
110 }
111  
112 sub _alienfile_clear
113 481 ▶{
Subroutine _alienfile_clear: called CC=3 SCAR=11.0
114 481 ▶ eval { defined $build_root && -d $build_root && path($build_root)->remove_tree };
Branch: 1 branch
BranchTrueFalseTotal
defined $build_root and -d $build_root and path($build_root)->remove_tree 288 193 481
Condition66%2/3
defined $build_root and -d $build_root
!ll&&!rl&&r
1930288
MC/DC50%1/2
defined $build_root and -d $build_root
defined $build_root -d $build_root
Truth table66%2/3
A and B
A= defined $build_rootB= -d $build_root
ABresult
0X0
100
111
115 481 undef $build;
116 481 undef $build_alienfile;
117 481 undef $build_root;
118 481 undef $build_targ;
119 }
120  
121  
122 sub alienfile_ok
123 226 ▶{
Subroutine alienfile_ok: called CC=6 SCAR=17.9
Pod documented
124 226 my $build;
125 my $name;
126 226 my $error;
127  
128 226 ▶ if(@_ == 1 && ! defined $_[0])
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and not defined $_[0]) { } 1 225 226
elsif (@_ == 1 and eval { do { $_[0]->isa('Alien::Build') } }) { } 1 224 225
Condition100%3/3
@_ == 1 and not defined $_[0]
!ll&&!rl&&r
22231
MC/DC100%2/2
@_ == 1 and not defined $_[0]
@_ == 1 not defined $_[0]
Truth table100%3/3
A and not(B)
A= @_ == 1B= not defined $_[0]
ABresult
0X0
100
111
129 {
130 1 $build = $_[0];
131 1 $error = 'no alienfile given';
132 1 $name = 'alienfile compiled';
133 }
134 223 ▶ elsif(@_ == 1 && eval { $_[0]->isa('Alien::Build') })
Condition100%3/3
@_ == 1 and eval { do { $_[0]->isa("Alien::Build") } }
!ll&&!rl&&r
22221
MC/DC100%2/2
@_ == 1 and eval { do { $_[0]->isa("Alien::Build") } }
@_ == 1 eval { do { $_[0]->isa("Alien::Build") } }
Truth table100%3/3
A and B
A= @_ == 1B= eval { do { $_[0]->isa("Alien::Build") } }
ABresult
0X0
100
111
135 {
136 1 $build = $_[0];
137 1 $name = 'alienfile compiled';
138 }
139 else
140 {
141 224 $build = eval { alienfile(@_) };
142 224 $error = $@;
143 224 $name = 'alienfile compiles';
144 }
145  
146 226 my $ok = !! $build;
147  
148 226 my $ctx = context();
149 226 $ctx->ok($ok, $name);
150 226 ▶ $ctx->diag("error: $error") if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 2 224 226
151 226 $ctx->release;
152  
153 226 $build;
154 }
155  
156  
157 sub alienfile_skip_if_missing_prereqs
158 49 ▶{
Subroutine alienfile_skip_if_missing_prereqs: called CC=7 SCAR=20.2
Pod documented
159 49 my($phase) = @_;
160  
161 49 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) 49 0 49
162 {
163 49 eval { $build->load_requires('configure', 1) };
164 49 ▶ if(my $error = $@)
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = $@) 2 47 49
165 {
166 2 my $reason = "Missing configure prereq";
167 2 ▶ if($error =~ /Required (.*) (.*),/)
Branch: 1 branch
BranchTrueFalseTotal
if ($error =~ /Required (.*) (.*),/) 2 0 2
168 {
169 2 $reason .= ": $1 $2";
170 }
171 2 my $ctx = context();
172 2 $ctx->plan(0, SKIP => $reason);
173 0 $ctx->release;
174 0 return;
175 }
176 47 ▶ $phase ||= $build->install_type;
Condition66%2/3
$phase ||= $build->install_type
l!l&&r!l&&!r
1460
MC/DC0%0/2
$phase ||= $build->install_type
$phase $build->install_type
Truth table66%2/3
A ||= B
A= $phaseB= $build->install_type
ABresult
1X1
011
000
177 47 eval { $build->load_requires($phase, 1) };
178 47 ▶ if(my $error = $@)
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = $@) 8 39 47
179 {
180 8 my $reason = "Missing $phase prereq";
181 8 ▶ if($error =~ /Required (.*) (.*),/)
Branch: 1 branch
BranchTrueFalseTotal
if ($error =~ /Required (.*) (.*),/) 8 0 8
182 {
183 8 $reason .= ": $1 $2";
184 }
185 8 my $ctx = context();
186 8 $ctx->plan(0, SKIP => $reason);
187 0 $ctx->release;
188 0 return;
189 }
190 }
191 }
192  
193  
194 sub alien_install_type_is
195 60 ▶{
Subroutine alien_install_type_is: called CC=7 SCAR=19.5
Pod documented
196 60 my($type, $name) = @_;
197  
198 60 ▶ croak "invalid install type" unless defined $type && $type =~ /^(system|share)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type and $type =~ /^(system|share)$/ 0 60 60
Condition33%1/3
defined $type and $type =~ /^(system|share)$/
!ll&&!rl&&r
0060
MC/DC0%0/2
defined $type and $type =~ /^(system|share)$/
defined $type $type =~ /^(system|share)$/
Truth table33%1/3
A and B
A= defined $typeB= $type =~ /^(system|share)$/
ABresult
0X0
100
111
199 60 ▶ $name ||= "alien install type is $type";
Condition100%2/2
$name ||= "alien install type is $type"
l!l
456
MC/DC100%1/1
$name ||= "alien install type is $type"
$name
Truth table100%2/2
A
A= $name
Aresult
11
00
200  
201 60 my $ok = 0;
202 60 my @diag;
203  
204 60 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) { } 59 1 60
205 {
206 59 ▶ my($out, $actual) = capture_merged {
Subroutine __ANON__: called CC=1 SCAR=0.0
207 59 $build->load_requires('configure');
208 59 $build->install_type;
209 59 };
210 59 ▶ if($type eq $actual)
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq $actual) { } 57 2 59
211 {
212 57 $ok = 1;
213 }
214 else
215 {
216 2 push @diag, "expected install type of $type, but got $actual";
217 }
218 }
219 else
220 {
221 1 push @diag, 'no alienfile'
222 }
223  
224 60 my $ctx = context();
225 60 $ctx->ok($ok, $name);
226 60 $ctx->diag($_) for @diag;
227 60 $ctx->release;
228  
229 60 $ok;
230 }
231  
232  
233 sub alien_download_ok
234 34 ▶{
Subroutine alien_download_ok: called CC=11 SCAR=26.0
Pod documented
235 34 my($name) = @_;
236  
237 34 ▶ $name ||= 'alien download';
Condition50%1/2
$name ||= "alien download"
l!l
034
MC/DC0%0/1
$name ||= "alien download"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
238  
239 34 my $ok;
240 my $file;
241 34 my @diag;
242 34 my @note;
243  
244 34 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) { } 34 0 34
245 {
246 34 ▶ my($out, $error) = capture_merged {
Subroutine __ANON__: called CC=1 SCAR=0.0
247 34 eval {
248 34 $build->load_requires('configure');
249 34 $build->load_requires($build->install_type);
250 34 $build->download;
251 };
252 34 $@;
253 34 };
254 34 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) { } 1 33 34
255 {
256 1 $ok = 0;
257 1 ▶ push @diag, $out if defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out 1 0 1
258 1 push @diag, "extract threw exception: $error";
259 }
260 else
261 {
262 33 $file = $build->install_prop->{download};
263 33 ▶ if(-d $file || -f $file)
Branch: 1 branch
BranchTrueFalseTotal
if (-d $file or -f $file) { } 33 0 33
Condition66%2/3
-d $file or -f $file
l!l&&r!l&&!r
1320
MC/DC0%0/2
-d $file or -f $file
-d $file -f $file
Truth table66%2/3
A or B
A= -d $fileB= -f $file
ABresult
1X1
011
000
264 {
265 33 $ok = 1;
266 33 ▶ push @note, $out if defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out 33 0 33
267 }
268 else
269 {
270 0 $ok = 0;
271 0 ▶ push @diag, $out if defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out 0 0 0
272 0 push @diag, 'no file or directory';
273 }
274 }
275 }
276 else
277 {
278 0 $ok = 0;
279 0 push @diag, 'no alienfile';
280 }
281  
282 34 my $ctx = context();
283 34 $ctx->ok($ok, $name);
284 34 $ctx->note($_) for @note;
285 34 $ctx->diag($_) for @diag;
286 34 $ctx->release;
287  
288 34 $file;
289 }
290  
291  
292 sub alien_extract_ok
293 20 ▶{
Subroutine alien_extract_ok: called CC=11 SCAR=26.3
Pod documented
294 20 my($archive, $name) = @_;
295  
296 20 ▶ $name ||= $archive ? "alien extraction of $archive" : 'alien extraction';
Branch: 1 branch
BranchTrueFalseTotal
$archive ? : 0 20 20
Condition33%1/3
$name ||= $archive ? "alien extraction of $archive" : "alien extraction"
l!l&&r!l&&!r
0200
MC/DC0%0/2
$name ||= $archive ? "alien extraction of $archive" : "alien extraction"
$name $archive ? "alien extraction of $archive" : "alien extraction"
Truth table33%1/3
A ||= B
A= $nameB= $archive ? "alien extraction of $archive" : "alien extraction"
ABresult
1X1
011
000
297 20 my $ok;
298 my $dir;
299 20 my @diag;
300 20 my @note;
301  
302 20 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) { } 20 0 20
303 {
304 20 my($out, $error);
305 20 ▶ ($out, $dir, $error) = capture_merged {
Subroutine __ANON__: called CC=1 SCAR=0.0
306 20 my $dir = eval {
307 20 $build->load_requires('configure');
308 20 $build->load_requires($build->install_type);
309 20 $build->download;
310 20 $build->extract($archive);
311 };
312 20 ($dir, $@);
313 20 };
314 20 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) { } 1 19 20
315 {
316 1 $ok = 0;
317 1 ▶ push @diag, $out if defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out 1 0 1
318 1 push @diag, "extract threw exception: $error";
319 }
320 else
321 {
322 19 ▶ if(-d $dir)
Branch: 1 branch
BranchTrueFalseTotal
if (-d $dir) { } 19 0 19
323 {
324 19 $ok = 1;
325 19 ▶ push @note, $out if defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out 19 0 19
326 }
327 else
328 {
329 0 $ok = 0;
330 0 ▶ push @diag, $out if defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out 0 0 0
331 0 push @diag, 'no directory';
332 }
333 }
334 }
335 else
336 {
337 0 $ok = 0;
338 0 push @diag, 'no alienfile';
339 }
340  
341 20 my $ctx = context();
342 20 $ctx->ok($ok, $name);
343 20 $ctx->note($_) for @note;
344 20 $ctx->diag($_) for @diag;
345 20 $ctx->release;
346  
347 20 $dir;
348 }
349  
350  
351 63 my $count = 1;
352  
353 sub alien_build_ok
354 33 ▶{
Subroutine alien_build_ok: called CC=10 SCAR=23.0
Pod documented
355 33 ▶ my $opt = defined $_[0] && ref($_[0]) eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && ref $_[0] eq 'HASH' ? : 0 33 33
Condition66%2/3
defined $_[0] and ref $_[0] eq "HASH"
!ll&&!rl&&r
3210
MC/DC0%0/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0] ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
356 ? shift : { class => 'Alien::Base' };
357  
358 33 my($name) = @_;
359  
360 33 ▶ $name ||= 'alien builds okay';
Condition100%2/2
$name ||= "alien builds okay"
l!l
132
MC/DC100%1/1
$name ||= "alien builds okay"
$name
Truth table100%2/2
A
A= $name
Aresult
11
00
361 33 my $ok;
362 my @diag;
363 33 my @note;
364 33 my $alien;
365  
366 33 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) { } 32 1 33
367 {
368 32 ▶ my($out,$error) = capture_merged {
Subroutine __ANON__: called CC=1 SCAR=0.0
369 32 eval {
370 32 $build->load_requires('configure');
371 32 $build->load_requires($build->install_type);
372 32 $build->download;
373 31 $build->build;
374 };
375 32 $@;
376 32 };
377 32 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) { } 1 31 32
378 {
379 1 $ok = 0;
380 1 ▶ push @diag, $out if defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out 1 0 1
381 1 push @diag, "build threw exception: $error";
382 }
383 else
384 {
385 31 $ok = 1;
386  
387 31 ▶ push @note, $out if defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out 31 0 31
388  
389 31 require Alien::Base;
390  
391 31 my $prefix = $build->runtime_prop->{prefix};
392 31 my $stage = $build->install_prop->{stage};
393 31 my %prop = %{ $build->runtime_prop };
394  
395 31 $prop{distdir} = $prefix;
396  
397 31 _mirror $stage, $prefix;
398  
399 2 ▶ my $dist_dir = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
400 2 $prefix;
401 31 };
402  
403 48 ▶ my $runtime_prop = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
404 48 \%prop;
405 31 };
406  
407 31 $alien = sprintf 'Test::Alien::Build::Faux%04d', $count++;
408 {
409 63 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
410 31 @{ "${alien}::ISA" } = $opt->{class};
411 31 *{ "${alien}::dist_dir" } = $dist_dir;
412 31 *{ "${alien}::runtime_prop" } = $runtime_prop;
413 }
414 }
415 }
416 else
417 {
418 1 $ok = 0;
419 1 push @diag, 'no alienfile';
420 }
421  
422 33 my $ctx = context();
423 33 $ctx->ok($ok, $name);
424 33 $ctx->diag($_) for @diag;
425 33 $ctx->note($_) for @note;
426 33 $ctx->release;
427  
428 33 $alien;
429 }
430  
431  
432 sub alien_build_clean
433 0 ▶{
Subroutine alien_build_clean: not called CC=4 SCAR=30.0
Pod documented
434 0 my $ctx = context();
435 0 ▶ if($build_root)
Branch: 1 branch
BranchTrueFalseTotal
if ($build_root) { } 0 0 0
436 {
437 0 foreach my $child (path($build_root)->children)
438 {
439 0 ▶ next if $child->basename eq 'prefix';
Branch: 1 branch
BranchTrueFalseTotal
if $child->basename eq "prefix" 0 0 0
440 0 $ctx->note("clean: rm: $child");
441 0 $child->remove_tree;
442 }
443 }
444 else
445 {
446 0 $ctx->note("no build to clean");
447 }
448 0 $ctx->release;
449 }
450  
451  
452 sub alien_clean_install
453 3 ▶{
Subroutine alien_clean_install: called CC=10 SCAR=27.1
Pod documented
454 3 my($name) = @_;
455  
456 3 ▶ $name ||= "run clean_install";
Condition50%1/2
$name ||= "run clean_install"
l!l
03
MC/DC0%0/1
$name ||= "run clean_install"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
457  
458 3 my $ok;
459 my @diag;
460 3 my @note;
461  
462 3 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) { } 3 0 3
463 {
464 3 ▶ my($out,$error) = capture_merged {
Subroutine __ANON__: called CC=1 SCAR=0.0
465 3 eval {
466 3 $build->clean_install;
467 };
468 3 $@;
469 3 };
470 3 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) { } 0 3 3
471 {
472 0 $ok = 0;
473 0 ▶ push @diag, $out if defined $out && $out ne '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $out and $out ne "" 0 0 0
Condition0%0/3
defined $out and $out ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $out and $out ne ""
defined $out $out ne ""
Truth table0%0/3
A and B
A= defined $outB= $out ne ""
ABresult
0X0
100
111
474 0 push @diag, "build threw exception: $error";
475 }
476 else
477 {
478 3 $ok = 1;
479 3 ▶ push @note, $out if defined $out && $out ne '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $out and $out ne "" 2 1 3
Condition66%2/3
defined $out and $out ne ""
!ll&&!rl&&r
012
MC/DC50%1/2
defined $out and $out ne ""
defined $out $out ne ""
Truth table66%2/3
A and B
A= defined $outB= $out ne ""
ABresult
0X0
100
111
480 }
481 }
482 else
483 {
484 0 $ok = 0;
485 0 push @diag, 'no alienfile';
486 }
487  
488 3 my $ctx = context();
489 3 $ctx->ok($ok, $name);
490 3 $ctx->diag($_) for @diag;
491 3 $ctx->note($_) for @note;
492 3 $ctx->release;
493 }
494  
495  
496 sub alien_checkpoint_ok
497 18 ▶{
Subroutine alien_checkpoint_ok: called CC=5 SCAR=16.1
Pod documented
498 18 my($name) = @_;
499  
500 18 ▶ $name ||= "alien checkpoint ok";
Condition50%1/2
$name ||= "alien checkpoint ok"
l!l
018
MC/DC0%0/1
$name ||= "alien checkpoint ok"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
501 18 my $ok;
502 my @diag;
503  
504 18 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) { } 17 1 18
505 {
506 17 eval { $build->checkpoint };
507 17 ▶ if($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 1 16 17
508 {
509 1 push @diag, "error in checkpoint: $@";
510 1 $ok = 0;
511 }
512 else
513 {
514 16 $ok = 1;
515 }
516 17 undef $build;
517 }
518 else
519 {
520 1 push @diag, "no build to checkpoint";
521 1 $ok = 0;
522 }
523  
524 18 my $ctx = context();
525 18 $ctx->ok($ok, $name);
526 18 $ctx->diag($_) for @diag;
527 18 $ctx->release;
528  
529 18 $ok;
530 }
531  
532  
533 sub alien_resume_ok
534 17 ▶{
Subroutine alien_resume_ok: called CC=10 SCAR=23.1
Pod documented
535 17 my($name) = @_;
536  
537 17 ▶ $name ||= "alien resume ok";
Condition50%1/2
$name ||= "alien resume ok"
l!l
017
MC/DC0%0/1
$name ||= "alien resume ok"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
538 17 my $ok;
539 my @diag;
540  
541 17 ▶ if($build_alienfile && $build_root && !defined $build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build_alienfile and $build_root and not defined $build) { } 15 2 17
Condition83%5/6
$build_alienfile and $build_root and not defined $build
!ll&&!rl&&r
1115
$build_alienfile and $build_root
!ll&&!rl&&r
1016
MC/DC66%2/3
$build_alienfile and $build_root and not defined $build
$build_alienfile $build_root not defined $build
Truth table75%3/4
A and B and not(C)
A= $build_alienfileB= $build_rootC= not defined $build
ABCresult
0XX0
10X0
1100
1111
542 {
543 15 $build = eval { Alien::Build->resume($build_alienfile, "$build_root/root") };
544 15 ▶ if($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 1 14 15
545 {
546 1 push @diag, "error in resume: $@";
547 1 $ok = 0;
548 }
549 else
550 {
551 14 $ok = 1;
552 }
553 }
554 else
555 {
556 2 ▶ if($build)
Branch: 1 branch
BranchTrueFalseTotal
if ($build) { } 1 1 2
557 {
558 1 push @diag, "build has not been checkpointed";
559 }
560 else
561 {
562 1 push @diag, "no build to resume";
563 }
564 2 $ok = 0;
565 }
566  
567 17 my $ctx = context();
568 17 $ctx->ok($ok, $name);
569 17 $ctx->diag($_) for @diag;
570 17 $ctx->release;
571  
572 17 ▶ ($ok && $build) || $ok;
Branch: 1 branch
BranchTrueFalseTotal
$ok and $build or $ok 14 3 17
Condition66%2/3
$ok and $build
!ll&&!rl&&r
3014
MC/DC50%1/2
$ok and $build
$ok $build
Truth table66%2/3
A and B
A= $okB= $build
ABresult
0X0
100
111
573 }
574  
575  
576 63 my $alien_rc_root;
577  
578 sub alien_rc
579 3 ▶{
Subroutine alien_rc: called CC=4 SCAR=14.4
Pod documented
580 3 my($code) = @_;
581  
582 3 ▶ croak "passed in undef rc" unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 3 3
583 3 ▶ croak "looks like you have already defined a rc.pl file" if $ENV{ALIEN_BUILD_RC} ne '-';
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"ALIEN_BUILD_RC"} ne "-" 0 3 3
584  
585 3 my(undef, $filename, $line) = caller;
586 3 my $code2 = "use strict; use warnings;\n" .
587 '# line ' . $line . ' "' . path($filename)->absolute . "\n$code";
588  
589 3 ▶ $alien_rc_root ||= Alien::Build::Temp->newdir;
Condition33%1/3
$alien_rc_root ||= "Alien::Build::Temp"->newdir
l!l&&r!l&&!r
030
MC/DC0%0/2
$alien_rc_root ||= "Alien::Build::Temp"->newdir
$alien_rc_root "Alien::Build::Temp"->newdir
Truth table33%1/3
A ||= B
A= $alien_rc_rootB= "Alien::Build::Temp"->newdir
ABresult
1X1
011
000
590  
591 3 my $rc = path($alien_rc_root)->child('rc.pl');
592 3 $rc->spew_utf8($code2);
593 3 $ENV{ALIEN_BUILD_RC} = "$rc";
594 3 return 1;
595 }
596  
597  
598 sub alien_subtest
599 63 ▶{
Subroutine alien_subtest: called CC=1 SCAR=0.0
Pod documented
600 63 my($name, $code, @args) = @_;
601  
602 63 _alienfile_clear;
603  
604 63 my $ctx = context();
605 63 my $pass = run_subtest($name, $code, { buffered => 1 }, @args);
606 63 $ctx->release;
607  
608 63 _alienfile_clear;
609  
610 63 $pass;
611 }
612  
613 63 delete $ENV{$_} for qw( ALIEN_BUILD_LOG ALIEN_BUILD_PRELOAD ALIEN_BUILD_POSTLOAD ALIEN_INSTALL_TYPE PKG_CONFIG_PATH ALIEN_BUILD_PKG_CONFIG );
614 63 $ENV{ALIEN_BUILD_RC} = '-';
615  
616 63 1;
617  
618 __END__
« blib/lib/Alien/Build/Plugin/Extract/Negotiate.pm ↑ Summary blib/lib/Alien/Build/Plugin/Build/CMake.pm »