blib/lib/CPAN/Testers/ParseReport.pm

filter: Statementstmt 69.9% 588 / 841 Branchbran 58.6% 326 / 556 Conditioncond 59.6% 108 / 181 MC/DCmcdc 46.8% 52 / 111 Subroutinesub 93.7% 30 / 32 Podpod 100% 4 / 4 totaltotal 64.2% 1108 / 1725 CC 364 SCAR 60.4
CC
364
Cov
65%
parse_single_report
1584.7
_download_overview
1246.6
parse_report
237.3
CRAP 418.6
↑ Summary blib/lib/CPAN/Testers/dagolden-reversion-gist.pl »
1 package CPAN::Testers::ParseReport;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Compress::Zlib ('$gzerrno');
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 my $LOADED = eval { require DateTime::Format::Strptime; 1; }; # uses Params::Util which may cause loading warnings with perl 5.8.9
8 5 ▶die $@ if !$LOADED and $@;
Branch: 1 branch
BranchTrueFalseTotal
if not $LOADED and $@ 0 5 5
Condition33%1/3
not $LOADED and $@
!ll&&!rl&&r
500
MC/DC0%0/2
not $LOADED and $@
not $LOADED $@
Truth table33%1/3
not(A) and B
A= not $LOADEDB= $@
ABresult
0X0
100
111
9 5 ▶use File::Basename qw(basename);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use File::Path qw(mkpath);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use File::ReadBackwards;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use HTML::Entities qw(decode_entities);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use JSON::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use List::AllUtils qw(uniq max min sum);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use MIME::QuotedPrint ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use Time::Local ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use Time::HiRes;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 5 our $default_distrotransport = "ctjson";
22 5 our $default_transport = "http_cpantesters";
23 5 our $default_cturl = "https://api.cpantesters.org";
24 5 our $Signal = 0;
25  
26 =encoding utf-8
27  
28 =head1 NAME
29  
30 CPAN::Testers::ParseReport - parse reports to www.cpantesters.org from various sources
31  
32 =cut
33  
34 5 ▶use version; our $VERSION = qv('0.6.0');
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 =head1 SYNOPSIS
37  
38 The documentation in here is normally not needed because the code is
39 meant to be run from the standalone program C<ctgetreports>.
40  
41 ctgetreports --q mod:Moose Devel-Events
42  
43 =head1 DESCRIPTION
44  
45 This is the core module for CPAN::Testers::ParseReport. If you're not
46 looking to extend or alter the behaviour of this module, you probably
47 want to look at L<ctgetreports> instead.
48  
49 =head1 OPTIONS
50  
51 Options are described in the L<ctgetreports> manpage and are passed
52 through to the functions unaltered.
53  
54 =head1 FUNCTIONS
55  
56 =head2 parse_distro($distro,%options)
57  
58 reads the cpantesters JSON file or the local database for the distro
59 and loops through the reports for the specified or most recent version
60 of that distro found in these data.
61  
62 parse_distro() intentionally has no meaningful return value, different
63 options would require different ones.
64  
65 =head2 $extract = parse_single_report($report,$dumpvars,%options)
66  
67 mirrors and reads this report. $report is of the form
68  
69 { guid => <guid>, }
70  
71 $dumpvar is a hashreference that gets filled with data.
72  
73 $extract is the result of parse_report() described below.
74  
75 =cut
76  
77 # A mapping of v3 API osname to a user-friendly label for the OS
78 # to use in reporting.
79 # TODO: This should probably be done by the API instead of here...
80 5 my %OSNAME = (
81 aix => 'AIX',
82 bsdos => 'BSD/OS',
83 cygwin => "Windows (Cygwin)",
84 darwin => "Mac OS X",
85 dec_osf => "Tru64",
86 dragonfly => "Dragonfly BSD",
87 freebsd => "FreeBSD",
88 gnu => "GNU Hurd",
89 haiku => "Haiku",
90 hpux => "HP-UX",
91 irix => "IRIX",
92 linux => "GNU/Linux",
93 macos => "Mac OS classic",
94 midnightbsd => "MidnightBSD",
95 mirbsd => "MirOS BSD",
96 mswin32 => "Windows (Win32)",
97 netbsd => "NetBSD",
98 openbsd => "OpenBSD",
99 os2 => "OS/2",
100 os390 => "OS390/zOS",
101 gnukfreebsd => "Debian GNU/kFreeBSD",
102 sco => "SCO",
103 solaris => "SunOS/Solaris",
104 vms => "VMS",
105 beos => "BeOS",
106 interix => "Interix",
107 nto => "QNX Neutrino",
108 minix => "MINIX",
109 bitrig => "BITRIG",
110 Mac => "MAC",
111 );
112  
113 {
114 5 my $ua;
115 0 ▶ sub _ua {
Subroutine _ua: not called CC=2 SCAR=17.9
116 0 ▶ return $ua if $ua;
Branch: 1 branch
BranchTrueFalseTotal
if $ua 0 0 0
117 0 $ua = LWP::UserAgent->new
118 (
119 keep_alive => 1,
120 env_proxy => 1,
121 timeout => 900,
122 );
123 0 $ua->parse_head(0);
124 0 $ua;
125 }
126 }
127 {
128 5 my $ua;
129 0 ▶ sub _ua_gzip {
Subroutine _ua_gzip: not called CC=2 SCAR=17.9
130 0 ▶ return $ua if $ua;
Branch: 1 branch
BranchTrueFalseTotal
if $ua 0 0 0
131 0 $ua = LWP::UserAgent->new
132 (
133 keep_alive => 1,
134 env_proxy => 1,
135 );
136 0 $ua->parse_head(0);
137 0 $ua->default_header('Accept-Encoding' => scalar HTTP::Message::decodable());
138 0 $ua;
139 }
140 }
141  
142 {
143 # we called it yaml because it was yaml; now it is json
144 5 my $j = JSON::XS->new->ascii->pretty;
145 9 ▶ sub _slurp {
Subroutine _slurp: called CC=2 SCAR=7.0
146 9 my($file) = @_;
147 9 local $/;
148 9 ▶ open my $fh, $file or die "Could not open '$file': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, $file or die "Could not open '${file}': $!" 9 0 9
149 9 <$fh>;
150 }
151 9 ▶ sub _yaml_loadfile {
Subroutine _yaml_loadfile: called CC=2 SCAR=9.2
152 9 my $file = shift;
153 9 my $content = _slurp $file;
154 # $DB::single = 1;
155 9 ▶ if ($file =~ /\.ndjson$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /\.ndjson$/) 0 9 9
156 0 $content =~ s/}$/},/gm;
157 0 $content =~ s/,\s*\z//;
158 0 $content =~ s/^/\[/s;
159 0 $content =~ s/\z/\]/s;
160 }
161 9 $j->decode($content);
162 }
163 5 ▶ sub _yaml_dump {
Subroutine _yaml_dump: called CC=1 SCAR=0.0
164 5 $j->encode(shift);
165 }
166 }
167  
168 5 ▶sub _download_overview {
Subroutine _download_overview: called CC=41 SCAR=71.3
169 5 my($cts_dir, $distro, %Opt) = @_;
170 5 ▶ my $cturl = $Opt{cturl} ||= $default_cturl;
Condition33%1/3
$Opt{"cturl"} ||= $CPAN::Testers::ParseReport::default_cturl
l!l&&r!l&&!r
050
MC/DC0%0/2
$Opt{"cturl"} ||= $CPAN::Testers::ParseReport::default_cturl
$Opt{"cturl"} $CPAN::Testers::ParseReport::default_cturl
Truth table33%1/3
A ||= B
A= $Opt{"cturl"}B= $CPAN::Testers::ParseReport::default_cturl
ABresult
1X1
011
000
171 5 ▶ $Opt{distrotransport} ||= $default_distrotransport;
Condition33%1/3
$Opt{"distrotransport"} ||= $CPAN::Testers::ParseReport::default_distrotransport
l!l&&r!l&&!r
050
MC/DC0%0/2
$Opt{"distrotransport"} ||= $CPAN::Testers::ParseReport::default_distrotransport
$Opt{"distrotransport"} $CPAN::Testers::ParseReport::default_distrotransport
Truth table33%1/3
A ||= B
A= $Opt{"distrotransport"}B= $CPAN::Testers::ParseReport::default_distrotransport
ABresult
1X1
011
000
172 5 ▶ my $extension = $Opt{distrotransport} eq "ndjson" ? "ndjson" : "json";
Branch: 1 branch
BranchTrueFalseTotal
$Opt{'distrotransport'} eq 'ndjson' ? : 0 5 5
173 5 my $ctarget = "$cts_dir/$distro.$extension";
174 5 my $cheaders = "$cts_dir/$distro.headers";
175 5 ▶ if ($Opt{local}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{'local'}) { } 5 0 5
176 5 ▶ unless (-e $ctarget) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $ctarget) 0 5 5
177 0 die "Alert: No local file '$ctarget' found, cannot continue\n";
178 }
179 } else {
180 0 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $Opt{'distrotransport'} eq 'ctjson' }) { } 0 0 0
elsif ($Opt{'distrotransport'} eq 'ndjson') { } 0 0 0
181 } elsif ($Opt{distrotransport} eq "ctjson") {
182 0 ▶ if (! -e $ctarget or -M $ctarget > .25) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $ctarget or -M $ctarget > "0.25") 0 0 0
Condition0%0/3
not -e $ctarget or -M $ctarget > "0.25"
l!l&&r!l&&!r
000
MC/DC0%0/2
not -e $ctarget or -M $ctarget > "0.25"
not -e $ctarget -M $ctarget > "0.25"
Truth table0%0/3
not(A) or B
A= not -e $ctargetB= -M $ctarget > "0.25"
ABresult
1X1
011
000
183 0 ▶ if (-e $ctarget && $Opt{verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $ctarget and $Opt{"verbose"}) 0 0 0
Condition0%0/3
-e $ctarget and $Opt{"verbose"}
!ll&&!rl&&r
000
MC/DC0%0/2
-e $ctarget and $Opt{"verbose"}
-e $ctarget $Opt{"verbose"}
Truth table0%0/3
A and B
A= -e $ctargetB= $Opt{"verbose"}
ABresult
0X0
100
111
184 0 my(@stat) = stat _;
185 0 my $timestamp = gmtime $stat[9];
186 0 ▶ print STDERR "(timestamp $timestamp GMT)\n" unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
187 }
188 0 my $uri = "$cturl/v3/summary/$distro";
189 0 ▶ print STDERR "Fetching $ctarget ($uri)...\n" if $Opt{verbose} && !$Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
if $Opt{"verbose"} and not $Opt{"quiet"} 0 0 0
Condition0%0/3
$Opt{"verbose"} and not $Opt{"quiet"}
!ll&&!rl&&r
000
MC/DC0%0/2
$Opt{"verbose"} and not $Opt{"quiet"}
$Opt{"verbose"} not $Opt{"quiet"}
Truth table0%0/3
A and not(B)
A= $Opt{"verbose"}B= not $Opt{"quiet"}
ABresult
0X0
100
111
190 0 my $resp = _ua->mirror($uri,$ctarget); # should most probably be _ua_gip, but then we need to deal with uncompressing
191 0 ▶ if ($resp->is_success) {
Branch: 2 branches
BranchTrueFalseTotal
if ($resp->is_success) { } 0 0 0
elsif (304 == $resp->code) { } 0 0 0
192 0 ▶ print STDERR "DONE\n" if $Opt{verbose} && !$Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
if $Opt{"verbose"} and not $Opt{"quiet"} 0 0 0
Condition0%0/3
$Opt{"verbose"} and not $Opt{"quiet"}
!ll&&!rl&&r
000
MC/DC0%0/2
$Opt{"verbose"} and not $Opt{"quiet"}
$Opt{"verbose"} not $Opt{"quiet"}
Truth table0%0/3
A and not(B)
A= $Opt{"verbose"}B= not $Opt{"quiet"}
ABresult
0X0
100
111
193 0 ▶ open my $fh, ">", $cheaders or die;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $cheaders or die 0 0 0
194 0 for ($resp->headers->as_string) {
195 0 print $fh $_;
196 0 ▶ if ($Opt{verbose} && $Opt{verbose}>1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"verbose"} and $Opt{"verbose"} > 1) 0 0 0
Condition0%0/3
$Opt{"verbose"} and $Opt{"verbose"} > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$Opt{"verbose"} and $Opt{"verbose"} > 1
$Opt{"verbose"} $Opt{"verbose"} > 1
Truth table0%0/3
A and B
A= $Opt{"verbose"}B= $Opt{"verbose"} > 1
ABresult
0X0
100
111
197 0 ▶ print STDERR $_ unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
198 }
199 }
200 } elsif (304 == $resp->code) {
201 0 ▶ print STDERR "DONE (not modified)\n" if $Opt{verbose} && !$Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
if $Opt{"verbose"} and not $Opt{"quiet"} 0 0 0
Condition0%0/3
$Opt{"verbose"} and not $Opt{"quiet"}
!ll&&!rl&&r
000
MC/DC0%0/2
$Opt{"verbose"} and not $Opt{"quiet"}
$Opt{"verbose"} not $Opt{"quiet"}
Truth table0%0/3
A and not(B)
A= $Opt{"verbose"}B= not $Opt{"quiet"}
ABresult
0X0
100
111
202 0 my $atime = my $mtime = time;
203 0 utime $atime, $mtime, $cheaders;
204 } else {
205 0 die sprintf
206 (
207 "No success downloading %s: %s",
208 $uri,
209 $resp->status_line,
210 );
211 }
212 }
213 } elsif ($Opt{distrotransport} eq "ndjson") {
214 0 ▶ my $ndjsonurl = $Opt{ndjsonurl} or die "missing option --ndjsonurl";
Branch: 1 branch
BranchTrueFalseTotal
my $ndjsonurl = $Opt{"ndjsonurl"} or die "missing option --ndjsonurl" 0 0 0
215 0 my($uri);
216 0 ▶ if ( -e $ctarget ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $ctarget) { } 0 0 0
217 0 ▶ my $bw = File::ReadBackwards->new( $ctarget )
Branch: 1 branch
BranchTrueFalseTotal
my $bw = "File::ReadBackwards"->new($ctarget) or die "can't read '${ctarget}': $!" 0 0 0
218 or die "can't read '$ctarget': $!" ;
219 0 my($log_line, $highestguid);
220 0 my $j = JSON::XS->new;
221 0 ▶ BW: while( defined( $log_line = $bw->readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($log_line = $bw->readline)) 0 0 0
222 0 my $h = $j->decode($log_line);
223 0 ▶ if ($highestguid = $h->{guid}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($highestguid = $h->{"guid"}) 0 0 0
224 0 last BW;
225 }
226 }
227 0 ▶ if ($highestguid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($highestguid) { } 0 0 0
228 0 $uri = "$ndjsonurl?dist=$distro&after=$highestguid";
229 } else {
230 0 $uri = "$ndjsonurl?dist=$distro";
231 }
232 } else {
233 0 $uri = "$ndjsonurl?dist=$distro";
234 }
235 0 my $resp = _ua->get($uri);
236 0 ▶ if ($resp->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resp->is_success) { } 0 0 0
237 0 ▶ print STDERR "DONE\n" if $Opt{verbose} && !$Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
if $Opt{"verbose"} and not $Opt{"quiet"} 0 0 0
Condition0%0/3
$Opt{"verbose"} and not $Opt{"quiet"}
!ll&&!rl&&r
000
MC/DC0%0/2
$Opt{"verbose"} and not $Opt{"quiet"}
$Opt{"verbose"} not $Opt{"quiet"}
Truth table0%0/3
A and not(B)
A= $Opt{"verbose"}B= not $Opt{"quiet"}
ABresult
0X0
100
111
238 0 ▶ open my $fh, ">", $cheaders or die;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $cheaders or die 0 0 0
239 0 for ($resp->headers->as_string) {
240 0 print $fh $_;
241 0 ▶ if ($Opt{verbose} && $Opt{verbose}>1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"verbose"} and $Opt{"verbose"} > 1) 0 0 0
Condition0%0/3
$Opt{"verbose"} and $Opt{"verbose"} > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$Opt{"verbose"} and $Opt{"verbose"} > 1
$Opt{"verbose"} $Opt{"verbose"} > 1
Truth table0%0/3
A and B
A= $Opt{"verbose"}B= $Opt{"verbose"} > 1
ABresult
0X0
100
111
242 0 ▶ print STDERR $_ unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
243 }
244 }
245 0 ▶ open $fh, ">>", $ctarget or die "could not open >>'$ctarget': $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">>", $ctarget or die "could not open >>'${ctarget}': $!" 0 0 0
246 0 print $fh $resp->content;
247 } else {
248 0 die sprintf
249 (
250 "No success downloading %s: %s",
251 $uri,
252 $resp->status_line,
253 );
254 }
255 } else {
256 0 die {severity=>0, text=>"Unknown distrotransport '$Opt{distrotransport}'"};
257 }
258 }
259 5 return $ctarget;
260 }
261  
262 5 ▶sub _parse_yaml {
Subroutine _parse_yaml: called CC=10 SCAR=26.2
263 5 my($ctarget, %Opt) = @_;
264 5 my $arr = _yaml_loadfile($ctarget);
265 5 my($selected_release_ul,$selected_release_distrov,$excuse_string);
266 5 ▶ if ($Opt{vdistro}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{'vdistro'}) { } 0 5 5
267 0 $excuse_string = "selected distro '$Opt{vdistro}'";
268 0 ▶ $arr = [grep { ($_->{distversion}||=join("-",$_->{dist},$_->{version})) eq $Opt{vdistro} } @$arr];
Condition0%0/3
$_->{"distversion"} ||= join("-", $_->{"dist"}, $_->{"version"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{"distversion"} ||= join("-", $_->{"dist"}, $_->{"version"})
$_->{"distversion"} join("-", $_->{"dist"}, $_->{"version"})
Truth table0%0/3
A ||= B
A= $_->{"distversion"}B= join("-", $_->{"dist"}, $_->{"version"})
ABresult
1X1
011
000
269 0 ($selected_release_distrov) = $arr->[0]{distversion};
270 } else {
271 # To find the "latest" version of the dist, we used to sort by the report's numeric ID
272 # and use the last newly-seen dist-version. The new API does not have the numeric ID, but it
273 # does have an ISO-8601 date/time string...
274 5 $excuse_string = "any distro";
275 5 my $last_addition;
276 my %seen;
277 5 for my $report (sort { $a->{date} cmp $b->{date} } @$arr) {
278 1745 ▶ $report->{distversion}||=join("-",$report->{dist},$report->{version});
Condition33%1/3
$report->{"distversion"} ||= join("-", $report->{"dist"}, $report->{"version"})
l!l&&r!l&&!r
174500
MC/DC0%0/2
$report->{"distversion"} ||= join("-", $report->{"dist"}, $report->{"version"})
$report->{"distversion"} join("-", $report->{"dist"}, $report->{"version"})
Truth table33%1/3
A ||= B
A= $report->{"distversion"}B= join("-", $report->{"dist"}, $report->{"version"})
ABresult
1X1
011
000
279 1745 ▶ unless ($seen{$report->{distversion}}++) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen{$report->{"distversion"}}++) 95 1650 1745
280 95 $last_addition = $report->{distversion};
281 }
282 }
283 5 $arr = [grep {$_->{distversion} eq $last_addition} @$arr];
284 5 ($selected_release_distrov) = $last_addition;
285 }
286 5 ▶ unless ($selected_release_distrov) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($selected_release_distrov) 0 5 5
287 0 warn "Warning: could not find $excuse_string in '$ctarget'";
288 0 return;
289 }
290 5 ▶ print STDERR "SELECTED: $selected_release_distrov\n" unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 5 5
291 5 my @all;
292 5 for my $test (@$arr) {
293 push @all, {
294 guid => $test->{guid},
295 650 };
296 650 ▶ return if $Signal;
Branch: 1 branch
BranchTrueFalseTotal
if $CPAN::Testers::ParseReport::Signal 0 650 650
297 }
298 5 @all = sort { $b->{guid} cmp $a->{guid} } @all;
299 5 return \@all;
300 }
301  
302 495 ▶sub parse_single_report {
Subroutine parse_single_report: called CC=44 SCAR=73.7
Pod documented
303 495 my($report, $dumpvars, %Opt) = @_;
304 495 my($guid) = $report->{guid};
305 495 ▶ $Opt{cachedir} ||= "$ENV{HOME}/var/cpantesters";
Condition50%1/2
$Opt{"cachedir"} ||= qq[$ENV{"HOME"}/var/cpantesters]
l!l
4950
MC/DC0%0/1
$Opt{"cachedir"} ||= qq[$ENV{"HOME"}/var/cpantesters]
$Opt{"cachedir"}
Truth table50%1/2
A
A= $Opt{"cachedir"}
Aresult
11
00
306 495 ▶ my $cturl = $Opt{cturl} ||= $default_cturl;
Condition33%1/3
$Opt{"cturl"} ||= $CPAN::Testers::ParseReport::default_cturl
l!l&&r!l&&!r
04950
MC/DC0%0/2
$Opt{"cturl"} ||= $CPAN::Testers::ParseReport::default_cturl
$Opt{"cturl"} $CPAN::Testers::ParseReport::default_cturl
Truth table33%1/3
A ||= B
A= $Opt{"cturl"}B= $CPAN::Testers::ParseReport::default_cturl
ABresult
1X1
011
000
307 # the name nntp-testers was picked because originally the reports
308 # were available from an NNTP server
309 495 my $nnt_dir = "$Opt{cachedir}/nntp-testers";
310 495 mkpath $nnt_dir;
311 495 my $target = "$nnt_dir/$guid";
312 495 ▶ if ($Opt{local}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{'local'}) { } 495 0 495
313 495 ▶ unless (-e $target) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $target) 0 495 495
314 0 die {severity=>0,text=>"Warning: No local file '$target' found, skipping\n"};
315 }
316 } else {
317 0 ▶ $Opt{transport} ||= $default_transport;
Condition0%0/3
$Opt{"transport"} ||= $CPAN::Testers::ParseReport::default_transport
l!l&&r!l&&!r
000
MC/DC0%0/2
$Opt{"transport"} ||= $CPAN::Testers::ParseReport::default_transport
$Opt{"transport"} $CPAN::Testers::ParseReport::default_transport
Truth table0%0/3
A ||= B
A= $Opt{"transport"}B= $CPAN::Testers::ParseReport::default_transport
ABresult
1X1
011
000
318 0 my $ttarget;
319 0 ▶ if (-e $target) {
Branch: 2 branches
BranchTrueFalseTotal
if (-e $target) { } 0 0 0
elsif (-e "$target.gz") { } 0 0 0
320 0 $ttarget = $target;
321 } elsif (-e "$target.gz") {
322 0 $ttarget = "$target.gz";
323 }
324 0 ▶ if ($ttarget) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ttarget) 0 0 0
325 0 my $raw_report;
326 0 ▶ open my $fh, $ttarget or die "Could not open '$ttarget': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, $ttarget or die "Could not open '${ttarget}': $!" 0 0 0
327 0 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $Opt{'transport'} eq 'http_cpantesters' }) { } 0 0 0
elsif ($Opt{'transport'} eq 'http_cpantesters_gzip') { } 0 0 0
328 } elsif ($Opt{transport} eq "http_cpantesters") {
329 0 local $/;
330 0 $raw_report = <$fh>;
331 } elsif ($Opt{transport} eq "http_cpantesters_gzip") {
332 0 my $gz = Compress::Zlib::gzopen($fh, "rb");
333 0 $raw_report = "";
334 0 my $buffer;
335 0 ▶ while (my $bytesread = $gz->gzread($buffer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bytesread = $gz->gzread($buffer)) 0 0 0
336 0 $raw_report .= $buffer;
337 }
338 }
339 0 ▶ if ($raw_report =~ m{<title>.*(Report not found|Error).*</title>}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raw_report =~ m[<title>.*(Report not found|Error).*</title>]) 0 0 0
340 0 ▶ unlink $ttarget or die "Could not unlink '$ttarget': $!";
Branch: 1 branch
BranchTrueFalseTotal
unlink $ttarget or die "Could not unlink '${ttarget}': $!" 0 0 0
341 }
342 }
343 0 ▶ if (! -e $target) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $target) 0 0 0
344 0 ▶ print STDERR "Fetching $target..." if $Opt{verbose} && !$Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
if $Opt{"verbose"} and not $Opt{"quiet"} 0 0 0
Condition0%0/3
$Opt{"verbose"} and not $Opt{"quiet"}
!ll&&!rl&&r
000
MC/DC0%0/2
$Opt{"verbose"} and not $Opt{"quiet"}
$Opt{"verbose"} not $Opt{"quiet"}
Truth table0%0/3
A and not(B)
A= $Opt{"verbose"}B= not $Opt{"quiet"}
ABresult
0X0
100
111
345 0 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { $Opt{'transport'} eq 'http_cpantesters' }) { } 0 0 0
elsif ($Opt{'transport'} eq 'http_cpantesters_gzip') { } 0 0 0
346 } elsif ($Opt{transport} eq "http_cpantesters") {
347 0 my $mustfetch = 0;
348 0 ▶ if ($Opt{"prefer-local-reports"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{'prefer-local-reports'}) { } 0 0 0
349 0 ▶ unless (-e $target) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $target) 0 0 0
350 0 $mustfetch = 1;
351 }
352 } else {
353 0 $mustfetch = 1;
354 }
355 0 ▶ if ($mustfetch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mustfetch) 0 0 0
356 # The API server returns a JSON structure containing both the
357 # raw output and details parsed from that output.
358 0 my $uri = "$cturl/v3/report/$guid";
359 0 my $resp = _ua->get($uri);
360 0 ▶ if ($resp->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resp->is_success) { } 0 0 0
361 0 my $json = $resp->decoded_content;
362 0 my $report;
363 0 local $@;
364 0 eval {
365 0 $report = JSON::XS::decode_json($json);
366 };
367 0 ▶ if (my $e = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 0 0
368 0 die {severity=>0,
369 text=>sprintf "Failed to parse JSON for report guid[%s]: %s", $guid, $e};
370 }
371 0 ▶ open my $fh, ">", $target or die {severity=>0,text=>"Could not open >$target: $!"};
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $target or die {"severity", 0, "text", "Could not open >${target}: $!"} 0 0 0
372 # The v3 report format keeps metadata in the JSON structure, but later
373 # when we're parsing the report, we expect to see the same NNTP/SMTP-style
374 # headers.
375 # TODO: We should probably have this module use the JSON natively.
376 printf $fh "From: %s <%s>\n",
377 $report->{reporter}{name},
378 $report->{reporter}{email},
379 0 ;
380 0 my $x = $OSNAME{ $report->{environment}{system}{osname} };
381 0 ▶ $x = $report->{environment}{system}{osname} unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 0 0
382 printf $fh "Subject: %s %s-%s perl-%s %s\n",
383 uc $report->{result}{grade},
384 $report->{distribution}{name},
385 $report->{distribution}{version},
386 $report->{environment}{language}{version},
387 0 $x,
388 ;
389 printf $fh "Date: %s\n\n",
390 $report->{created},
391 0 ;
392  
393 # The v3 report format allows for separating output into phases
394 # (in order: configure, build, install, test),
395 # though no client currently (2026-01-10) does so it all ends up
396 # in "uncategorized"...
397 0 print $fh grep defined, @{$report->{result}{output}}{qw(configure build install test uncategorized)};
398 0 close $fh;
399 0 ▶ if ($Opt{verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"verbose"}) 0 0 0
400 0 my(@stat) = stat $target;
401 0 my $timestamp = gmtime $stat[9];
402 0 ▶ print STDERR "(timestamp $timestamp GMT)\n" unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
403 0 ▶ if ($Opt{verbose} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"verbose"} > 1) 0 0 0
404 0 ▶ print STDERR $resp->headers->as_string unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
405 }
406 }
407 0 my $headers = "$target.headers";
408 0 ▶ open $fh, ">", $headers or die {severity=>1,text=>"Could not open >$headers: $!"};
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">", $headers or die {"severity", 1, "text", "Could not open >${headers}: $!"} 0 0 0
409 0 print $fh $resp->headers->as_string;
410 } else {
411 0 die {
412 severity => 0,
413 text => sprintf("HTTP Server Error[%s] for guid[%s]", $resp->status_line, $guid),
414 uri => $uri,
415 };
416 }
417 }
418 } elsif ($Opt{transport} eq "http_cpantesters_gzip") {
419 0 my $mustfetch = 0;
420 0 ▶ if ($Opt{"prefer-local-reports"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{'prefer-local-reports'}) { } 0 0 0
421 0 ▶ unless (-e "$target.gz") {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e "$target.gz") 0 0 0
422 0 $mustfetch = 1;
423 }
424 } else {
425 0 $mustfetch = 1;
426 }
427 0 ▶ if ($mustfetch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mustfetch) 0 0 0
428 # The API server returns a JSON structure containing both the
429 # raw output and details parsed from that output.
430 0 my $resp = _ua_gzip->get("$cturl/v3/report/$guid");
431 0 ▶ if ($resp->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resp->is_success) { } 0 0 0
432 0 my $json = $resp->decoded_content;
433 0 my $report;
434 0 local $@;
435 0 eval {
436 0 $report = JSON::XS::decode_json($json);
437 };
438 0 ▶ if (my $e = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 0 0
439 0 die {severity=>0,
440 text=>sprintf "Failed to parse JSON for report guid[%s]: %s", $guid, $e};
441 }
442 0 ▶ my $gz = Compress::Zlib::gzopen("$target.gz", "wb")
Branch: 1 branch
BranchTrueFalseTotal
my $gz = &Compress::Zlib::gzopen("$target.gz", "wb") or die {"severity", 0, "text", "Could not open >$target.gz: $CPAN::Testers::ParseReport::gzerrno"} 0 0 0
443 or die {severity=>0,text=>"Could not open >$target.gz: $gzerrno"};
444 # The v3 report format keeps metadata in the JSON structure, but later
445 # when we're parsing the report, we expect to see the same NNTP/SMTP-style
446 # headers.
447 # TODO: We should probably have this module use the JSON natively.
448 $gz->gzwrite(sprintf "From: %s <%s>\n",
449 $report->{reporter}{name},
450 $report->{reporter}{email},
451 0 );
452 0 my $x = $OSNAME{ $report->{environment}{system}{osname} };
453 0 ▶ $x = $report->{environment}{system}{osname} unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 0 0
454 $gz->gzwrite(sprintf "Subject: %s %s-%s perl-%s %s\n",
455 uc $report->{result}{grade},
456 $report->{distribution}{name},
457 $report->{distribution}{version},
458 $report->{environment}{language}{version},
459 0 $x,
460 );
461 0 $gz->gzwrite(sprintf "Date: %s\n\n", $report->{created});
462  
463 # The v3 report format allows for separating output into phases
464 # (in order: configure, build, install, test),
465 # though no client currently (2026-01-10) does so it all ends up
466 # in "uncategorized"...
467 0 $gz->gzwrite(join "\n", grep defined, @{$report->{result}{output}}{qw(configure build install test uncategorized)});
468 0 $gz->gzclose;
469 0 ▶ if ($Opt{verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"verbose"}) 0 0 0
470 0 my(@stat) = stat "$target.gz";
471 0 my $timestamp = gmtime $stat[9];
472 0 ▶ print STDERR "(timestamp $timestamp GMT)\n" unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
473 0 ▶ if ($Opt{verbose} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"verbose"} > 1) 0 0 0
474 0 ▶ print STDERR $resp->headers->as_string unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
475 }
476 }
477 0 my $headers = "$target.headers";
478 0 ▶ open my $fh, ">", $headers or die {severity=>1,text=>"Could not open >$headers: $!"};
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $headers or die {"severity", 1, "text", "Could not open >${headers}: $!"} 0 0 0
479 0 print $fh $resp->headers->as_string;
480 } else {
481 0 die {severity=>0,
482 text=>sprintf "HTTP Server Error[%s] for guid[%s]", $resp->status_line, $guid};
483 }
484 }
485 } else {
486 0 die {severity=>1,text=>"Illegal value for --transport: '$Opt{transport}'"};
487 }
488 }
489 }
490 495 parse_report($target, $dumpvars, %Opt);
491 }
492  
493 5 ▶sub parse_distro {
Subroutine parse_distro: called CC=34 SCAR=45.3
Pod documented
494 5 my($distro,%Opt) = @_;
495 5 my %dumpvars;
496 5 ▶ $Opt{cachedir} ||= "$ENV{HOME}/var/cpantesters";
Condition50%1/2
$Opt{"cachedir"} ||= qq[$ENV{"HOME"}/var/cpantesters]
l!l
50
MC/DC0%0/1
$Opt{"cachedir"} ||= qq[$ENV{"HOME"}/var/cpantesters]
$Opt{"cachedir"}
Truth table50%1/2
A
A= $Opt{"cachedir"}
Aresult
11
00
497 # the name cpantesters-show was picked because originally
498 # http://www.cpantesters.org/show/ contained html file that we had
499 # to parse.
500 5 my $cts_dir = "$Opt{cachedir}/cpantesters-show";
501 5 mkpath $cts_dir;
502 5 ▶ if ($Opt{solve}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"solve"}) 1 4 5
503 1 require Statistics::Regression;
504 1 ▶ $Opt{dumpvars} = "." unless defined $Opt{dumpvars};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Opt{"dumpvars"} 1 0 1
505 }
506 5 ▶ if (!$Opt{vdistro} && $distro =~ /^(.+)-(?i:v?\d+)(?:\.\d+)*\w*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $Opt{"vdistro"} and $distro =~ /^(.+)-(?i:v?\d+)(?:\.\d+)*\w*$/) 0 5 5
Condition33%1/3
not $Opt{"vdistro"} and $distro =~ /^(.+)-(?i:v?\d+)(?:\.\d+)*\w*$/
!ll&&!rl&&r
050
MC/DC0%0/2
not $Opt{"vdistro"} and $distro =~ /^(.+)-(?i:v?\d+)(?:\.\d+)*\w*$/
not $Opt{"vdistro"} $distro =~ /^(.+)-(?i:v?\d+)(?:\.\d+)*\w*$/
Truth table33%1/3
not(A) and B
A= not $Opt{"vdistro"}B= $distro =~ /^(.+)-(?i:v?\d+)(?:\.\d+)*\w*$/
ABresult
0X0
100
111
507 0 $Opt{vdistro} = $distro;
508 0 $distro = $1;
509 }
510 5 my $reports;
511 5 ▶ if (my $ctdb = $Opt{ctdb}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ctdb = $Opt{'ctdb'}) { } 0 5 5
512 0 require CPAN::WWW::Testers::Generator::Database;
513 0 require CPAN::DistnameInfo;
514 0 ▶ my $dbi = CPAN::WWW::Testers::Generator::Database->new(database=>$ctdb) or die "Alert: unknown error while opening database '$ctdb'";
Branch: 1 branch
BranchTrueFalseTotal
my $dbi = "CPAN::WWW::Testers::Generator::Database"->new("database", $ctdb) or die "Alert: unknown error while opening database '${ctdb}'" 0 0 0
515 0 ▶ unless ($Opt{vdistro}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Opt{"vdistro"}) 0 0 0
516 0 my $sql = "select version from cpanstats where dist=? order by id";
517 0 my @rows = $dbi->get_query($sql,$distro);
518 0 my($newest,%seen);
519 0 for my $row (@rows) {
520 0 ▶ $newest = $row->[0] unless $seen{$row->[0]}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $seen{$row->[0]}++ 0 0 0
521 }
522 0 $Opt{vdistro} = "$distro-$newest";
523 }
524 0 my $d = CPAN::DistnameInfo->new("FOO/$Opt{vdistro}.tgz");
525 0 my $dist = $d->dist;
526 0 my $version = $d->version;
527 0 my $sql = "select guid from cpanstats where dist=? and version=? order by id desc";
528 0 my @rows = $dbi->get_query($sql,$dist,$version);
529 0 my @all;
530 0 for my $row (@rows) {
531 0 push @all, {
532 guid => $row->[0],
533 };
534 }
535 0 $reports = \@all;
536 } else {
537 5 my $ctarget = _download_overview($cts_dir, $distro, %Opt);
538 5 $reports = _parse_yaml($ctarget,%Opt);
539 }
540 5 ▶ return unless $reports;
Branch: 1 branch
BranchTrueFalseTotal
unless $reports 0 5 5
541 5 my $sampled = 0;
542 5 ▶ my $samplesize = $Opt{sample} || 0;
Condition100%2/2
$Opt{'sample'} || 0
l!l
32
MC/DC100%1/1
$Opt{'sample'} || 0
$Opt{'sample'}
Truth table100%2/2
A
A= $Opt{'sample'}
Aresult
11
00
543 5 ▶ $samplesize = 0 if $samplesize && $samplesize >= @$reports;
Branch: 1 branch
BranchTrueFalseTotal
if $samplesize and $samplesize >= @$reports 1 4 5
Condition100%3/3
$samplesize and $samplesize >= @$reports
!ll&&!rl&&r
221
MC/DC100%2/2
$samplesize and $samplesize >= @$reports
$samplesize $samplesize >= @$reports
Truth table100%3/3
A and B
A= $samplesizeB= $samplesize >= @$reports
ABresult
0X0
100
111
544 REPEATER: {
545 5 my $i = 0;
546 13 my %taken;
547 13 REPORT: for my $report (@$reports) {
548 1286 $i++;
549 1286 ▶ if ($samplesize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($samplesize) 896 390 1286
550 896 my $need = $samplesize - $sampled;
551 896 ▶ next REPORT unless $need;
Branch: 1 branch
BranchTrueFalseTotal
unless $need 111 785 896
552 785 my $left = @$reports - $i;
553 # warn sprintf "tot %d i %d sampled %d need %d left %d\n", scalar @$reports, $i, $sampled, $need, $left;
554 785 my $want_this = (rand(1) <= ($need/$left));
555 785 ▶ next REPORT unless $want_this;
Branch: 1 branch
BranchTrueFalseTotal
unless $want_this 680 105 785
556 }
557 495 eval {parse_single_report($report, \%dumpvars, %Opt)};
558 495 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 495 495
559 0 ▶ if (ref $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $@) { } 0 0 0
560 0 ▶ if ($@->{severity}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@->{'severity'}) { } 0 0 0
561 0 die $@->{text};
562 } else {
563 0 my $j = JSON::XS->new->ascii->canonical;
564 0 warn sprintf "%s (%s)", $@->{text}, $j->encode({%{$@}, line => __LINE__, file => __FILE__});
565 }
566 } else {
567 0 die $@;
568 }
569 }
570 495 $sampled++;
571 495 $taken{$i-1}=undef;
572 495 ▶ last REPEATER if $Signal;
Branch: 1 branch
BranchTrueFalseTotal
if $CPAN::Testers::ParseReport::Signal 0 495 495
573 }
574 13 ▶ if ($samplesize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($samplesize) 10 3 13
575 10 PASSFAIL: for my $pf ("pass","fail") {
576 20 ▶ my $minx = $Opt{"min".$pf} or next PASSFAIL;
Branch: 1 branch
BranchTrueFalseTotal
my $minx = $Opt{'min' . $pf} or next PASSFAIL 9 11 20
577 9 my $x = $dumpvars{"meta:ok"}{uc $pf}{uc $pf};
578 9 ▶ if ($x < $minx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x < $minx) 8 1 9
579 # bump samplesize, remove already sampled reports from array, redo
580 8 my $bump = int($samplesize * 0.05)+1;
581 8 $samplesize += $bump;
582 8 for my $k (sort {$b <=> $a} keys %taken) {
583 61 splice @$reports, $k, 1;
584 }
585 8 redo REPEATER;
586 }
587 }
588 }
589 }
590 5 ▶ if ($Opt{dumpvars}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"dumpvars"}) 5 0 5
591 5 ▶ my $dumpfile = $Opt{dumpfile} || "ctgetreports.out";
Condition50%1/2
$Opt{'dumpfile'} || 'ctgetreports.out'
l!l
05
MC/DC0%0/1
$Opt{'dumpfile'} || 'ctgetreports.out'
$Opt{'dumpfile'}
Truth table50%1/2
A
A= $Opt{'dumpfile'}
Aresult
11
00
592 5 ▶ open my $fh, ">", $dumpfile or die "Could not open '$dumpfile' for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $dumpfile or die "Could not open '${dumpfile}' for writing: $!" 5 0 5
593 5 print $fh _yaml_dump(\%dumpvars);
594 5 ▶ close $fh or die "Could not close '$dumpfile': $!"
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Could not close '${dumpfile}': $!" 5 0 5
595 }
596 5 ▶ if ($Opt{solve}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"solve"}) 1 4 5
597 1 solve(\%dumpvars,%Opt);
598 }
599 }
600  
601 =head2 $bool = _looks_like_qp($raw_report)
602  
603 We had to acknowledge the fact that some MTAs swallow the MIME-Version
604 header while passing MIME through. So we introduce fallback heuristics
605 that try to determine if a report is written in quoted printable.
606  
607 Note that this subroutine is internal, just documented to have the
608 internals documented.
609  
610 The current implementation counts the number of QP escaped spaces and
611 equal signs.
612  
613 =cut
614  
615 14 ▶sub _looks_like_qp {
Subroutine _looks_like_qp: called CC=4 SCAR=14.0
616 14 my($report) = @_;
617 14 my $count_space = () = $report =~ /=20/g;
618 14 ▶ return 1 if $count_space > 12;
Branch: 1 branch
BranchTrueFalseTotal
if $count_space > 12 1 13 14
619 13 my $count_equal = () = $report =~ /=3D/g;
620 13 ▶ return 1 if $count_equal > 12;
Branch: 1 branch
BranchTrueFalseTotal
if $count_equal > 12 0 13 13
621 13 ▶ return 1 if $count_space+$count_equal > 24;
Branch: 1 branch
BranchTrueFalseTotal
if $count_space + $count_equal > 24 0 13 13
622 13 return 0; # waiting for a counter example
623 }
624  
625 =head2 $extract = parse_report($target,$dumpvars,%Opt)
626  
627 Reads one report. $target is the local filename to read (but see below
628 for option 'article'). $dumpvars is a hashref which gets filled with
629 descriptive stats about PASS/FAIL/etc. %Opt are the options as
630 described in the C<ctgetreports> manpage. $extract is a hashref
631 containing the found variables.
632  
633 Note: this parsing is a bit dirty but as it seems good enough I'm not
634 inclined to change it. We parse HTML with regexps only, not an HTML
635 parser. Only the entities are decoded.
636  
637 In %Opt you can use
638  
639 article => $some_full_article_as_scalar
640  
641 to use this function to parse one full article as text. When this is
642 given, the argument $target is not read, but its basename is taken to
643 be the guid of the article. (OMG, hackers!)
644  
645 =cut
646 517 ▶sub parse_report {
Subroutine parse_report: called CC=163 SCAR=54.7
Pod documented
647 517 my($target,$dumpvars,%Opt) = @_;
648 517 our @q;
649 517 my $guid = basename($target);
650 # warn "DEBUG: guid[$guid]";
651 517 my($ok,$about);
652  
653 517 my(%extract);
654  
655 517 my($report,$isHTML) = _get_cooked_report($target, \%Opt);
656 517 my @qr = map /^qr:(.+)/, @{$Opt{q}};
657 517 ▶ if ($Opt{raw} || @qr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"raw"} or @qr) 131 386 517
Condition66%2/3
$Opt{"raw"} or @qr
l!l&&r!l&&!r
0131386
MC/DC50%1/2
$Opt{"raw"} or @qr
$Opt{"raw"} @qr
Truth table66%2/3
A or B
A= $Opt{"raw"}B= @qr
ABresult
1X1
011
000
658 131 for my $qr (@qr) {
659 131 my $cqr = eval "qr{$qr}";
660 131 ▶ die "Could not compile regular expression '$qr': $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 131 131
661 131 my(@matches) = $report =~ $cqr;
662 131 my $v;
663 131 ▶ if (@matches) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matches) { } 2 129 131
664 2 ▶ if (@matches==1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matches == 1) { } 2 0 2
665 2 $v = $matches[0];
666 } else {
667 0 $v = join "", map {"($_)"} @matches;
668 }
669 } else {
670 129 $v = "";
671 }
672 131 $extract{"qr:$qr"} = $v;
673 }
674 }
675  
676 517 my $report_writer;
677 517 my $moduleunpack = {};
678 517 my $expect_prereq = 0;
679 517 my $expect_toolchain = 0;
680 517 my $expecting_toolchain_soon = 0;
681 517 my $expect_module_versions_report = 0;
682 517 my $expect_characteristics_libperl = 0;
683 517 my $fallback_p5 = "";
684  
685 517 my $in_summary = 0;
686 517 my $in_summary_seen_platform = 0;
687 517 my $in_prg_output = 0;
688 517 my $in_env_context = 0;
689 517 my $in_test_summary = 0;
690 517 my $in_characteristics = 0;
691  
692 517 my $current_headline;
693 517 my @previous_line = ""; # so we can neutralize line breaks
694 517 my @rlines = split /\r?\n/, $report;
695 517 LINE: for (@rlines) {
696 3882 ▶ next LINE unless ($isHTML ? m/<title>((\S+)\s+(\S+))/ : m/^Subject:\s*((\S+)\s+(\S+))/)
Branch: 2 branches
BranchTrueFalseTotal
unless $isHTML ? /<title>((\S+)\s+(\S+))/ : /^Subject:\s*((\S+)\s+(\S+))/ or /^Subject:\s*<strong>((\S+)\s+(\S+))/ 3365 517 3882
$isHTML ? : 3465 417 3882
Condition100%3/3
$isHTML ? /<title>((\S+)\s+(\S+))/ : /^Subject:\s*((\S+)\s+(\S+))/ or /^Subject:\s*<strong>((\S+)\s+(\S+))/
l!l&&r!l&&!r
51613365
MC/DC100%2/2
$isHTML ? /<title>((\S+)\s+(\S+))/ : /^Subject:\s*((\S+)\s+(\S+))/ or /^Subject:\s*<strong>((\S+)\s+(\S+))/
$isHTML ? /<title>((\S+)\s+(\S+))/ : /^Subject:\s*((\S+)\s+(\S+))/ /^Subject:\s*<strong>((\S+)\s+(\S+))/
Truth table100%3/3
A or B
A= $isHTML ? /<title>((\S+)\s+(\S+))/ : /^Subject:\s*((\S+)\s+(\S+))/B= /^Subject:\s*<strong>((\S+)\s+(\S+))/
ABresult
1X1
011
000
697 || m{^Subject:\s*<strong>((\S+)\s+(\S+))};
698 517 my $s = $1;
699 517 ▶ $s = $1 if $s =~ m{<strong>(.+)};
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /<strong>(.+)/ 5 512 517
700 517 ▶ if ($s =~ /(\S+)\s+(\S+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /(\S+)\s+(\S+)/) 517 0 517
701 517 $ok = $1;
702 517 $about = $2;
703 }
704 517 $extract{"meta:ok"} = $ok;
705 517 $extract{"meta:about"} = $about;
706 517 last;
707 }
708 517 ▶ unless ($extract{"meta:about"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($extract{"meta:about"}) 0 517 517
709 0 $extract{"meta:about"} = $Opt{vdistro};
710 0 ▶ unless ($extract{"meta:ok"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($extract{"meta:ok"}) 0 0 0
711 0 warn "Warning: could not determine state of report";
712 }
713 }
714 517 ▶ LINE: while (@rlines) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rlines) 141965 517 142482
715 141965 $_ = shift @rlines;
716 141965 ▶ while (/!$/ and @rlines) {
Branch: 1 branch
BranchTrueFalseTotal
if (/!$/ and @rlines) 345 141965 142310
Condition66%2/3
/!$/ and @rlines
!ll&&!rl&&r
1419650345
MC/DC50%1/2
/!$/ and @rlines
/!$/ @rlines
Truth table66%2/3
A and B
A= /!$/B= @rlines
ABresult
0X0
100
111
717 345 my $followupline = shift @rlines;
718 345 $followupline =~ s/^\s+//; # remo leading space
719 345 $_ .= $followupline;
720 }
721 141965 ▶ if (/^--------/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^--------/) 4106 137859 141965
722 4106 ▶ if ($previous_line[-2] && $previous_line[-2] =~ /^--------/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($previous_line[-2] and $previous_line[-2] =~ /^--------/) { } 1933 2173 4106
elsif ($previous_line[-1] and $previous_line[-1] =~ /Test Summary Report/) { } 176 3971 4147
Condition100%3/3
$previous_line[-2] and $previous_line[-2] =~ /^--------/
!ll&&!rl&&r
22319501933
MC/DC100%2/2
$previous_line[-2] and $previous_line[-2] =~ /^--------/
$previous_line[-2] $previous_line[-2] =~ /^--------/
Truth table100%3/3
A and B
A= $previous_line[-2]B= $previous_line[-2] =~ /^--------/
ABresult
0X0
100
111
723 1933 $current_headline = $previous_line[-1];
724 1933 ▶ if ($current_headline =~ /PROGRAM OUTPUT/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_headline =~ /PROGRAM OUTPUT/) { } 475 1458 1933
725 475 $in_prg_output = 1;
726 } else {
727 1458 $in_prg_output = 0;
728 }
729 1933 ▶ if ($current_headline =~ /ENVIRONMENT AND OTHER CONTEXT/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_headline =~ /ENVIRONMENT AND OTHER CONTEXT/) { } 512 1421 1933
730 512 $in_env_context = 1;
731 } else {
732 1421 $in_env_context = 0;
733 }
734 ▶ } elsif ($previous_line[-1] && $previous_line[-1] =~ /Test Summary Report/) {
Condition100%3/3
$previous_line[-1] and $previous_line[-1] =~ /Test Summary Report/
!ll&&!rl&&r
197423176
MC/DC100%2/2
$previous_line[-1] and $previous_line[-1] =~ /Test Summary Report/
$previous_line[-1] $previous_line[-1] =~ /Test Summary Report/
Truth table100%3/3
A and B
A= $previous_line[-1]B= $previous_line[-1] =~ /Test Summary Report/
ABresult
0X0
100
111
735 176 $in_test_summary = 1;
736 176 $in_prg_output = 0;
737 }
738 }
739 141965 ▶ if ($extract{"meta:perl"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extract{'meta:perl'}) { } 60922 81043 141965
740 60922 ▶ if ( $in_summary
Branch: 1 branch
BranchTrueFalseTotal
if ($in_summary and not $extract{"conf:git_commit_id"} and /Commit id:\s*([[:xdigit:]]+)/) 2 60920 60922
Condition83%5/6
$in_summary and not $extract{"conf:git_commit_id"} and /Commit id:\s*([[:xdigit:]]+)/
!ll&&!rl&&r
54608662
$in_summary and not $extract{"conf:git_commit_id"}
!ll&&!rl&&r
05460868
MC/DC66%2/3
$in_summary and not $extract{"conf:git_commit_id"} and /Commit id:\s*([[:xdigit:]]+)/
$in_summary not $extract{"conf:git_commit_id"} /Commit id:\s*([[:xdigit:]]+)/
Truth table75%3/4
A and not(B) and C
A= $in_summaryB= not $extract{"conf:git_commit_id"}C= /Commit id:\s*([[:xdigit:]]+)/
ABCresult
0XX0
10X0
1100
1111
741 and !$extract{"conf:git_commit_id"}
742 and /Commit id:\s*([[:xdigit:]]+)/) {
743 2 $extract{"conf:git_commit_id"} = $1;
744 }
745 } else {
746 81043 my $p5;
747 81043 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { /Summary of my perl5 \((.+)\) configuration:/ }) 516 80527 81043
748 0 } elsif (/Summary of my perl5 \((.+)\) configuration:/) {
749 516 $p5 = $1;
750 516 $in_summary = 1;
751 516 $in_env_context = 0;
752 }
753 81043 ▶ if ($p5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p5) 516 80527 81043
754 516 my($r,$v,$s,$p);
755 516 ▶ if (($r,$v,$s,$p) = $p5 =~ /revision (\S+) version (\S+) subversion (\S+) patch (\S+)/) {
Branch: 3 branches
BranchTrueFalseTotal
if (() = $p5 =~ /revision (\S+) version (\S+) subversion (\S+) patch (\S+)/) { } 293 223 516
elsif (() = $p5 =~ /revision (\S+) version (\S+) subversion (\S+)/) { } 214 9 223
elsif (() = $p5 =~ /(\d+\S*) patchlevel (\S+) subversion (\S+)/) { } 9 0 9
756 293 $r =~ s/\.0//; # 5.0 6 2!
757 293 $extract{"meta:perl"} = "$r.$v.$s\@$p";
758 } elsif (($r,$v,$s) = $p5 =~ /revision (\S+) version (\S+) subversion (\S+)/) {
759 214 $r =~ s/\.0//;
760 214 $extract{"meta:perl"} = "$r.$v.$s";
761 } elsif (($r,$v,$s) = $p5 =~ /(\d+\S*) patchlevel (\S+) subversion (\S+)/) {
762 9 $r =~ s/\.0//;
763 9 $extract{"meta:perl"} = "$r.$v.$s";
764 } else {
765 0 $extract{"meta:perl"} = $p5;
766 }
767 }
768 }
769 141965 ▶ unless ($extract{"meta:from"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($extract{"meta:from"}) 17692 124273 141965
770 17692 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $isHTML ? m[<div class="h_name">From:</div> <b>(.+?)</b><br/>] : /^From:\s*(.+)/ or /^From:\s*(.+)/ }) 517 17175 17692
771 0 ▶ } elsif ($isHTML ?
Branch: 1 branch
BranchTrueFalseTotal
$isHTML ? : 17176 516 17692
Condition100%3/3
($isHTML ? m[<div class="h_name">From:</div> <b>(.+?)</b><br/>] : /^From:\s*(.+)/) || /^From:\s*(.+)/
l!l&&r!l&&!r
516117175
MC/DC100%2/2
($isHTML ? m[<div class="h_name">From:</div> <b>(.+?)</b><br/>] : /^From:\s*(.+)/) || /^From:\s*(.+)/
($isHTML ? m[<div class="h_name">From:</div> <b>(.+?)</b><br/>] : /^From:\s*(.+)/) /^From:\s*(.+)/
Truth table100%3/3
A || B
A= ($isHTML ? m[<div class="h_name">From:</div> <b>(.+?)</b><br/>] : /^From:\s*(.+)/)B= /^From:\s*(.+)/
ABresult
1X1
011
000
772 m|<div class="h_name">From:</div> <b>(.+?)</b><br/>| :
773 m|^From:\s*(.+)|
774 or
775 m|^From:\s*(.+)|
776 ) {
777 517 my $f = $1;
778 517 ▶ $f = $1 if $f =~ m{<strong>(.+)</strong>};
Branch: 1 branch
BranchTrueFalseTotal
if $f =~ m[<strong>(.+)</strong>] 6 511 517
779 517 $extract{"meta:from"} = $f;
780 }
781 17692 ▶ $extract{"meta:from"} =~ s/\.$// if $extract{"meta:from"};
Branch: 1 branch
BranchTrueFalseTotal
if $extract{"meta:from"} 517 17175 17692
782 }
783 141965 ▶ unless ($extract{"meta:date"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($extract{"meta:date"}) 18079 123886 141965
784 18079 ▶ if (0) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $isHTML ? m[<div class="h_name">Date:</div> (.+?)<br/>] : /^Date:\s*(.+)/ or /^Date:\s*(.+)/ }) 517 17562 18079
785 0 ▶ } elsif ($isHTML ?
Branch: 1 branch
BranchTrueFalseTotal
$isHTML ? : 17672 407 18079
Condition100%3/3
($isHTML ? m[<div class="h_name">Date:</div> (.+?)<br/>] : /^Date:\s*(.+)/) || /^Date:\s*(.+)/
l!l&&r!l&&!r
516117562
MC/DC100%2/2
($isHTML ? m[<div class="h_name">Date:</div> (.+?)<br/>] : /^Date:\s*(.+)/) || /^Date:\s*(.+)/
($isHTML ? m[<div class="h_name">Date:</div> (.+?)<br/>] : /^Date:\s*(.+)/) /^Date:\s*(.+)/
Truth table100%3/3
A || B
A= ($isHTML ? m[<div class="h_name">Date:</div> (.+?)<br/>] : /^Date:\s*(.+)/)B= /^Date:\s*(.+)/
ABresult
1X1
011
000
786 m|<div class="h_name">Date:</div> (.+?)<br/>| :
787 m|^Date:\s*(.+)|
788 or
789 m|^Date:\s*(.+)|
790 ) {
791 517 my $date = $1;
792 517 ▶ $date = $1 if $date =~ m{<strong>(.+)</strong>};
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ m[<strong>(.+)</strong>] 6 511 517
793 517 my($dt);
794 517 DATEFMT: for my $pat ("%Y-%m-%dT%TZ", # 2010-07-07T14:01:40Z
795 "%a, %d %b %Y %T %z", # Sun, 28 Sep 2008 12:23:12 +0100
796 "%b %d, %Y %R", # July 10,...
797 "%b %d, %Y %R", # July 4,...
798 ) {
799 1521 $dt = eval {
800 1521 my $p = DateTime::Format::Strptime->new
801 (
802 locale => "en",
803 time_zone => "UTC",
804 pattern => $pat,
805 );
806 1521 $p->parse_datetime($date)
807 };
808 1521 ▶ last DATEFMT if $dt;
Branch: 1 branch
BranchTrueFalseTotal
if $dt 517 1004 1521
809 }
810 517 ▶ unless ($dt) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dt) 0 517 517
811 0 warn "Could not parse date[$date], setting to epoch 0";
812 0 $dt = DateTime->from_epoch( epoch => 0 );
813 }
814 517 $extract{"meta:date"} = $dt->datetime;
815 }
816 18079 ▶ $extract{"meta:date"} =~ s/\.$// if $extract{"meta:date"};
Branch: 1 branch
BranchTrueFalseTotal
if $extract{"meta:date"} 517 17562 18079
817 }
818 141965 ▶ unless ($extract{"meta:writer"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($extract{"meta:writer"}) 25634 116331 141965
819 25634 for ("$previous_line[-1] $_") {
820 25634 ▶ if (0) {
Branch: 4 branches
BranchTrueFalseTotal
if (do { /CPANPLUS, version (\S+)/ }) { } 10 25624 25634
elsif (/created by (App::cpanminus::reporter \S+)/) { } 0 25624 25624
elsif (/created (?:automatically )?by (\S+)/) { } 472 25152 25624
elsif (/This report was machine-generated by (\S+) (\S+)/) { } 35 25117 25152
821 } elsif (/CPANPLUS, version (\S+)/) {
822 10 $extract{"meta:writer"} = "CPANPLUS $1";
823 } elsif (/created by (App::cpanminus::reporter \S+)/) {
824 0 $extract{"meta:writer"} = $1;
825 } elsif (/created (?:automatically )?by (\S+)/) {
826 472 $extract{"meta:writer"} = $1;
827 472 ▶ if (/\s+on\s+perl\s+([^,]+),/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\s+on\s+perl\s+([^,]+),/) 472 0 472
828 472 $fallback_p5 = $1;
829 }
830 } elsif (/This report was machine-generated by (\S+) (\S+)/) {
831 35 $extract{"meta:writer"} = "$1 $2";
832 }
833 25634 ▶ $extract{"meta:writer"} =~ s/[\.,]$// if $extract{"meta:writer"};
Branch: 1 branch
BranchTrueFalseTotal
if $extract{"meta:writer"} 517 25117 25634
834 }
835 }
836 141965 ▶ if ($in_summary) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_summary) 61438 80527 141965
837 # we do that first three lines a bit too often
838 61438 ▶ my $qr = $Opt{dumpvars} || "";
Condition100%2/2
$Opt{'dumpvars'} || ''
l!l
6135682
MC/DC100%1/1
$Opt{'dumpvars'} || ''
$Opt{'dumpvars'}
Truth table100%2/2
A
A= $Opt{'dumpvars'}
Aresult
11
00
839 61438 ▶ $qr = qr/$qr/ if $qr;
Branch: 1 branch
BranchTrueFalseTotal
if $qr 61356 82 61438
840 61438 ▶ unless (@q) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@CPAN::Testers::ParseReport::q) 2 61436 61438
841 2 ▶ @q = @{$Opt{q}||[]};
Condition50%1/2
$Opt{'q'} || []
l!l
20
MC/DC0%0/1
$Opt{'q'} || []
$Opt{'q'}
Truth table50%1/2
A
A= $Opt{'q'}
Aresult
11
00
842 2 ▶ @q = qw(meta:perl conf:archname conf:usethreads conf:optimize meta:writer meta:from) unless @q;
Branch: 1 branch
BranchTrueFalseTotal
unless @CPAN::Testers::ParseReport::q 2 0 2
843 }
844  
845 61438 my %conf_vars = map {($_ => 1)} grep { /^conf:/ } @q;
846  
847 61438 ▶ if (/^\s+Platform:$/) {
Branch: 4 branches
BranchTrueFalseTotal
if (/^\s+Platform:$/) { } 516 60922 61438
elsif (/^\s*$/ or m[</pre>]) { } 23646 37276 60922
elsif ($in_characteristics) { } 242 37034 37276
elsif ($expect_characteristics_libperl and /Characteristics of this/) { } 7 37027 37034
848 516 $in_summary_seen_platform=1;
849 ▶ } elsif (/^\s*$/ || m|</pre>|) {
Condition100%3/3
/^\s*$/ or m[</pre>]
l!l&&r!l&&!r
2315149537276
MC/DC100%2/2
/^\s*$/ or m[</pre>]
/^\s*$/ m[</pre>]
Truth table100%3/3
A or B
A= /^\s*$/B= m[</pre>]
ABresult
1X1
011
000
850 # if not html, we have reached the end now
851 23646 ▶ if ($in_characteristics) {
Branch: 2 branches
BranchTrueFalseTotal
if ($in_characteristics) { } 1 23645 23646
elsif ($in_summary_seen_platform) { } 23636 9 23645
852 1 $in_summary = 0;
853 } elsif ($in_summary_seen_platform) {
854 # some perls have an empty line after the summary line
855 23636 $expect_characteristics_libperl = 1;
856 }
857 } elsif ($in_characteristics) {
858 242 ▶ if (my($date) = /Compiled at (.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($date) = /Compiled at (.+)/) 7 235 242
859 7 $date =~ s/\s+\z//;
860 # find: Apr 10 2013 16:59:47
861 # want: 2016-07-05T11:03:04
862 7 my($dt);
863 7 DATEFMT: for my $pat ("%b %d %Y %T") { # Sep 28 2008 12:23:12
864 7 $dt = eval {
865 7 my $p = DateTime::Format::Strptime->new
866 (
867 locale => "en",
868 time_zone => "UTC",
869 pattern => $pat,
870 );
871 7 $p->parse_datetime($date)
872 };
873 7 ▶ last DATEFMT if $dt;
Branch: 1 branch
BranchTrueFalseTotal
if $dt 7 0 7
874 }
875 7 ▶ unless ($dt) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dt) 0 7 7
876 0 warn "Could not parse date[$date], setting to epoch 0";
877 0 $dt = DateTime->from_epoch( epoch => 0 );
878 }
879 7 $extract{"meta:perl_compiled_at"} = $dt->datetime;
880 }
881 ▶ } elsif ($expect_characteristics_libperl && /Characteristics of this/) {
Condition100%3/3
$expect_characteristics_libperl and /Characteristics of this/
!ll&&!rl&&r
14371226567
MC/DC100%2/2
$expect_characteristics_libperl and /Characteristics of this/
$expect_characteristics_libperl /Characteristics of this/
Truth table100%3/3
A and B
A= $expect_characteristics_libperlB= /Characteristics of this/
ABresult
0X0
100
111
882 7 $in_characteristics = 1;
883 } else {
884 37027 my(%kv) = m!\G,?\s*([^=]+)= # left hand side and equal sign
885 (
886 [^',\s]+(?=.+=) # use64bitint=define use64bitall=define uselongdouble=undef
887 # (lookahead needed for left-over equal sign)
888 |
889 [^',]+$ # libpth=/usr/lib /usr/local/lib
890 |
891 '[^']+?' # cccdlflags='-DPIC -fPIC'
892 |
893 \S+ # useshrplib=false
894 )!xgc;
895 37027 ▶ while (my($k,$v) = each %kv) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %kv) 43197 37027 80224
896 43197 my $ck = "conf:$k";
897 43197 $ck =~ s/\s+$//;
898 43197 $v =~ s/,$//;
899 43197 ▶ if ($v =~ /^'(.*)'$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /^'(.*)'$/) 9209 33988 43197
900 9209 $v = $1;
901 }
902 43197 $v =~ s/^\s+//;
903 43197 $v =~ s/\s+$//;
904 43197 ▶ if ($qr && $ck =~ $qr) {
Branch: 2 branches
BranchTrueFalseTotal
if ($qr and $ck =~ /$qr/) { } 43079 118 43197
elsif ($conf_vars{$ck}) { } 4 114 118
Condition66%2/3
$qr and $ck =~ /$qr/
!ll&&!rl&&r
118043079
MC/DC50%1/2
$qr and $ck =~ /$qr/
$qr $ck =~ /$qr/
Truth table66%2/3
A and B
A= $qrB= $ck =~ /$qr/
ABresult
0X0
100
111
905 43079 $extract{$ck} = $v;
906 } elsif ($conf_vars{$ck}) {
907 4 $extract{$ck} = $v;
908 }
909 }
910 }
911 }
912 141965 ▶ if ($in_prg_output) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_prg_output) 11677 130288 141965
913 11677 ▶ unless ($extract{"meta:output_from"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($extract{"meta:output_from"}) 1416 10261 11677
914 1416 ▶ if (/Output from (.+):$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/Output from (.+):$/) 472 944 1416
915 472 $extract{"meta:output_from"} = $1
916 }
917 }
918  
919 # Parsing of Module::Versions::Report text in test output
920 11677 ▶ if (/Modules in memory:/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/Modules in memory:/) { } 1 11676 11677
elsif ($expect_module_versions_report) { } 8 11668 11676
921 1 $expect_module_versions_report = 1;
922 1 next LINE;
923 }
924 elsif ($expect_module_versions_report) {
925 8 ▶ if (/\s+(\S+)(?:\s+(v\d\S+?))?;/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/\s+(\S+)(?:\s+(v\d\S+?))?;/) { } 7 1 8
elsif (/\[at .+?\]/) { } 1 0 1
926 7 ▶ $extract{"mod:$1"} = defined $2 ? $2 : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 5 2 7
927 7 next LINE;
928 }
929 elsif (/\[at .+?\]/) {
930 # trailing timestamp
931 1 $expect_module_versions_report = 0;
932 1 next LINE;
933 }
934 }
935 }
936 141956 ▶ if ($in_env_context) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_env_context) 12025 129931 141956
937 12025 ▶ if ($extract{"meta:writer"} =~ /^CPANPLUS\b/
Branch: 1 branch
BranchTrueFalseTotal
if ($extract{"meta:writer"} =~ /^CPANPLUS\b/ or exists $extract{"env:PERL5_CPANPLUS_IS_VERSION"}) 862 11163 12025
Condition100%3/3
$extract{"meta:writer"} =~ /^CPANPLUS\b/ or exists $extract{"env:PERL5_CPANPLUS_IS_VERSION"}
l!l&&r!l&&!r
30455811163
MC/DC100%2/2
$extract{"meta:writer"} =~ /^CPANPLUS\b/ or exists $extract{"env:PERL5_CPANPLUS_IS_VERSION"}
$extract{"meta:writer"} =~ /^CPANPLUS\b/ exists $extract{"env:PERL5_CPANPLUS_IS_VERSION"}
Truth table100%3/3
A or B
A= $extract{"meta:writer"} =~ /^CPANPLUS\b/B= exists $extract{"env:PERL5_CPANPLUS_IS_VERSION"}
ABresult
1X1
011
000
938 ||
939 exists $extract{"env:PERL5_CPANPLUS_IS_VERSION"}
940 ) {
941 (
942 862 ▶ s/Perl:\s+\$\^X/\$^X/
Branch: 1 branch
BranchTrueFalseTotal
s/Perl:\s+\$\^X/\$^X/ or s/EUID:\s+\$>/\$EUID/ or s/UID:\s+\$</\$UID/ or s/EGID:\s+\$\)/\$EGID/ or s/GID:\s+\$\(/\$GID/ 164 698 862
Condition100%9/9
s/Perl:\s+\$\^X/\$^X/ or s/EUID:\s+\$>/\$EUID/ or s/UID:\s+\$</\$UID/ or s/EGID:\s+\$\)/\$EGID/
l!l&&r!l&&!r
12341698
s/Perl:\s+\$\^X/\$^X/ or s/EUID:\s+\$>/\$EUID/ or s/UID:\s+\$</\$UID/
l!l&&r!l&&!r
8241739
s/Perl:\s+\$\^X/\$^X/ or s/EUID:\s+\$>/\$EUID/
l!l&&r!l&&!r
4141780
MC/DC100%4/4
s/Perl:\s+\$\^X/\$^X/ or s/EUID:\s+\$>/\$EUID/ or s/UID:\s+\$</\$UID/ or s/EGID:\s+\$\)/\$EGID/
s/Perl:\s+\$\^X/\$^X/ s/EUID:\s+\$>/\$EUID/ s/UID:\s+\$</\$UID/ s/EGID:\s+\$\)/\$EGID/
Truth table100%5/5
A or B or C or D
A= s/Perl:\s+\$\^X/\$^X/B= s/EUID:\s+\$>/\$EUID/C= s/UID:\s+\$</\$UID/D= s/EGID:\s+\$\)/\$EGID/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
943 ||
944 s/EUID:\s+\$>/\$EUID/
945 ||
946 s/UID:\s+\$</\$UID/
947 ||
948 s/EGID:\s+\$\)/\$EGID/
949 ||
950 s/GID:\s+\$\(/\$GID/
951 )
952 }
953 12025 ▶ if (my($left,$right) = /^\s{4}(\S+)\s*=\s*(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = /^\s{4}(\S+)\s*=\s*(.*)$/) 7137 4888 12025
954 7137 ▶ if ($left eq '$UID/$EUID') {
Branch: 2 branches
BranchTrueFalseTotal
if ($left eq '$UID/$EUID') { } 471 6666 7137
elsif ($left =~ /GID/) { } 1024 5642 6666
955 471 my($uid,$euid) = split m{\s*/\s*}, $right;
956 471 $extract{'env:$UID'} = $uid;
957 471 $extract{'env:$EUID'} = $euid;
958 } elsif ($left =~ /GID/) {
959 1024 for my $xgid (uniq split " ", $right) {
960 3030 $extract{"env:$left∋$xgid"} = "true";
961 }
962 } else {
963 5642 $extract{"env:$left"} = $right;
964 }
965 }
966 }
967 141956 ▶ if ($in_test_summary) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_test_summary) 980 140976 141956
968 980 ▶ if (/^(?:Result:|Files=\d)/) {
Branch: 3 branches
BranchTrueFalseTotal
if (/^(?:Result:|Files=\d)/) { } 176 804 980
elsif (/^(\S+)\s+\(Wstat:.+?Tests:.+?Failed:\s*(\d+)\)$/) { } 208 596 804
elsif (/^\s+Failed tests?:/) { } 26 570 596
969 176 $in_test_summary = 0;
970 } elsif (/^(\S+)\s+\(Wstat:.+?Tests:.+?Failed:\s*(\d+)\)$/) {
971 208 my $in_test_summary_current_test = $1; # t/globtest.t or t\globtest.t
972 208 my $in_test_summary_current_failed = $2;
973 208 $in_test_summary_current_test =~ s|\\|/|g; # only t/globtest.t
974 208 $extract{"fail:$in_test_summary_current_test"} = $in_test_summary_current_failed;
975 } elsif (/^\s+Failed tests?:/) {
976 # ignoring the exact combination of tests for now, seems like overkill
977 }
978 }
979 141956 push @previous_line, $_;
980 141956 ▶ if ($expect_prereq || $expect_toolchain) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expect_prereq or $expect_toolchain) 14624 127332 141956
Condition100%3/3
$expect_prereq or $expect_toolchain
l!l&&r!l&&!r
60328592127332
MC/DC100%2/2
$expect_prereq or $expect_toolchain
$expect_prereq $expect_toolchain
Truth table100%3/3
A or B
A= $expect_prereqB= $expect_toolchain
ABresult
1X1
011
000
981 14624 ▶ if (/Perl module toolchain versions installed/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/Perl module toolchain versions installed/) 13 14611 14624
982 # first time discovered in CPANPLUS 0.89_06
983 13 $expecting_toolchain_soon = 1;
984 13 $expect_prereq=0;
985 13 next LINE;
986 }
987 14611 ▶ if (exists $moduleunpack->{type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $moduleunpack->{"type"}) 11048 3563 14611
988 11048 my($module,$v,$needwant);
989 # type 1 and 2 are about prereqs, type three about toolchain
990 11048 ▶ if ($moduleunpack->{type} == 1) {
Branch: 3 branches
BranchTrueFalseTotal
if ($moduleunpack->{'type'} == 1) { } 2366 8682 11048
elsif ($moduleunpack->{'type'} == 2) { } 90 8592 8682
elsif ($moduleunpack->{'type'} == 3) { } 8592 0 8592
991 2366 (my $leader,$module,$needwant,$v) = eval { unpack $moduleunpack->{tpl}, $_; };
992 2366 ▶ next LINE if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 2366 2366
993 2366 ▶ if ($leader =~ /^-/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($leader =~ /^-/) { } 465 1901 2366
elsif ($leader =~ /^( buil # build_requires: |conf # configure_requires: )/x) { } 5 1896 1901
elsif ($module =~ /^( - # line drawing )/x) { } 470 1426 1896
994 465 $moduleunpack = {};
995 465 $expect_prereq = 0;
996 465 next LINE;
997 } elsif ($leader =~ /^(
998 buil # build_requires:
999 |conf # configure_requires:
1000 )/x) {
1001 5 next LINE;
1002 } elsif ($module =~ /^(
1003 - # line drawing
1004 )/x) {
1005 470 next LINE;
1006 }
1007 } elsif ($moduleunpack->{type} == 2) {
1008 90 (my $leader,$module,$v,$needwant) = eval { unpack $moduleunpack->{tpl}, $_; };
1009 90 ▶ next LINE if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 90 90
1010 90 for ($module,$v,$needwant) {
1011 270 s/^\s+//;
1012 270 s/\s+$//;
1013 }
1014 90 ▶ if ($leader =~ /^\*/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($leader =~ /^\*/) { } 0 90 90
elsif (not defined $v && defined $needwant or $v =~ /\s/ or $needwant =~ /\s/) { } 4 86 90
1015 0 $moduleunpack = {};
1016 0 $expect_prereq = 0;
1017 0 next LINE;
1018 ▶ } elsif (!defined $v
Condition66%6/9
not defined $v && defined $needwant or $v =~ /\s/ or $needwant =~ /\s/
l!l&&r!l&&!r
2286
not defined $v && defined $needwant or $v =~ /\s/
l!l&&r!l&&!r
0288
defined $v && defined $needwant
!ll&&!rl&&r
0090
MC/DC50%2/4
not defined $v && defined $needwant or $v =~ /\s/ or $needwant =~ /\s/
defined $v defined $needwant $v =~ /\s/ $needwant =~ /\s/
Truth table60%3/5
not(A && B) or C or D
A= defined $vB= defined $needwantC= $v =~ /\s/D= $needwant =~ /\s/
ABCDresult
0XXX1
10XX1
111X1
11011
11000
1019 or !defined $needwant
1020 or $v =~ /\s/
1021 or $needwant =~ /\s/
1022 ) {
1023 4 ($module,$v,$needwant) = split " ", $_;
1024 }
1025 } elsif ($moduleunpack->{type} == 3) {
1026 8592 (my $leader,$module,$v) = eval { unpack $moduleunpack->{tpl}, $_; };
1027 8592 ▶ next LINE if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 8592 8592
1028 8592 ▶ if (!$module) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $module) { } 478 8114 8592
elsif ($module =~ /^-/) { } 471 7643 8114
1029 478 $moduleunpack = {};
1030 478 $expect_toolchain = 0;
1031 478 next LINE;
1032 } elsif ($module =~ /^-/) {
1033 471 next LINE;
1034 }
1035 }
1036 9159 $module =~ s/\s+$//;
1037 9159 ▶ if ($module) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module) 8671 488 9159
1038 8671 $v =~ s/^\s+//;
1039 8671 $v =~ s/\s+$//;
1040 8671 my($modulename,$versionlead) = split " ", $module;
1041 8671 ▶ if (defined $modulename and defined $versionlead) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $modulename and defined $versionlead) 26 8645 8671
Condition66%2/3
defined $modulename and defined $versionlead
!ll&&!rl&&r
0864526
MC/DC50%1/2
defined $modulename and defined $versionlead
defined $modulename defined $versionlead
Truth table66%2/3
A and B
A= defined $modulenameB= defined $versionlead
ABresult
0X0
100
111
1042 26 $module = $modulename;
1043 26 $v = "$versionlead$v";
1044 }
1045 8671 ▶ if ($v eq "Have") {
Branch: 1 branch
BranchTrueFalseTotal
if ($v eq "Have") 5 8666 8671
1046 5 next LINE;
1047 }
1048 8666 $extract{"mod:$module"} = $v;
1049 8666 ▶ if (defined $needwant) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $needwant) 1023 7643 8666
1050 1023 $needwant =~ s/^\s+//;
1051 1023 $needwant =~ s/\s+$//;
1052 1023 $extract{"prereq:$module"} = $needwant;
1053 }
1054 }
1055 }
1056 12717 ▶ if (/(\s+)(Module\s+)(Need\s+)Have/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/(\s+)(Module\s+)(Need\s+)Have/) { } 465 12252 12717
elsif (/(\s+)(Module Name\s+)(Have)(\s+)Want/) { } 7 12245 12252
1057 465 $in_env_context = 0;
1058 465 $moduleunpack = {
1059 tpl => 'a'.length($1).'a'.length($2).'a'.length($3).'a*',
1060 type => 1,
1061 };
1062 } elsif (/(\s+)(Module Name\s+)(Have)(\s+)Want/) {
1063 7 $in_env_context = 0;
1064 7 my $adjust_1 = 0;
1065 7 my $adjust_2 = -length($4);
1066 7 my $adjust_3 = length($4);
1067 # I think they do not really try to align, usually we
1068 # get away with split
1069 7 $moduleunpack = {
1070 tpl => 'a'.length($1).'a'.(length($2)+$adjust_2).'a'.(length($3)+$adjust_3).'a*',
1071 type => 2,
1072 };
1073 }
1074 }
1075 140049 ▶ if (/PREREQUISITES|Prerequisite modules loaded/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/PREREQUISITES|Prerequisite modules loaded/) 953 139096 140049
1076 953 $in_env_context = 0;
1077 953 $expect_prereq=1;
1078 }
1079 140049 ▶ if ($expecting_toolchain_soon) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expecting_toolchain_soon) 949 139100 140049
1080 949 ▶ if (/(\s+)(Module(?:\sName)?\s+) Have/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/(\s+)(Module(?:\sName)?\s+) Have/) 478 471 949
1081 478 $in_env_context = 0;
1082 478 $expect_toolchain=1;
1083 478 $expecting_toolchain_soon=0;
1084 478 $moduleunpack = {
1085 tpl => 'a'.length($1).'a'.length($2).'a*',
1086 type => 3,
1087 };
1088 }
1089 }
1090 140049 ▶ if (/toolchain versions installed/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/toolchain versions installed/) 465 139584 140049
1091 465 $in_env_context = 0;
1092 465 $expecting_toolchain_soon=1;
1093 }
1094 } # LINE
1095 517 ▶ if (! $extract{"mod:CPANPLUS"} && $extract{"meta:writer"} =~ /^CPANPLUS\s(\d+(\.\d+))$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $extract{"mod:CPANPLUS"} and $extract{"meta:writer"} =~ /^CPANPLUS\s(\d+(\.\d+))$/) 1 516 517
Condition100%3/3
not $extract{"mod:CPANPLUS"} and $extract{"meta:writer"} =~ /^CPANPLUS\s(\d+(\.\d+))$/
!ll&&!rl&&r
85081
MC/DC100%2/2
not $extract{"mod:CPANPLUS"} and $extract{"meta:writer"} =~ /^CPANPLUS\s(\d+(\.\d+))$/
not $extract{"mod:CPANPLUS"} $extract{"meta:writer"} =~ /^CPANPLUS\s(\d+(\.\d+))$/
Truth table100%3/3
not(A) and B
A= not $extract{"mod:CPANPLUS"}B= $extract{"meta:writer"} =~ /^CPANPLUS\s(\d+(\.\d+))$/
ABresult
0X0
100
111
1096 1 $extract{"mod:CPANPLUS"} = $1;
1097 }
1098 517 ▶ if (! $extract{"meta:perl"} && $fallback_p5) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $extract{"meta:perl"} and $fallback_p5) 1 516 517
Condition66%2/3
not $extract{"meta:perl"} and $fallback_p5
!ll&&!rl&&r
51601
MC/DC50%1/2
not $extract{"meta:perl"} and $fallback_p5
not $extract{"meta:perl"} $fallback_p5
Truth table66%2/3
not(A) and B
A= not $extract{"meta:perl"}B= $fallback_p5
ABresult
0X0
100
111
1099 1 my($p5,$patch) = split /\s+patch\s+/, $fallback_p5;
1100 1 $extract{"meta:perl"} = $p5;
1101 1 ▶ $extract{"conf:git_describe"} = $patch if defined $patch;
Branch: 1 branch
BranchTrueFalseTotal
if defined $patch 0 1 1
1102 }
1103 517 $extract{guid} = $guid;
1104 517 ▶ if (my $filtercbbody = $Opt{filtercb}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $filtercbbody = $Opt{"filtercb"}) 0 517 517
1105 0 my $filtercb = eval('sub {'.$filtercbbody.'}');
1106 0 $filtercb->(\%extract);
1107 }
1108 517 ▶ if ($Opt{solve}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"solve"}) 131 386 517
1109 131 ▶ if ($extract{"conf:osvers"} && $extract{"conf:archname"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extract{"conf:osvers"} and $extract{"conf:archname"}) 130 1 131
Condition66%2/3
$extract{"conf:osvers"} and $extract{"conf:archname"}
!ll&&!rl&&r
10130
MC/DC50%1/2
$extract{"conf:osvers"} and $extract{"conf:archname"}
$extract{"conf:osvers"} $extract{"conf:archname"}
Truth table66%2/3
A and B
A= $extract{"conf:osvers"}B= $extract{"conf:archname"}
ABresult
0X0
100
111
1110 130 $extract{"conf:archname+osvers"} = join " ", @extract{"conf:archname","conf:osvers"};
1111 }
1112 131 ▶ if ($extract{"meta:perl"} && $extract{"conf:osname"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extract{"meta:perl"} and $extract{"conf:osname"}) 130 1 131
Condition66%2/3
$extract{"meta:perl"} and $extract{"conf:osname"}
!ll&&!rl&&r
01130
MC/DC50%1/2
$extract{"meta:perl"} and $extract{"conf:osname"}
$extract{"meta:perl"} $extract{"conf:osname"}
Truth table66%2/3
A and B
A= $extract{"meta:perl"}B= $extract{"conf:osname"}
ABresult
0X0
100
111
1113 130 $extract{"meta:osname+perl"} = join " ", @extract{"conf:osname","meta:perl"};
1114 }
1115 131 ▶ my $data = $dumpvars->{"==DATA=="} ||= [];
Condition100%2/2
$dumpvars->{"==DATA=="} ||= []
l!l
1292
MC/DC100%1/1
$dumpvars->{"==DATA=="} ||= []
$dumpvars->{"==DATA=="}
Truth table100%2/2
A
A= $dumpvars->{"==DATA=="}
Aresult
11
00
1116 131 push @$data, \%extract;
1117 }
1118 # ---- %extract finished ----
1119 517 my $diag = "";
1120 517 ▶ if (my $qr = $Opt{dumpvars}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $qr = $Opt{"dumpvars"}) 515 2 517
1121 515 $qr = qr/$qr/;
1122 515 ▶ while (my($k,$v) = each %extract) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %extract) 65382 515 65897
1123 65382 ▶ if ($k =~ $qr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /$qr/) 65382 0 65382
1124 65382 $dumpvars->{$k}{$v}{$extract{"meta:ok"}}++;
1125 }
1126 }
1127 }
1128 517 for my $want (@q) {
1129 3102 ▶ my $have = $extract{$want} || "";
Condition100%2/2
$extract{$want} || ''
l!l
2783319
MC/DC100%1/1
$extract{$want} || ''
$extract{$want}
Truth table100%2/2
A
A= $extract{$want}
Aresult
11
00
1130 3102 $diag .= " $want\[$have]";
1131 }
1132 517 binmode \*STDERR, ":encoding(UTF-8)";
1133 517 ▶ printf STDERR " %-4s %36s%s\n", $extract{"meta:ok"}, $guid, $diag unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 517 517
1134 517 ▶ if ($Opt{raw}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"raw"}) 0 517 517
1135 0 $report =~ s/\s+\z//;
1136 0 ▶ print STDERR $report, "\n================\n" unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
1137 }
1138 517 ▶ if ($Opt{interactive}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"interactive"}) 0 517 517
1139 0 ▶ eval { require IO::Prompt; 1; } or
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require IO::Prompt; 1 } } or die "Option '--interactive' requires IO::Prompt installed" 0 0 0
1140 die "Option '--interactive' requires IO::Prompt installed";
1141 0 local @ARGV;
1142 0 local $ARGV;
1143 0 my $ans = IO::Prompt::prompt
1144 (
1145 -p => "View $guid? [onechar: ynq] ",
1146 -d => "y",
1147 -u => qr/[ynq]/,
1148 -onechar,
1149 );
1150 0 ▶ print STDERR "\n" unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 0 0
1151 0 ▶ if ($ans eq "y") {
Branch: 2 branches
BranchTrueFalseTotal
if ($ans eq 'y') { } 0 0 0
elsif ($ans eq 'q') { } 0 0 0
1152 0 my($report) = _get_cooked_report($target, \%Opt);
1153 0 ▶ $Opt{pager} ||= "less";
Condition0%0/2
$Opt{"pager"} ||= "less"
l!l
00
MC/DC0%0/1
$Opt{"pager"} ||= "less"
$Opt{"pager"}
Truth table0%0/2
A
A= $Opt{"pager"}
Aresult
11
00
1154 0 ▶ open my $lfh, "|-", $Opt{pager} or die "Could not fork '$Opt{pager}': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $lfh, "|-", $Opt{"pager"} or die qq[Could not fork '$Opt{"pager"}': $!] 0 0 0
1155 0 local $/;
1156 0 print {$lfh} $report;
1157 0 ▶ close $lfh or die "Could not close pager: $!"
Branch: 1 branch
BranchTrueFalseTotal
close $lfh or die "Could not close pager: $!" 0 0 0
1158 } elsif ($ans eq "q") {
1159 0 $Signal++;
1160 0 return;
1161 }
1162 }
1163 517 return \%extract;
1164 }
1165  
1166 517 ▶sub _get_cooked_report {
Subroutine _get_cooked_report: called CC=17 SCAR=29.2
1167 517 my($target, $Opt_ref) = @_;
1168 517 my($report, $isHTML);
1169 517 ▶ if ($report = $Opt_ref->{article}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($report = $Opt_ref->{"article"}) 1 516 517
1170 1 $isHTML = $report =~ /^</;
1171 1 undef $target;
1172 }
1173 517 ▶ if ($target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 516 1 517
1174 516 local $/;
1175 516 my $raw_report;
1176 516 ▶ if (0) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { -e $target }) { } 513 3 516
elsif (-e "$target.gz") { } 3 0 3
1177 } elsif (-e $target) {
1178 513 ▶ open my $fh, '<', $target or die "Could not open '$target': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $target or die "Could not open '${target}': $!" 513 0 513
1179 513 $raw_report = <$fh>;
1180 } elsif (-e "$target.gz") {
1181 3 ▶ open my $fh, "<", "$target.gz" or die "Could not open '$target.gz': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", "$target.gz" or die "Could not open '$target.gz': $!" 3 0 3
1182  
1183 # Opens a gzip (.gz) file for reading or writing. The mode parameter
1184 # is as in fopen ("rb" or "wb") but can also include a compression level
1185 # ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
1186 # Huffman only compression as in "wb1h", or 'R' for run-length encoding
1187 # as in "wb1R". (See the description of deflateInit2 for more information
1188 # about the strategy parameter.)
1189  
1190 3 my $gz = Compress::Zlib::gzopen($fh, "rb");
1191 3 $raw_report = "";
1192 3 my $buffer;
1193 3 ▶ while (my $bytesread = $gz->gzread($buffer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bytesread = $gz->gzread($buffer)) 23 3 26
1194 23 $raw_report .= $buffer;
1195 }
1196 } else {
1197 0 die "Could not find '$target' or '$target.gz'";
1198 }
1199 516 $isHTML = $raw_report =~ /^</;
1200 516 ▶ if ($isHTML) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isHTML) 500 16 516
1201 500 ▶ if ($raw_report =~ m{^<\?.+?<html.+?<head.+?<body.+?<pre[^>]*>(.+)</pre>.*</body>.*</html>}s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raw_report =~ m[^<\?.+?<html.+?<head.+?<body.+?<pre[^>]*>(.+)</pre>.*</body>.*</html>]s) 5 495 500
1202 5 $raw_report = decode_entities($1);
1203 5 $isHTML = 0;
1204 }
1205 }
1206 516 ▶ if ($isHTML) {
Branch: 2 branches
BranchTrueFalseTotal
if ($isHTML) { } 495 21 516
elsif ($raw_report =~ /^MIME-Version: 1.0$/m or _looks_like_qp($raw_report)) { } 8 13 21
1207 495 $report = decode_entities($raw_report);
1208 ▶ } elsif ($raw_report =~ /^MIME-Version: 1.0$/m
Condition100%3/3
$raw_report =~ /^MIME-Version: 1.0$/m or _looks_like_qp($raw_report)
l!l&&r!l&&!r
7113
MC/DC100%2/2
$raw_report =~ /^MIME-Version: 1.0$/m or _looks_like_qp($raw_report)
$raw_report =~ /^MIME-Version: 1.0$/m _looks_like_qp($raw_report)
Truth table100%3/3
A or B
A= $raw_report =~ /^MIME-Version: 1.0$/mB= _looks_like_qp($raw_report)
ABresult
1X1
011
000
1209 ||
1210 _looks_like_qp($raw_report)
1211 ) {
1212 # note(1): minimizing MIME effort; don't know about reports in other formats
1213 # note(2): Net-Generatus-0.40 had an offending report
1214 8 $report = eval { MIME::QuotedPrint::decode_qp($raw_report) };
1215 8 ▶ if (!$report || $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $report or $@) 0 8 8
Condition33%1/3
not $report or $@
l!l&&r!l&&!r
008
MC/DC0%0/2
not $report or $@
not $report $@
Truth table33%1/3
not(A) or B
A= not $reportB= $@
ABresult
1X1
011
000
1216 0 warn "WARNING: report '$target' could not be parsed as qp, giving up";
1217 0 ▶ if ($raw_report =~ /Subject:.+Dear.+Perl.+Summary/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raw_report =~ /Subject:.+Dear.+Perl.+Summary/s) 0 0 0
1218 0 $report = $raw_report;
1219 }
1220 }
1221 } else {
1222 13 $report = $raw_report;
1223 }
1224 }
1225 517 ▶ if ($report =~ /\r\n/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($report =~ /\r\n/) 1 516 517
1226 1 my @rlines = split /\r?\n/, $report;
1227 1 $report = join "\n", @rlines;
1228 }
1229 517 ($report, $isHTML);
1230 }
1231  
1232 =head2 solve
1233  
1234 Feeds a couple of potentially interesting data to
1235 Statistics::Regression and sorts the result by R^2 descending. Do not
1236 confuse this with a prove, rather take it as a useful hint. It can
1237 save you minutes of staring at data and provide a quick overview where
1238 one should look closer. Displays the N top candidates, where N
1239 defaults to 3 and can be set with the C<$Opt{solvetop}> variable.
1240 Regressions results with an R^2 of 1.00 are displayed in any case.
1241  
1242 The function is called when the option C<-solve> is given on the
1243 commandline. Several extra config variables are calculated, see source
1244 code for details.
1245  
1246 =cut
1247 {
1248 5 my %never_solve_on = map {($_ => 1)}
1249 (
1250 'conf:ccflags',
1251 'conf:config_args',
1252 'conf:cppflags',
1253 'conf:lddlflags',
1254 'conf:uname',
1255 'conf:osvers',
1256 'env:$^X',
1257 'env:PATH',
1258 'env:PERL',
1259 'env:PERL5LIB',
1260 'env:PERL5OPT',
1261 'env:PERL5_CPANPLUS_IS_RUNNING',
1262 'env:PERL5_CPAN_IS_RUNNING',
1263 'env:PERL5_CPAN_IS_RUNNING_IN_RECURSION',
1264 'env:PERL5_YACSMOKE_BASE',
1265 'env:PERLBREW_MANPATH',
1266 'env:PERLBREW_PATH',
1267 'env:PERLBREW_PERL',
1268 'env:PERL_CPAN_REPORTER_CONFIG',
1269 'env:PERL_CPAN_REPORTER_DIR',
1270 'meta:ok',
1271 'meta:perl_compiled_at',
1272 'guid',
1273 );
1274 5 my %normalize_numeric =
1275 (
1276 # here we were treating date as numeric; current
1277 # implementation requires to decide for one normalization, so
1278 # we decided 2012-02 for a sampling focussing on recentness;
1279  
1280 #'meta:date' => sub {
1281 # my $v = shift;
1282 # my($Y,$M,$D,$h,$m,$s) = $v =~ /(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)/;
1283 # unless (defined $M) {
1284 # die "illegal value[$v] for a date";
1285 # }
1286 # Time::Local::timegm($s,$m,$h,$D,$M-1,$Y);
1287 #},
1288 );
1289 my %normalize_value =
1290 (
1291 1357 ▶ 'meta:perl' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1292 1357 my($perlatpatchlevel) = shift;
1293 1357 my $perl = $perlatpatchlevel;
1294 1357 $perl =~ s/\@.*//;
1295 1357 $perl;
1296 },
1297 250 ▶ 'meta:date' => sub {
Subroutine __ANON__: called CC=7 SCAR=31.5
1298 250 my $v = shift;
1299 250 my($Y,$M,$D,$h,$m,$s) = $v =~ /(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)/;
1300 250 ▶ unless (defined $M) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $M) 0 250 250
1301 0 die "illegal value[$v] for a date";
1302 }
1303 250 my $epoch = Time::Local::timegm($s,$m,$h,$D,$M-1,$Y);
1304 250 my $Y_epoch = time - 2*365.25*86400;
1305 250 my $ret;
1306 250 ▶ if ($epoch < $Y_epoch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($epoch < $Y_epoch) { } 250 0 250
1307 250 $ret = $Y;
1308 } else {
1309 0 my @gmtime = gmtime $Y_epoch; $gmtime[5] += 1900;
1310 0 ▶ if ($Y == $gmtime[5]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Y == $gmtime[5]) { } 0 0 0
1311 0 $ret = $Y;
1312 } else {
1313 0 my $M_epoch = time - 9*7*86400;
1314 0 ▶ if ($epoch < $M_epoch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($epoch < $M_epoch) { } 0 0 0
1315 0 $ret = "$Y-$M";
1316 } else {
1317 0 my @gmtime = gmtime $M_epoch; $gmtime[5] += 1900; $gmtime[4]++;
1318 0 ▶ if ($Y == $gmtime[5] && $M == $gmtime[4]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Y == $gmtime[5] and $M == $gmtime[4]) { } 0 0 0
Condition0%0/3
$Y == $gmtime[5] and $M == $gmtime[4]
!ll&&!rl&&r
000
MC/DC0%0/2
$Y == $gmtime[5] and $M == $gmtime[4]
$Y == $gmtime[5] $M == $gmtime[4]
Truth table0%0/3
A and B
A= $Y == $gmtime[5]B= $M == $gmtime[4]
ABresult
0X0
100
111
1319 0 $ret = "$Y-$M";
1320 } else {
1321 0 $ret = "$Y-$M-$D";
1322 }
1323 }
1324 }
1325 }
1326 250 return $ret;
1327 },
1328 5 );
1329 1 ▶sub solve {
Subroutine solve: called CC=40 SCAR=38.9
Pod documented
1330 1 my($V,%Opt) = @_;
1331 1 require Statistics::Regression;
1332 1 my @regression;
1333 my $ycb;
1334 1 ▶ if (my $ycbbody = $Opt{ycb}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ycbbody = $Opt{'ycb'}) { } 0 1 1
1335 0 $ycb = eval('sub {'.$ycbbody.'}');
1336 0 ▶ die if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1337 } else {
1338 41210 ▶ $ycb = sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1339 41210 my $rec = shift;
1340 41210 my $y;
1341 41210 ▶ if ($rec->{"meta:ok"} eq "PASS") {
Branch: 2 branches
BranchTrueFalseTotal
if ($rec->{'meta:ok'} eq 'PASS') { } 25043 16167 41210
elsif ($rec->{'meta:ok'} eq 'FAIL') { } 15533 634 16167
1342 25043 $y = 1;
1343 } elsif ($rec->{"meta:ok"} eq "FAIL") {
1344 15533 $y = 0;
1345 }
1346 41210 return $y
1347 1 };
1348 }
1349 1 VAR: for my $variable (sort keys %$V) {
1350 341 ▶ next if $variable eq "==DATA==";
Branch: 1 branch
BranchTrueFalseTotal
if $variable eq "==DATA==" 1 340 341
1351 340 ▶ if ($never_solve_on{$variable}){
Branch: 1 branch
BranchTrueFalseTotal
if ($never_solve_on{$variable}) 17 323 340
1352 17 ▶ warn "Skipping '$variable'\n" unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 17 17
1353 17 next VAR;
1354 }
1355 323 my $value_distribution = $V->{$variable};
1356 323 my $keys = keys %$value_distribution;
1357 323 my @X = qw(const);
1358 323 ▶ if ($normalize_numeric{$variable}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($normalize_numeric{$variable}) { } 0 323 323
1359 0 push @X, "n_$variable";
1360 } else {
1361 323 my %seen = ();
1362 323 for my $value (sort keys %$value_distribution) {
1363 1038 my $pf = $value_distribution->{$value};
1364 1038 ▶ $pf->{PASS} ||= 0;
Condition100%2/2
$pf->{"PASS"} ||= 0
l!l
782256
MC/DC100%1/1
$pf->{"PASS"} ||= 0
$pf->{"PASS"}
Truth table100%2/2
A
A= $pf->{"PASS"}
Aresult
11
00
1365 1038 ▶ $pf->{FAIL} ||= 0;
Condition100%2/2
$pf->{"FAIL"} ||= 0
l!l
524514
MC/DC100%1/1
$pf->{"FAIL"} ||= 0
$pf->{"FAIL"}
Truth table100%2/2
A
A= $pf->{"FAIL"}
Aresult
11
00
1366 1038 ▶ if ($pf->{PASS} || $pf->{FAIL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pf->{"PASS"} or $pf->{"FAIL"}) 1025 13 1038
Condition100%3/3
$pf->{"PASS"} or $pf->{"FAIL"}
l!l&&r!l&&!r
78224313
MC/DC100%2/2
$pf->{"PASS"} or $pf->{"FAIL"}
$pf->{"PASS"} $pf->{"FAIL"}
Truth table100%3/3
A or B
A= $pf->{"PASS"}B= $pf->{"FAIL"}
ABresult
1X1
011
000
1367 my $Xele = sprintf "eq_%s",
1368 (
1369 $normalize_value{$variable} ?
1370 1025 ▶ $normalize_value{$variable}->($value) :
Branch: 1 branch
BranchTrueFalseTotal
$normalize_value{$variable} ? : 199 826 1025
1371 $value
1372 );
1373 1025 ▶ push @X, $Xele unless $seen{$Xele}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $seen{$Xele}++ 837 188 1025
1374  
1375 }
1376 1038 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($pf->{"PASS"} xor $pf->{"FAIL"}) 744 294 1038
Condition100%4/4
$pf->{"PASS"} xor $pf->{"FAIL"}
l&&rl&&!r!l&&r!l&&!r
28150124313
MC/DC100%2/2
$pf->{"PASS"} xor $pf->{"FAIL"}
$pf->{"PASS"} $pf->{"FAIL"}
Truth table100%4/4
A xor B
A= $pf->{"PASS"}B= $pf->{"FAIL"}
ABresult
110
101
011
000
1377 $pf->{PASS} xor $pf->{FAIL}
1378 ) {
1379 744 my $vl = 40;
1380 744 ▶ substr($value,$vl) = "..." if length $value > 3+$vl;
Branch: 1 branch
BranchTrueFalseTotal
if length $value > 3 + $vl 182 562 744
1381 744 my $poor_mans_freehand_estimation = 0;
1382 744 ▶ if ($poor_mans_freehand_estimation) {
Branch: 1 branch
BranchTrueFalseTotal
if ($poor_mans_freehand_estimation) 0 744 744
1383 warn sprintf
1384 (
1385 "%4d %4d %-23s | %s\n",
1386 $pf->{PASS},
1387 $pf->{FAIL},
1388 0 $variable,
1389 $value,
1390 );
1391 }
1392 }
1393 }
1394 }
1395 323 ▶ warn "variable[$variable]keys[$keys]X[@X]\n" unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 323 323
1396 323 ▶ next VAR unless @X > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @X > 1 6 317 323
1397 317 my %regdata =
1398 (
1399 X => \@X,
1400 data => [],
1401 );
1402 317 RECORD: for my $rec (@{$V->{"==DATA=="}}) {
1403 41210 my $y = $ycb->($rec);
1404 41210 ▶ next RECORD unless defined $y;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $y 634 40576 41210
1405 40576 my %obs;
1406 40576 $obs{Y} = $y;
1407 40576 @obs{@X} = (0) x @X;
1408 40576 $obs{const} = 1;
1409 40576 for my $x (@X) {
1410 147712 ▶ if ($x =~ /^eq_(.+)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($x =~ /^eq_(.+)/) { } 106240 41472 147712
elsif ($x =~ /^n_(.+)/) { } 0 41472 41472
1411 106240 my $read_v = $1;
1412 106240 ▶ if (exists $rec->{$variable}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rec->{$variable} and defined $rec->{$variable}) 74030 32210 106240
Condition66%2/3
exists $rec->{$variable} and defined $rec->{$variable}
!ll&&!rl&&r
32210074030
MC/DC50%1/2
exists $rec->{$variable} and defined $rec->{$variable}
exists $rec->{$variable} defined $rec->{$variable}
Truth table66%2/3
A and B
A= exists $rec->{$variable}B= defined $rec->{$variable}
ABresult
0X0
100
111
1413 && defined $rec->{$variable}
1414 ) {
1415 my $use_v = (
1416 $normalize_value{$variable} ?
1417 $normalize_value{$variable}->($rec->{$variable}) :
1418 74030 ▶ $rec->{$variable}
Branch: 1 branch
BranchTrueFalseTotal
$normalize_value{$variable} ? : 1408 72622 74030
1419 );
1420 74030 ▶ if ($use_v eq $read_v) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_v eq $read_v) 14466 59564 74030
1421 14466 $obs{$x} = 1;
1422 }
1423 }
1424 # warn "DEBUG: y[$y]x[$x]obs[$obs{$x}]\n";
1425 } elsif ($x =~ /^n_(.+)/) {
1426 0 my $v = $1;
1427 0 $obs{$x} = eval { $normalize_numeric{$v}->($rec->{$v}); };
1428 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1429 0 warn "Warning: error during parsing v[$v] in record[$rec->{guid}]: $@; continuing with undef value";
1430 }
1431 }
1432 }
1433 40576 push @{$regdata{data}}, \%obs;
1434 }
1435 317 my $start = Time::HiRes::time;
1436 317 _run_regression ($variable, \%regdata, \@regression, \%Opt);
1437 317 my $end = Time::HiRes::time;
1438 warn sprintf "regressiontimings[%s]start[%s]end[%s]diff[%s]\n",
1439 317 ▶ $variable, $start, $end, $end-$start unless $Opt{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $Opt{"quiet"} 0 317 317
1440 }
1441 1 ▶ my $top = min ($Opt{solvetop} || 3, scalar @regression);
Condition50%1/2
$Opt{'solvetop'} || 3
l!l
01
MC/DC0%0/1
$Opt{'solvetop'} || 3
$Opt{'solvetop'}
Truth table50%1/2
A
A= $Opt{'solvetop'}
Aresult
11
00
1442 1 ▶ my $max_rsq = sum map {1==$_->rsq ? 1 : 0} @regression;
Branch: 1 branch
BranchTrueFalseTotal
1 == $_->rsq ? : 0 303 303
1443 1 ▶ $top = $max_rsq if $max_rsq && $max_rsq > $top;
Branch: 1 branch
BranchTrueFalseTotal
if $max_rsq and $max_rsq > $top 0 1 1
Condition33%1/3
$max_rsq and $max_rsq > $top
!ll&&!rl&&r
100
MC/DC0%0/2
$max_rsq and $max_rsq > $top
$max_rsq $max_rsq > $top
Truth table33%1/3
A and B
A= $max_rsqB= $max_rsq > $top
ABresult
0X0
100
111
1444 1 my $score = 0;
1445 1 printf
1446 (
1447 "State after regression testing: %d results, showing top %d\n\n",
1448 scalar @regression,
1449 $top,
1450 );
1451 1 for my $reg (sort {
1452 1969 ▶ $b->rsq <=> $a->rsq
Condition100%3/3
$b->rsq <=> $a->rsq || $a->k <=> $b->k
l!l&&r!l&&!r
15572410
MC/DC100%2/2
$b->rsq <=> $a->rsq || $a->k <=> $b->k
$b->rsq <=> $a->rsq $a->k <=> $b->k
Truth table100%3/3
A || B
A= $b->rsq <=> $a->rsqB= $a->k <=> $b->k
ABresult
1X1
011
000
1453 ||
1454 $a->k <=> $b->k
1455 } @regression) {
1456 3 printf "(%d)\n", ++$score;
1457 3 eval { $reg->print; };
1458 3 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3 3
1459 0 printf "\n\nOops, Statistics::Regression died during ->print() with error message[$@]\n\n";
1460 }
1461 3 ▶ last if --$top <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$top <= 0 1 2 3
1462 }
1463 }
1464 }
1465  
1466 # $variable is the name we pass through to S:R constructor
1467 # $regdata is hash and has the arrays "X" and "data" (observations)
1468 # X goes to S:R constructor
1469 # each observation has a Y which we pass to S:R in an include() call
1470 # $regression is the collector array of results
1471 # $opt are the options from outside, used to see if we are "verbose"
1472 5 ▶sub _run_regression {
Subroutine _run_regression: called CC=7 SCAR=19.7
1473 317 my($variable,$regdata,$regression,$opt) = @_;
1474 317 my @X = @{$regdata->{X}};
1475 # my $splo = $regdata->{"spliced-out"} = []; # maybe can be used to
1476 # hold the reference
1477 # group
1478 317 ▶ while (@X > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@X > 1) 362 14 376
1479 362 my $reg = Statistics::Regression->new($variable,\@X);
1480 362 for my $obs (@{$regdata->{data}}) {
1481 46336 my $y = delete $obs->{Y};
1482 46336 $reg->include($y, $obs);
1483 46336 $obs->{Y} = $y;
1484 }
1485 362 eval {$reg->theta;
1486 362 my @e = $reg->standarderrors;
1487 303 ▶ die "found standarderrors == 0" if grep { 0 == $_ } @e;
Branch: 1 branch
BranchTrueFalseTotal
if grep {0 == $_;} @e 0 303 303
1488 303 $reg->rsq;};
1489 362 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 59 303 362
1490 59 ▶ if ($opt->{verbose} && $opt->{verbose}>=2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{"verbose"} and $opt->{"verbose"} >= 2) 0 59 59
Condition33%1/3
$opt->{"verbose"} and $opt->{"verbose"} >= 2
!ll&&!rl&&r
5900
MC/DC0%0/2
$opt->{"verbose"} and $opt->{"verbose"} >= 2
$opt->{"verbose"} $opt->{"verbose"} >= 2
Truth table33%1/3
A and B
A= $opt->{"verbose"}B= $opt->{"verbose"} >= 2
ABresult
0X0
100
111
1491 warn _yaml_dump
1492 ({error=>"could not determine some regression parameters",
1493 variable=>$variable,
1494 k=>$reg->k,
1495 n=>$reg->n,
1496 0 X=>$regdata->{"X"},
1497 errorstr => $@,
1498 });
1499 }
1500 # reduce k in case that linear dependencies disturbed us;
1501 # often called reference group; I'm tempted to collect and
1502 # make visible
1503 59 splice @X, 1, 1;
1504 } else {
1505 # $reg->print;
1506 303 push @$regression, $reg;
1507 303 return;
1508 }
1509 }
1510 }
1511  
1512 =head1 AUTHOR
1513  
1514 Andreas König
1515  
1516 =head1 BUGS
1517  
1518 Please report any bugs or feature requests through the web
1519 interface at
1520 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPAN-Testers-ParseReport>.
1521 I will be notified, and then you'll automatically be notified of
1522 progress on your bug as I make changes.
1523  
1524 =head1 SUPPORT
1525  
1526 You can find documentation for this module with the perldoc command.
1527  
1528 perldoc CPAN::Testers::ParseReport
1529  
1530  
1531 You can also look for information at:
1532  
1533 =over 4
1534  
1535 =item * RT: CPAN's request tracker
1536  
1537 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPAN-Testers-ParseReport>
1538  
1539 =item * AnnoCPAN: Annotated CPAN documentation
1540  
1541 L<http://annocpan.org/dist/CPAN-Testers-ParseReport>
1542  
1543 =item * CPAN Ratings
1544  
1545 L<http://cpanratings.perl.org/d/CPAN-Testers-ParseReport>
1546  
1547 =item * Search CPAN
1548  
1549 L<http://search.cpan.org/dist/CPAN-Testers-ParseReport>
1550  
1551 =back
1552  
1553  
1554 =head1 ACKNOWLEDGEMENTS
1555  
1556 Thanks to RJBS for module-starter.
1557  
1558 =head1 COPYRIGHT & LICENSE
1559  
1560 Copyright 2008,2009,2010,2011,2012,2013,2014,2015,2016 Andreas König.
1561  
1562 This program is free software; you can redistribute it and/or modify it
1563 under the same terms as Perl itself.
1564  
1565  
1566 =cut
1567  
1568 5 1; # End of CPAN::Testers::ParseReport
↑ Summary blib/lib/CPAN/Testers/dagolden-reversion-gist.pl »