blib/lib/Alien/Build/Plugin/PkgConfig/LibPkgConf.pm

filter: Statementstmt 42.5% 40 / 94 Branchbran 21.0% 8 / 38 Conditioncond 17.6% 3 / 17 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 72.7% 8 / 11 Podpod 100% 2 / 2 totaltotal 35.8% 61 / 170 CC 30 SCAR 44.8
CC
30
Cov
34%
__ANON__
156.0
init
88.1
__ANON__
72.0
CRAP 87.8
« blib/lib/Test/Alien.pm ↑ Summary corpus/lib/Alien/Foo1/ConfigData.pm »
1 package Alien::Build::Plugin::PkgConfig::LibPkgConf;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Alien::Build::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Probe system and determine library or tool properties using PkgConfig::LibPkgConf
10 7 our $VERSION = '2.88'; # VERSION
11  
12  
13 0 ▶has '+pkg_name' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 0 Carp::croak "pkg_name is a required property";
15 7 };
16  
17  
18 7 has atleast_version => undef;
19  
20  
21 7 has exact_version => undef;
22  
23  
24 7 has max_version => undef;
25  
26  
27 7 has minimum_version => undef;
28  
29 # private for now, used by negotiator
30 7 has register_prereqs => 1;
31  
32  
33 7 ▶use constant _min_version => '0.04';
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 sub available
36 13 ▶{
Subroutine available: called CC=1 SCAR=0.0
Pod documented
37 13 !!eval { require PkgConfig::LibPkgConf; PkgConfig::LibPkgConf->VERSION(_min_version) };
38 }
39  
40 sub init
41 3 ▶{
Subroutine init: called CC=12 SCAR=44.8
Pod documented
42 3 my($self, $meta) = @_;
43  
44 3 ▶ unless(defined $meta->prop->{env}->{PKG_CONFIG})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $meta->prop->{"env"}{"PKG_CONFIG"}) 3 0 3
45 {
46 # TODO: this doesn't yet find pkgconf in the bin dir of a share
47 # install.
48 3 ▶ my $command_line =
Branch: 2 branches
BranchTrueFalseTotal
File::Which::which('pkgconf') ? : 0 3 3
File::Which::which('pkg-config') ? : 0 3 3
49 File::Which::which('pkgconf')
50 ? 'pkgconf'
51 : File::Which::which('pkg-config')
52 ? 'pkg-config'
53 : undef;
54 3 ▶ $meta->prop->{env}->{PKG_CONFIG} = $command_line
Branch: 1 branch
BranchTrueFalseTotal
if defined $command_line 0 3 3
55 if defined $command_line;
56 }
57  
58 3 ▶ if($self->register_prereqs)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->register_prereqs) 1 2 3
59 {
60 # Also update in Neotiate.pm
61 1 $meta->add_requires('configure' => 'PkgConfig::LibPkgConf::Client' => _min_version);
62  
63 1 ▶ if(defined $self->minimum_version || defined $self->atleast_version || defined $self->exact_version || defined $self->max_version)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->minimum_version or defined $self->atleast_version or defined $self->exact_version or defined $self->max_version) 1 0 1
Condition33%3/9
defined $self->minimum_version or defined $self->atleast_version or defined $self->exact_version or defined $self->max_version
l!l&&r!l&&!r
100
defined $self->minimum_version or defined $self->atleast_version or defined $self->exact_version
l!l&&r!l&&!r
100
defined $self->minimum_version or defined $self->atleast_version
l!l&&r!l&&!r
100
MC/DC0%0/4
defined $self->minimum_version or defined $self->atleast_version or defined $self->exact_version or defined $self->max_version
defined $self->minimum_version defined $self->atleast_version defined $self->exact_version defined $self->max_version
Truth table20%1/5
A or B or C or D
A= defined $self->minimum_versionB= defined $self->atleast_versionC= defined $self->exact_versionD= defined $self->max_version
ABCDresult
1XXX1
01XX1
001X1
00011
00000
64 {
65 1 $meta->add_requires('configure' => 'PkgConfig::LibPkgConf::Util' => _min_version);
66 }
67 }
68  
69 0 ▶ my($pkg_name, @alt_names) = (ref $self->pkg_name) ? (@{ $self->pkg_name }) : ($self->pkg_name);
Branch: 1 branch
BranchTrueFalseTotal
ref $self->pkg_name ? : 0 3 3
70  
71 $meta->register_hook(
72 0 ▶ probe => sub {
Subroutine __ANON__: not called CC=12 SCAR=50.5
73 0 my($build) = @_;
74 0 ▶ $build->runtime_prop->{legacy}->{name} ||= $pkg_name;
Condition0%0/3
$build->runtime_prop->{"legacy"}{"name"} ||= $pkg_name
l!l&&r!l&&!r
000
MC/DC0%0/2
$build->runtime_prop->{"legacy"}{"name"} ||= $pkg_name
$build->runtime_prop->{"legacy"}{"name"} $pkg_name
Truth table0%0/3
A ||= B
A= $build->runtime_prop->{"legacy"}{"name"}B= $pkg_name
ABresult
1X1
011
000
75  
76 0 $build->hook_prop->{probe_class} = __PACKAGE__;
77 0 $build->hook_prop->{probe_instance_id} = $self->instance_id;
78  
79 0 require PkgConfig::LibPkgConf::Client;
80 0 my $client = PkgConfig::LibPkgConf::Client->new;
81 0 my $pkg = $client->find($pkg_name);
82 0 ▶ die "package $pkg_name not found" unless $pkg;
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg 0 0 0
83  
84 0 $build->hook_prop->{version} = $pkg->version;
85 0 my $atleast_version = $self->atleast_version;
86 0 ▶ $atleast_version = $self->minimum_version unless defined $self->atleast_version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->atleast_version 0 0 0
87 0 ▶ if($atleast_version)
Branch: 1 branch
BranchTrueFalseTotal
if ($atleast_version) 0 0 0
88 {
89 0 require PkgConfig::LibPkgConf::Util;
90 0 ▶ if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $atleast_version) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $atleast_version) < 0) 0 0 0
91 {
92 0 die "package $pkg_name is version @{[ $pkg->version ]}, but at least $atleast_version is required.";
93 }
94 }
95  
96 0 ▶ if($self->exact_version)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->exact_version) 0 0 0
97 {
98 0 require PkgConfig::LibPkgConf::Util;
99 0 ▶ if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $self->exact_version) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $self->exact_version) != 0) 0 0 0
100 {
101 0 die "package $pkg_name is version @{[ $pkg->version ]}, but exactly @{[ $self->exact_version ]} is required.";
102 }
103 }
104  
105 0 ▶ if($self->max_version)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->max_version) 0 0 0
106 {
107 0 require PkgConfig::LibPkgConf::Util;
108 0 ▶ if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $self->max_version) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $self->max_version) > 0) 0 0 0
109 {
110 0 die "package $pkg_name is version @{[ $pkg->version ]}, but max @{[ $self->max_version ]} is required.";
111 }
112 }
113  
114 0 foreach my $alt (@alt_names)
115 {
116 0 my $pkg = $client->find($alt);
117 0 ▶ die "package $alt not found" unless $pkg;
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg 0 0 0
118 }
119  
120 0 'system';
121 },
122 3 );
123  
124 $meta->register_hook(
125 0 ▶ $_ => sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
126 0 my($build) = @_;
127  
128 return if $build->hook_prop->{name} eq 'gather_system'
129 0 ▶ && ($build->install_prop->{system_probe_instance_id} || '') ne $self->instance_id;
Branch: 1 branch
BranchTrueFalseTotal
if $build->hook_prop->{"name"} eq "gather_system" and ($build->install_prop->{"system_probe_instance_id"} || "") ne $self->instance_id 0 0 0
Condition0%0/5
$build->hook_prop->{"name"} eq "gather_system" and ($build->install_prop->{"system_probe_instance_id"} || "") ne $self->instance_id
!ll&&!rl&&r
000
$build->install_prop->{'system_probe_instance_id'} || ''
l!l
00
MC/DC0%0/2
$build->hook_prop->{"name"} eq "gather_system" and ($build->install_prop->{"system_probe_instance_id"} || "") ne $self->instance_id
$build->hook_prop->{"name"} eq "gather_system" $build->install_prop->{'system_probe_instance_id'}
Truth table0%0/3
A and B
A= $build->hook_prop->{"name"} eq "gather_system"B= $build->install_prop->{'system_probe_instance_id'}
ABresult
0X0
100
111
130  
131 0 require PkgConfig::LibPkgConf::Client;
132 0 my $client = PkgConfig::LibPkgConf::Client->new;
133  
134 0 foreach my $name ($pkg_name, @alt_names)
135 {
136 0 my $pkg = $client->find($name);
137 0 ▶ die "reload of package $name failed" unless defined $pkg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pkg 0 0 0
138  
139 0 my %prop;
140 0 $prop{version} = $pkg->version;
141 0 $prop{cflags} = $pkg->cflags;
142 0 $prop{libs} = $pkg->libs;
143 0 $prop{cflags_static} = $pkg->cflags_static;
144 0 $prop{libs_static} = $pkg->libs_static;
145 0 $build->runtime_prop->{alt}->{$name} = \%prop;
146 }
147  
148 0 foreach my $key (keys %{ $build->runtime_prop->{alt}->{$pkg_name} })
149 {
150 0 $build->runtime_prop->{$key} = $build->runtime_prop->{alt}->{$pkg_name}->{$key};
151 }
152  
153 0 ▶ if(keys %{ $build->runtime_prop->{alt} } == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$build->runtime_prop->{"alt"};} == 1) 0 0 0
154 {
155 0 delete $build->runtime_prop->{alt};
156 }
157 },
158 3 ) for qw( gather_system gather_share );
159  
160 3 $self;
161 }
162  
163 7 1;
164  
165 __END__
« blib/lib/Test/Alien.pm ↑ Summary corpus/lib/Alien/Foo1/ConfigData.pm »