blib/lib/Test/Alien/Diag.pm

filter: Statementstmt 100% 62 / 62 Branchbran 95.0% 19 / 20 Conditioncond 85.7% 6 / 7 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 97.0% 97 / 100 CC 22 SCAR 29.0
CC
22
Cov
98%
alien_diag
22.0
BEGIN
1.0
BEGIN
1.0
CRAP 18.1
« blib/lib/Alien/Build/Plugin/Extract/CommandLine.pm ↑ Summary blib/lib/Alien/Build/Plugin/Download/Negotiate.pm »
1 package Test::Alien::Diag;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Test2::API qw( context );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our @EXPORT = qw( alien_diag );
10 2 our @EXPORT_OK = @EXPORT;
11  
12 # ABSTRACT: Print out standard diagnostic for Aliens in the test step.
13 2 our $VERSION = '2.88'; # VERSION
14  
15  
16 2 my @default_scalar_properties = qw(
17 cflags cflags_static libs libs_static version install_type
18 );
19  
20 2 my @default_list_properties = qw(
21 dynamic_libs bin_dir
22 );
23  
24 sub alien_diag ($@)
25 7 ▶{
Subroutine alien_diag: called CC=22 SCAR=30.9
Pod documented
26 7 my $ctx = context();
27  
28 7 ▶ my %options = defined $_[-1] && ref($_[-1]) eq 'HASH' ? %{ pop @_ } : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $_[-1] && ref $_[-1] eq 'HASH' ? : 4 3 7
Condition66%2/3
defined $_[-1] and ref $_[-1] eq "HASH"
!ll&&!rl&&r
034
MC/DC50%1/2
defined $_[-1] and ref $_[-1] eq "HASH"
defined $_[-1] ref $_[-1] eq "HASH"
Truth table66%2/3
A and B
A= defined $_[-1]B= ref $_[-1] eq "HASH"
ABresult
0X0
100
111
29  
30 7 ▶ my @extra_properties = @{ delete $options{properties} || [] };
Condition100%2/2
delete $options{'properties'} || []
l!l
43
MC/DC100%1/1
delete $options{'properties'} || []
delete $options{'properties'}
Truth table100%2/2
A
A= delete $options{'properties'}
Aresult
11
00
31 7 ▶ my @extra_list_properties = @{ delete $options{list_properties} || [] };
Condition100%2/2
delete $options{'list_properties'} || []
l!l
43
MC/DC100%1/1
delete $options{'list_properties'} || []
delete $options{'list_properties'}
Truth table100%2/2
A
A= delete $options{'list_properties'}
Aresult
11
00
32  
33 7 my $max = 0;
34 7 foreach my $alien (@_)
35 {
36 9 foreach my $name (@default_scalar_properties, @default_list_properties, @extra_properties, @extra_list_properties)
37 {
38 84 ▶ if(eval { $alien->can($name) })
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $alien->can($name) } }) 28 56 84
39 {
40 28 my $str = "$alien->$name";
41 28 ▶ if(length($str) > $max)
Branch: 1 branch
BranchTrueFalseTotal
if (length $str > $max) 13 15 28
42 {
43 13 $max = length($str);
44 }
45 }
46 }
47 }
48  
49  
50 7 $ctx->diag('');
51  
52 7 ▶ if(%options)
Branch: 1 branch
BranchTrueFalseTotal
if (%options) 2 5 7
53 {
54 2 my @extra = sort keys %options;
55 2 ▶ $ctx->diag("warning: unknown option@{[ @extra > 1 ? 's' : '' ]} for alien_diag: @extra");
Branch: 1 branch
BranchTrueFalseTotal
@extra > 1 ? : 1 1 2
56 2 $ctx->diag("(you should check for typos or maybe upgrade to a newer version of Alien::Build)");
57 }
58  
59  
60 7 foreach my $alien (@_) {
61 9 $ctx->diag('') for 1..2;
62  
63 9 my $found = 0;
64  
65 9 foreach my $name (sort(@default_scalar_properties, @extra_properties))
66 {
67 60 ▶ if(eval { $alien->can($name) })
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $alien->can($name) } }) 20 40 60
68 {
69 20 $found++;
70 20 my $value = $alien->$name;
71 20 ▶ $value = '[undef]' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 4 16 20
72 20 $ctx->diag(sprintf "%-${max}s = %s", "$alien->$name", $value);
73 }
74 }
75  
76 9 foreach my $name (sort(@default_list_properties, @extra_list_properties))
77 {
78 24 ▶ if(eval { $alien->can($name) })
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $alien->can($name) } }) 8 16 24
79 {
80 8 $found++;
81 8 my @list = eval { $alien->$name };
82 8 ▶ next if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 8 8
83 8 $ctx->diag(sprintf "%-${max}s = %s", "$alien->$name", $_) for @list;
84 }
85 }
86  
87 9 ▶ $ctx->diag("no diagnostics found for $alien") unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 1 8 9
88 }
89  
90 7 $ctx->diag('') for 1..2;
91  
92 7 $ctx->release;
93 }
94  
95 2 1;
96  
97 __END__
« blib/lib/Alien/Build/Plugin/Extract/CommandLine.pm ↑ Summary blib/lib/Alien/Build/Plugin/Download/Negotiate.pm »