blib/lib/CPAN/Reporter.pm

filter: Statementstmt 85.6% 532 / 621 Branchbran 73.8% 229 / 310 Conditioncond 71.6% 86 / 120 MC/DCmcdc 52.2% 35 / 67 Subroutinesub 96.7% 59 / 61 Podpod 0.0% 0 / 6 totaltotal 79.4% 941 / 1185 CC 215 SCAR 29.3
CC
215
Cov
81%
_parse_test_harness
42.0
_timeout_wrapper_win32
42.0
_dispatch_report
40.8
CRAP 18.8
« blib/lib/CPAN/Reporter/PrereqCheck.pm ↑ Summary blib/lib/CPAN/Reporter/Config.pm »
1 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package CPAN::Reporter;
3  
4 33 our $VERSION = '1.2018';
5  
6 33 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 33 ▶use Capture::Tiny qw/ capture tee_merged /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 33 ▶use CPAN 1.94 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 #CPAN.pm was split into separate files in this version
10 #set minimum to it for simplicity
11 33 ▶use CPAN::Version ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 33 ▶use File::Basename qw/basename dirname/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 33 ▶use File::Find ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 33 ▶use File::HomeDir ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 33 ▶use File::Path qw/mkpath rmtree/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 33 ▶use File::Spec 3.19 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 33 ▶use File::Temp 0.16 qw/tempdir/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 33 ▶use IO::File ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 33 ▶use Parse::CPAN::Meta ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 33 ▶use Probe::Perl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21 33 ▶use Test::Reporter 1.54 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 33 ▶use CPAN::Reporter::Config ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 33 ▶use CPAN::Reporter::History ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 33 ▶use CPAN::Reporter::PrereqCheck ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 33 ▶use constant MAX_OUTPUT_LENGTH => 1_000_000;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 #--------------------------------------------------------------------------#
29 # create temp lib dir for Devel::Autoflush
30 # so that PERL5OPT=-MDevel::Autoflush is found by any perl
31 #--------------------------------------------------------------------------#
32  
33 33 ▶use Devel::Autoflush 0.04 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
34 # directory fixture
35 33 my $Autoflush_Lib = tempdir(
36 "CPAN-Reporter-lib-XXXX", TMPDIR => 1, CLEANUP => 1
37 );
38 # copy Devel::Autoflush to directory or clear autoflush_lib variable
39 _file_copy_quiet(
40 33 ▶ $INC{'Devel/Autoflush.pm'},
Branch: 1 branch
BranchTrueFalseTotal
_file_copy_quiet($INC{"Devel/Autoflush.pm"}, "File::Spec"->catfile($Autoflush_Lib, ("Devel", "Autoflush.pm"))) or undef $Autoflush_Lib 0 33 33
41 File::Spec->catfile( $Autoflush_Lib, qw/Devel Autoflush.pm/ )
42 ) or undef $Autoflush_Lib;
43  
44 #--------------------------------------------------------------------------#
45 # public API
46 #--------------------------------------------------------------------------#
47  
48 sub configure {
49 4 ▶ goto &CPAN::Reporter::Config::_configure;
Subroutine configure: called CC=1 SCAR=0.0
Pod undocumented
50 }
51  
52 sub grade_make {
53 16 ▶ my @args = @_;
Subroutine grade_make: called CC=5 SCAR=16.1
Pod undocumented
54 16 ▶ my $result = _init_result( 'make', @args ) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $result = _init_result("make", @args) or return 1 15 16
55 15 _compute_make_grade($result);
56 15 ▶ if ( $result->{grade} eq 'discard' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{'grade'} eq 'discard') { } 4 11 15
57 $CPAN::Frontend->myprint(
58 "\nCPAN::Reporter: test results were not valid, $result->{grade_msg}.\n\n",
59 4 $result->{prereq_pm}, "\n",
60 "Test report will not be sent"
61 );
62 4 ▶ CPAN::Reporter::History::_record_history( $result )
Branch: 1 branch
BranchTrueFalseTotal
unless CPAN::Reporter::History::_is_duplicate($result) 1 3 4
63 if not CPAN::Reporter::History::_is_duplicate( $result );
64 }
65 else {
66 11 _print_grade_msg($result->{make_cmd}, $result);
67 11 ▶ if ( $result->{grade} ne 'pass' ) { _dispatch_report( $result ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{"grade"} ne "pass") 9 2 11
68 }
69 15 return $result->{success};
70 }
71  
72 sub grade_PL {
73 34 ▶ my @args = @_;
Subroutine grade_PL: called CC=5 SCAR=16.1
Pod undocumented
74 34 ▶ my $result = _init_result( 'PL', @args ) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $result = _init_result("PL", @args) or return 1 33 34
75 33 _compute_PL_grade($result);
76 33 ▶ if ( $result->{grade} eq 'discard' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{'grade'} eq 'discard') { } 9 24 33
77 $CPAN::Frontend->myprint(
78 "\nCPAN::Reporter: test results were not valid, $result->{grade_msg}.\n\n",
79 9 $result->{prereq_pm}, "\n",
80 "Test report will not be sent"
81 );
82 9 ▶ CPAN::Reporter::History::_record_history( $result )
Branch: 1 branch
BranchTrueFalseTotal
unless CPAN::Reporter::History::_is_duplicate($result) 2 7 9
83 if not CPAN::Reporter::History::_is_duplicate( $result );
84 }
85 else {
86 24 _print_grade_msg($result->{PL_file} , $result);
87 24 ▶ if ( $result->{grade} ne 'pass' ) { _dispatch_report( $result ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{"grade"} ne "pass") 18 6 24
88 }
89 33 return $result->{success};
90 }
91  
92 sub grade_test {
93 119 ▶ my @args = @_;
Subroutine grade_test: called CC=4 SCAR=13.9
Pod undocumented
94 119 ▶ my $result = _init_result( 'test', @args ) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $result = _init_result("test", @args) or return 1 118 119
95 118 _compute_test_grade($result);
96 118 ▶ if ( $result->{grade} eq 'discard' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{'grade'} eq 'discard') { } 15 103 118
97 $CPAN::Frontend->myprint(
98 "\nCPAN::Reporter: test results were not valid, $result->{grade_msg}.\n\n",
99 15 $result->{prereq_pm}, "\n",
100 "Test report will not be sent"
101 );
102 15 ▶ CPAN::Reporter::History::_record_history( $result )
Branch: 1 branch
BranchTrueFalseTotal
unless CPAN::Reporter::History::_is_duplicate($result) 3 12 15
103 if not CPAN::Reporter::History::_is_duplicate( $result );
104 }
105 else {
106 103 _print_grade_msg( "Test", $result );
107 103 _dispatch_report( $result );
108 }
109 118 return $result->{success};
110 }
111  
112 sub record_command {
113 186 ▶ my ($command, $timeout) = @_;
Subroutine record_command: called CC=15 SCAR=28.3
Pod undocumented
114  
115 # XXX refactor this!
116 # Get configuration options
117 186 ▶ if ( -r CPAN::Reporter::Config::_get_config_file() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-r CPAN::Reporter::Config::_get_config_file()) 170 16 186
118 170 my $config_obj = CPAN::Reporter::Config::_open_config_file();
119 170 my $config;
120 170 ▶ $config = CPAN::Reporter::Config::_get_config_options( $config_obj )
Branch: 1 branch
BranchTrueFalseTotal
if $config_obj 170 0 170
121 if $config_obj;
122  
123 170 ▶ $timeout ||= $config->{command_timeout}; # might still be undef
Condition100%3/3
$timeout ||= $config->{"command_timeout"}
l!l&&r!l&&!r
66158
MC/DC100%2/2
$timeout ||= $config->{"command_timeout"}
$timeout $config->{"command_timeout"}
Truth table100%3/3
A ||= B
A= $timeoutB= $config->{"command_timeout"}
ABresult
1X1
011
000
124 }
125  
126 186 my ($cmd, $redirect) = _split_redirect($command);
127  
128 # Teeing a command loses its exit value so we must wrap the command
129 # and print the exit code so we can read it off of output
130 186 my $wrap_code;
131 186 ▶ if ( $timeout ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($timeout) 15 171 186
132 15 ▶ $wrap_code = $^O eq 'MSWin32'
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 15 15
133 ? _timeout_wrapper_win32($cmd, $timeout)
134 : _timeout_wrapper($cmd, $timeout);
135 }
136 # if no timeout or timeout wrap code wasn't available
137 186 ▶ if ( ! $wrap_code ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wrap_code) 171 15 186
138 171 my $safecmd = quotemeta($cmd);
139 171 $wrap_code = << "HERE";
140 my \$rc = system("$safecmd");
141 my \$ec = \$rc == -1 ? -1 : \$?;
142 print "($safecmd exited with \$ec)\\n";
143 HERE
144 }
145  
146 # write code to a tempfile for execution
147 186 my $wrapper_name = _temp_filename( 'CPAN-Reporter-CW-' );
148 186 ▶ my $wrapper_fh = IO::File->new( $wrapper_name, 'w' )
Branch: 1 branch
BranchTrueFalseTotal
my $wrapper_fh = "IO::File"->new($wrapper_name, "w") or die "Could not create a wrapper for ${cmd}: $!" 0 186 186
149 or die "Could not create a wrapper for $cmd\: $!";
150  
151 186 $wrapper_fh->print( $wrap_code );
152 186 $wrapper_fh->close;
153  
154 # tee the command wrapper
155 186 my @tee_input = ( Probe::Perl->find_perl_interpreter, $wrapper_name );
156 186 ▶ push @tee_input, $redirect if defined $redirect;
Branch: 1 branch
BranchTrueFalseTotal
if defined $redirect 1 185 186
157 186 my $tee_out;
158 {
159 # ensure autoflush if we can
160 186 ▶ local $ENV{PERL5OPT} = _get_perl5opt() if _is_PL($command);
Branch: 1 branch
BranchTrueFalseTotal
if _is_PL($command) 39 147 186
161 186 ▶ $tee_out = tee_merged { system( @tee_input ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
162 }
163  
164 # cleanup
165 186 ▶ unlink $wrapper_name unless $ENV{PERL_CR_NO_CLEANUP};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"PERL_CR_NO_CLEANUP"} 186 0 186
166  
167 186 my @cmd_output = split qr{(?<=$/)}, $tee_out;
168 186 ▶ if ( ! @cmd_output ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@cmd_output) 0 186 186
169 0 $CPAN::Frontend->mywarn(
170 "CPAN::Reporter: didn't capture command results for '$cmd'\n"
171 );
172 0 return;
173 }
174  
175 # extract the exit value
176 186 my $exit_value;
177 186 ▶ if ( $cmd_output[-1] =~ m{exited with} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd_output[-1] =~ /exited with/) 186 0 186
178 186 ($exit_value) = $cmd_output[-1] =~ m{exited with ([-0-9]+)};
179 186 pop @cmd_output;
180 }
181  
182 # bail out on some errors
183 186 ▶ if ( ! defined $exit_value ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $exit_value) { } 0 186 186
elsif ($exit_value == -1) { } 0 186 186
184 0 $CPAN::Frontend->mywarn(
185 "CPAN::Reporter: couldn't determine exit value for '$cmd'\n"
186 );
187 0 return;
188 }
189 elsif ( $exit_value == -1 ) {
190 0 $CPAN::Frontend->mywarn(
191 "CPAN::Reporter: couldn't execute '$cmd'\n"
192 );
193 0 return;
194 }
195  
196 186 return \@cmd_output, $exit_value;
197 }
198  
199 sub test {
200 76 ▶ my ($dist, $system_command) = @_;
Subroutine test: called CC=1 SCAR=0.0
Pod undocumented
201 76 my ($output, $exit_value) = record_command( $system_command );
202 76 return grade_test( $dist, $system_command, $output, $exit_value );
203 }
204  
205 #--------------------------------------------------------------------------#
206 # private functions
207 #--------------------------------------------------------------------------#
208  
209 #--------------------------------------------------------------------------#
210 # _compute_make_grade
211 #--------------------------------------------------------------------------#
212  
213 sub _compute_make_grade {
214 15 ▶ my $result = shift;
Subroutine _compute_make_grade: called CC=2 SCAR=6.9
215 15 my ($grade,$msg);
216 15 ▶ if ( $result->{exit_value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{'exit_value'}) { } 13 2 15
217 13 $result->{grade} = "unknown";
218 13 $result->{grade_msg} = "Stopped with an error"
219 }
220 else {
221 2 $result->{grade} = "pass";
222 2 $result->{grade_msg} = "No errors"
223 }
224  
225 15 _downgrade_known_causes( $result );
226  
227 15 $result->{success} = $result->{grade} eq 'pass';
228 15 return;
229 }
230  
231 #--------------------------------------------------------------------------#
232 # _compute_PL_grade
233 #--------------------------------------------------------------------------#
234  
235 sub _compute_PL_grade {
236 33 ▶ my $result = shift;
Subroutine _compute_PL_grade: called CC=2 SCAR=6.9
237 33 my ($grade,$msg);
238 33 ▶ if ( $result->{exit_value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{'exit_value'}) { } 23 10 33
239 23 $result->{grade} = "unknown";
240 23 $result->{grade_msg} = "Stopped with an error"
241 }
242 else {
243 10 $result->{grade} = "pass";
244 10 $result->{grade_msg} = "No errors"
245 }
246  
247 33 _downgrade_known_causes( $result );
248  
249 33 $result->{success} = $result->{grade} eq 'pass';
250 33 return;
251 }
252  
253 #--------------------------------------------------------------------------#
254 # _compute_test_grade
255 #
256 # Don't shortcut to unknown unless _has_tests because a custom
257 # Makefile.PL or Build.PL might define tests in a non-standard way
258 #
259 # With test.pl and 'make test', any t/*.t might pass Test::Harness, but
260 # test.pl might still fail, or there might only be test.pl,
261 # so use exit code directly
262 #
263 # Likewise, if we have recursive Makefile.PL, then we don't trust the
264 # reverse-order parsing and should just take the exit code directly
265 #
266 # Otherwise, parse in reverse order for Test::Harness output or a couple
267 # other significant strings and stop after the first match. Going in
268 # reverse and stopping is done to (hopefully) avoid picking up spurious
269 # results from any test output. But then we have to check for
270 # unsupported OS strings in case those were printed but were not fatal.
271 #--------------------------------------------------------------------------#
272  
273 sub _compute_test_grade {
274 118 ▶ my $result = shift;
Subroutine _compute_test_grade: called CC=15 SCAR=27.1
275 118 my ($grade,$msg);
276 118 my $output = $result->{output};
277  
278 # In some cases, get a result straight from the exit code
279 118 ▶ if ( $result->{is_make} && ( -f "test.pl" || _has_recursive_make() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{'is_make'} and -f 'test.pl' || _has_recursive_make()) { } 16 102 118
Condition100%6/6
$result->{"is_make"} and -f "test.pl" || _has_recursive_make()
!ll&&!rl&&r
386416
-f "test.pl" or _has_recursive_make()
l!l&&r!l&&!r
13364
MC/DC100%3/3
$result->{"is_make"} and -f "test.pl" || _has_recursive_make()
$result->{"is_make"} -f "test.pl" _has_recursive_make()
Truth table100%4/4
A and B or C
A= $result->{"is_make"}B= -f "test.pl"C= _has_recursive_make()
ABCresult
0XX0
1000
11X1
1011
280 16 ▶ if ( $result->{exit_value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{'exit_value'}) { } 10 6 16
281 10 $grade = "fail";
282 10 $msg = "'make test' error detected";
283 }
284 else {
285 6 $grade = "pass";
286 6 $msg = "'make test' no errors";
287 }
288 }
289 # Otherwise, get a result from Test::Harness output
290 else {
291 # figure out the right harness parser
292 102 _expand_result( $result );
293 102 my $harness_version = $result->{toolchain}{'Test::Harness'}{have};
294 102 ▶ my $harness_parser = CPAN::Version->vgt($harness_version, '2.99_01')
Branch: 1 branch
BranchTrueFalseTotal
'CPAN::Version'->vgt($harness_version, '2.99_01') ? : 102 0 102
295 ? \&_parse_tap_harness
296 : \&_parse_test_harness;
297 # parse lines in reverse
298 102 for my $i ( reverse 0 .. $#{$output} ) {
299 268 ▶ if ( $output->[$i] =~ m{No support for OS|OS unsupported}ims ) { # from any *.t file
Branch: 2 branches
BranchTrueFalseTotal
if ($output->[$i] =~ /No support for OS|OS unsupported/ism) { } 6 262 268
elsif ($output->[$i] =~ /^.?No tests defined/ms) { } 8 254 262
300 6 $grade = 'na';
301 6 $msg = 'This platform is not supported';
302 }
303 elsif ( $output->[$i] =~ m{^.?No tests defined}ms ) { # from M::B
304 8 $grade = 'unknown';
305 8 $msg = 'No tests provided';
306 }
307 else {
308 254 ($grade, $msg) = $harness_parser->( $output->[$i] );
309 }
310 268 ▶ last if $grade;
Branch: 1 branch
BranchTrueFalseTotal
if $grade 90 178 268
311 }
312 # fallback on exit value if no recognizable Test::Harness output
313 102 ▶ if ( ! $grade ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($grade) 12 90 102
314 12 ▶ $grade = $result->{exit_value} ? "fail" : "pass";
Branch: 1 branch
BranchTrueFalseTotal
$result->{'exit_value'} ? : 6 6 12
315 $msg = ( $result->{is_make} ? "'make test' " : "'Build test' " )
316 12 ▶ . ( $result->{exit_value} ? "error detected" : "no errors");
Branch: 2 branches
BranchTrueFalseTotal
$result->{'is_make'} ? : 9 3 12
$result->{'exit_value'} ? : 6 6 12
317 }
318 }
319  
320 118 $result->{grade} = $grade;
321 118 $result->{grade_msg} = $msg;
322  
323 118 _downgrade_known_causes( $result );
324  
325 $result->{success} = $result->{grade} eq 'pass'
326 118 ▶ || $result->{grade} eq 'unknown';
Condition100%3/3
$result->{'grade'} eq 'pass' || $result->{'grade'} eq 'unknown'
l!l&&r!l&&!r
321076
MC/DC100%2/2
$result->{'grade'} eq 'pass' || $result->{'grade'} eq 'unknown'
$result->{'grade'} eq 'pass' $result->{'grade'} eq 'unknown'
Truth table100%3/3
A || B
A= $result->{'grade'} eq 'pass'B= $result->{'grade'} eq 'unknown'
ABresult
1X1
011
000
327 118 return;
328 }
329  
330 #--------------------------------------------------------------------------#
331 # _dispatch_report
332 #
333 # Set up Test::Reporter and prompt user for edit, send
334 #--------------------------------------------------------------------------#
335  
336 sub _dispatch_report {
337 131 ▶ my $result = shift;
Subroutine _dispatch_report: called CC=28 SCAR=37.1
338 131 my $phase = $result->{phase};
339  
340 131 $CPAN::Frontend->myprint(
341 "CPAN::Reporter: preparing a CPAN Testers report for $result->{dist_name}\n"
342 );
343  
344 # Get configuration options
345 131 my $config_obj = CPAN::Reporter::Config::_open_config_file();
346 131 my $config;
347 131 ▶ $config = CPAN::Reporter::Config::_get_config_options( $config_obj )
Branch: 1 branch
BranchTrueFalseTotal
if $config_obj 126 5 131
348 if $config_obj;
349 131 ▶ if ( ! $config->{email_from} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($config->{"email_from"}) 5 126 131
350 5 $CPAN::Frontend->mywarn( << "EMAIL_REQUIRED");
351  
352 CPAN::Reporter: required 'email_from' option missing an email address, so
353 test report will not be sent. See documentation for configuration details.
354  
355 Even though CPAN Testers no longer uses email, this email address will
356 show up in the report and help identify the tester. This is required
357 for compatibility with tools that process legacy reports for analysis.
358  
359 EMAIL_REQUIRED
360 5 return;
361 }
362  
363 # Need to know if this is a duplicate
364 126 my $is_duplicate = CPAN::Reporter::History::_is_duplicate( $result );
365  
366 # Abort if the distribution name is not formatted according to
367 # CPAN Testers requirements: Dist-Name-version.suffix
368 # Regex from CPAN-Testers should extract name, separator, version
369 # and extension
370 my @format_checks = $result->{dist_basename} =~
371 126 m{(.+)([\-\_])(v?\d.*)(\.(?:tar\.(?:gz|bz2)|tgz|zip))$}i;
372 ;
373 126 ▶ if ( ! grep { length } @format_checks ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {length $_;} @format_checks) 3 123 126
374 3 $CPAN::Frontend->mywarn( << "END_BAD_DISTNAME");
375  
376 CPAN::Reporter: the distribution name '$result->{dist_basename}' does not
377 appear to be packaged according to CPAN tester guidelines. Perhaps it is
378 not a normal CPAN distribution.
379  
380 Test report will not be sent.
381  
382 END_BAD_DISTNAME
383  
384 # record this as a discard, instead
385 3 $result->{grade} = 'discard';
386 3 ▶ CPAN::Reporter::History::_record_history( $result )
Branch: 1 branch
BranchTrueFalseTotal
unless $is_duplicate 3 0 3
387 if not $is_duplicate;
388 3 return;
389 }
390  
391 # Gather 'expensive' data for the report
392 123 _expand_result( $result);
393  
394 # Skip if distribution name matches the send_skipfile
395 123 ▶ if ( $config->{send_skipfile} && -r $config->{send_skipfile} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"send_skipfile"} and -r $config->{"send_skipfile"}) 4 119 123
Condition66%2/3
$config->{"send_skipfile"} and -r $config->{"send_skipfile"}
!ll&&!rl&&r
11904
MC/DC50%1/2
$config->{"send_skipfile"} and -r $config->{"send_skipfile"}
$config->{"send_skipfile"} -r $config->{"send_skipfile"}
Truth table66%2/3
A and B
A= $config->{"send_skipfile"}B= -r $config->{"send_skipfile"}
ABresult
0X0
100
111
396 4 my $send_skipfile = IO::File->new( $config->{send_skipfile}, "r" );
397 4 my $dist_id = $result->{dist}->pretty_id;
398 4 ▶ while ( my $pattern = <$send_skipfile> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $pattern = readline $send_skipfile)) 11 1 12
399 11 chomp($pattern);
400 # ignore comments
401 11 ▶ next if substr($pattern,0,1) eq '#';
Branch: 1 branch
BranchTrueFalseTotal
if substr($pattern, 0, 1) eq "#" 4 7 11
402 # if it doesn't match, continue with next pattern
403 7 ▶ next if $dist_id !~ /$pattern/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $dist_id =~ /$pattern/i 4 3 7
404 # if it matches, warn and return
405 3 $CPAN::Frontend->myprint( << "END_SKIP_DIST" );
406 CPAN::Reporter: '$dist_id' matched against the send_skipfile.
407  
408 Test report will not be sent.
409  
410 END_SKIP_DIST
411  
412 3 return;
413 }
414 }
415  
416 # Setup the test report
417 120 my $tr = Test::Reporter->new;
418 120 $tr->grade( $result->{grade} );
419 120 $tr->distribution( $result->{dist_name} );
420 # Older Test::Reporter doesn't support distfile, but we need it for
421 # Metabase transport
422 $tr->distfile( $result->{dist}->pretty_id )
423 120 ▶ if $Test::Reporter::VERSION >= 1.54;
Branch: 1 branch
BranchTrueFalseTotal
if $Test::Reporter::VERSION >= "1.54" 120 0 120
424  
425 # Skip if duplicate and not sending duplicates
426 120 ▶ if ( $is_duplicate ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_duplicate) 74 46 120
427 74 ▶ if ( _prompt( $config, "send_duplicates", $tr->grade) =~ /^n/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_prompt($config, "send_duplicates", $tr->grade) =~ /^n/) 2 72 74
428 2 $CPAN::Frontend->myprint(<< "DUPLICATE_REPORT");
429  
430 CPAN::Reporter: this appears to be a duplicate report for the $phase phase:
431 2 @{[$tr->subject]}
432  
433 Test report will not be sent.
434  
435 DUPLICATE_REPORT
436  
437 2 return;
438 }
439 }
440  
441 # Set debug and transport options, if supported
442 118 ▶ $tr->debug( $config->{debug} ) if defined $config->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if defined $config->{"debug"} 0 118 118
443 118 my $transport = $config->{transport};
444 118 ▶ unless ( defined $transport && length $transport ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $transport and length $transport) 0 118 118
Condition33%1/3
defined $transport and length $transport
!ll&&!rl&&r
00118
MC/DC0%0/2
defined $transport and length $transport
defined $transport length $transport
Truth table33%1/3
A and B
A= defined $transportB= length $transport
ABresult
0X0
100
111
445 0 $CPAN::Frontend->mywarn( << "TRANSPORT_REQUIRED");
446  
447 CPAN::Reporter: required 'transport' option missing so the test report
448 will not be sent. See documentation for configuration details.
449  
450 TRANSPORT_REQUIRED
451 0 return;
452 }
453 118 my @transport_args = split " ", $transport;
454  
455 # special hack for Metabase arguments
456 118 ▶ if ($transport_args[0] eq 'Metabase') {
Branch: 1 branch
BranchTrueFalseTotal
if ($transport_args[0] eq "Metabase") 116 2 118
457 116 @transport_args = _validate_metabase_args(@transport_args);
458 116 ▶ unless (@transport_args) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@transport_args) 0 116 116
459 0 $CPAN::Frontend->mywarn( "Test report will not be sent.\n\n" );
460 0 return;
461 }
462 }
463  
464 118 eval { $tr->transport( @transport_args ) };
465 118 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 117 118
466 1 $CPAN::Frontend->mywarn(
467 "CPAN::Reporter: problem with Test::Reporter transport: \n" .
468 "$@\n" .
469 "Test report will not be sent\n"
470 );
471 1 return;
472 }
473  
474 # prepare mail transport
475 117 $tr->from( $config->{email_from} );
476  
477 # Populate the test report
478 117 $tr->comments( _report_text( $result ) );
479 117 $tr->via( 'CPAN::Reporter ' . $CPAN::Reporter::VERSION );
480  
481 # prompt for editing report
482 117 ▶ if ( _prompt( $config, "edit_report", $tr->grade ) =~ /^y/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_prompt($config, "edit_report", $tr->grade) =~ /^y/) 0 117 117
483 0 my $editor = $config->{editor};
484 0 ▶ local $ENV{VISUAL} = $editor if $editor; ## no critic
Branch: 1 branch
BranchTrueFalseTotal
if $editor 0 0 0
485 0 $tr->edit_comments;
486 }
487  
488 # send_*_report can override send_report
489 117 ▶ my $send_config = defined $config->{"send_$phase\_report"}
Branch: 1 branch
BranchTrueFalseTotal
defined $$config{"send_${phase}_report"} ? : 9 108 117
490 ? "send_$phase\_report"
491 : "send_report" ;
492 117 ▶ if ( _prompt( $config, $send_config, $tr->grade ) =~ /^y/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_prompt($config, $send_config, $tr->grade) =~ /^y/) { } 114 3 117
493 114 $CPAN::Frontend->myprint( "CPAN::Reporter: sending test report with '" . $tr->grade .
494 "' via " . $transport_args[0] . "\n");
495 114 ▶ if ( $tr->send() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tr->send) { } 114 0 114
496 114 ▶ CPAN::Reporter::History::_record_history( $result )
Branch: 1 branch
BranchTrueFalseTotal
unless $is_duplicate 43 71 114
497 if not $is_duplicate;
498 }
499 else {
500 0 $CPAN::Frontend->mywarn( "CPAN::Reporter: " . $tr->errstr . "\n");
501  
502 0 ▶ if ( $config->{retry_submission} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"retry_submission"}) 0 0 0
503 0 sleep(3);
504  
505 0 $CPAN::Frontend->mywarn( "CPAN::Reporter: second attempt\n");
506 0 $tr->errstr('');
507  
508 0 ▶ if ( $tr->send() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tr->send) { } 0 0 0
509 0 ▶ CPAN::Reporter::History::_record_history( $result )
Branch: 1 branch
BranchTrueFalseTotal
unless $is_duplicate 0 0 0
510 if not $is_duplicate;
511 }
512 else {
513 0 $CPAN::Frontend->mywarn( "CPAN::Reporter: " . $tr->errstr . "\n");
514 }
515 }
516  
517 }
518 }
519 else {
520 3 $CPAN::Frontend->myprint("CPAN::Reporter: test report will not be sent\n");
521 }
522  
523 117 return;
524 }
525  
526 sub _report_timeout {
527 129 ▶ my $result = shift;
Subroutine _report_timeout: called CC=7 SCAR=29.4
528 129 ▶ if ($result->{exit_value} == 9) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{"exit_value"} == 9) 2 127 129
529 2 my $config_obj = CPAN::Reporter::Config::_open_config_file();
530 2 my $config;
531 2 ▶ $config = CPAN::Reporter::Config::_get_config_options( $config_obj )
Branch: 1 branch
BranchTrueFalseTotal
if $config_obj 2 0 2
532 if $config_obj;
533  
534 2 ▶ if ($config->{'_store_problems_in_dir'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"_store_problems_in_dir"}) 0 2 2
535 0 my $distribution = $result->{dist}->base_id;
536 0 my $file = "e9.$distribution.${\(time)}.$$.log";
537 0 ▶ if (open my $to_log_fh, '>>', $config->{'_store_problems_in_dir'}.'/'.$file) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $to_log_fh, '>>', $config->{'_store_problems_in_dir'} . '/' . $file) { } 0 0 0
538 0 print $to_log_fh $distribution,"\n";
539 0 print $to_log_fh "stage: ",$result->{phase},"\n";
540 0 print $to_log_fh $Config{archname},"\n";
541 0 print $to_log_fh _report_text( $result );
542 } else {
543 $CPAN::Frontend->mywarn( "CPAN::Reporter: writing ".
544 0 $config->{'_store_problems_in_dir'}.'/'.$file. " failed\n");
545 }
546 }
547 2 ▶ if ($config->{'_problem_log'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"_problem_log"}) 0 2 2
548 0 my $distribution = $result->{dist}->base_id;
549 0 ▶ if (open my $to_log_fh, '>>', $config->{'_problem_log'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $to_log_fh, '>>', $config->{'_problem_log'}) { } 0 0 0
550 0 print $to_log_fh "$result->{phase} $distribution $Config{archname}\n";
551 } else {
552 $CPAN::Frontend->mywarn( "CPAN::Reporter: writing ".
553 0 $config->{'_store_problems_in_dir'}. " failed\n");
554 }
555 }
556 }
557 }
558  
559 #--------------------------------------------------------------------------#
560 # _downgrade_known_causes
561 # Downgrade failure/unknown grade if we can determine a cause
562 # If platform not supported => 'na'
563 # If perl version is too low => 'na'
564 # If stated prereqs missing => 'discard'
565 #--------------------------------------------------------------------------#
566  
567 sub _downgrade_known_causes {
568 169 ▶ my ($result) = @_;
Subroutine _downgrade_known_causes: called CC=35 SCAR=35.6
569 169 my ($grade, $output) = ( $result->{grade}, $result->{output} );
570 169 ▶ my $msg = $result->{grade_msg} || q{};
Condition50%1/2
$result->{'grade_msg'} || ''
l!l
1690
MC/DC0%0/1
$result->{'grade_msg'} || ''
$result->{'grade_msg'}
Truth table50%1/2
A
A= $result->{'grade_msg'}
Aresult
11
00
571  
572 # shortcut unless fail/unknown; but PL might look like pass but actually
573 # have "OS Unsupported" messages if someone printed message and then
574 # did "exit 0"
575 169 ▶ return if $grade eq 'na';
Branch: 1 branch
BranchTrueFalseTotal
if $grade eq "na" 6 163 169
576 163 ▶ return if $grade eq 'pass' && $result->{phase} ne 'PL';
Branch: 1 branch
BranchTrueFalseTotal
if $grade eq "pass" and $result->{"phase"} ne "PL" 34 129 163
Condition100%3/3
$grade eq "pass" and $result->{"phase"} ne "PL"
!ll&&!rl&&r
1191034
MC/DC100%2/2
$grade eq "pass" and $result->{"phase"} ne "PL"
$grade eq "pass" $result->{"phase"} ne "PL"
Truth table100%3/3
A and B
A= $grade eq "pass"B= $result->{"phase"} ne "PL"
ABresult
0X0
100
111
577  
578 # get prereqs
579 129 _expand_result( $result );
580  
581 129 _report_timeout( $result );
582  
583 # if process was halted with a signal, just set for discard and return
584 129 ▶ if ( $result->{exit_value} & 127 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{"exit_value"} & 127) 2 127 129
585 2 $result->{grade} = 'discard';
586 2 $result->{grade_msg} = 'Command interrupted';
587 2 return;
588 }
589  
590 # look for perl version error messages from various programs
591 # "Error evaling..." type errors happen on Perl < 5.006 when modules
592 # define their version with "our $VERSION = ..."
593 127 my ($harness_error, $version_error, $unsupported) ;
594 127 for my $line ( @$output ) {
595 3215 ▶ if ( $result->{phase} eq 'test'
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{"phase"} eq "test" and $line =~ m[open3: IO::Pipe: Can't spawn.*?TAP/Parser/Iterator/Process.pm]) 2 3213 3215
Condition100%3/3
$result->{"phase"} eq "test" and $line =~ m[open3: IO::Pipe: Can't spawn.*?TAP/Parser/Iterator/Process.pm]
!ll&&!rl&&r
13030832
MC/DC100%2/2
$result->{"phase"} eq "test" and $line =~ m[open3: IO::Pipe: Can't spawn.*?TAP/Parser/Iterator/Process.pm]
$result->{"phase"} eq "test" $line =~ m[open3: IO::Pipe: Can't spawn.*?TAP/Parser/Iterator/Process.pm]
Truth table100%3/3
A and B
A= $result->{"phase"} eq "test"B= $line =~ m[open3: IO::Pipe: Can't spawn.*?TAP/Parser/Iterator/Process.pm]
ABresult
0X0
100
111
596 && $line =~ m{open3: IO::Pipe: Can't spawn.*?TAP/Parser/Iterator/Process.pm}
597 ) {
598 2 $harness_error++;
599 2 last;
600 }
601 3213 ▶ if( $line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ims ||
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ism or $line =~ /Perl version .*? or higher required\. We run/ism or $line =~ /ERROR: perl: Version .*? is installed, but we need version/ism or $line =~ /ERROR: perl \(.*?\) is installed, but we need version/ism or $line =~ /Error evaling version line 'BEGIN/ism or $line =~ /Could not eval '/ism) 0 3205 3205
Condition73%11/15
$line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ism or $line =~ /Perl version .*? or higher required\. We run/ism or $line =~ /ERROR: perl: Version .*? is installed, but we need version/ism or $line =~ /ERROR: perl \(.*?\) is installed, but we need version/ism or $line =~ /Error evaling version line 'BEGIN/ism or $line =~ /Could not eval '/ism
l!l&&r!l&&!r
803205
$line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ism or $line =~ /Perl version .*? or higher required\. We run/ism or $line =~ /ERROR: perl: Version .*? is installed, but we need version/ism or $line =~ /ERROR: perl \(.*?\) is installed, but we need version/ism or $line =~ /Error evaling version line 'BEGIN/ism
l!l&&r!l&&!r
803205
$line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ism or $line =~ /Perl version .*? or higher required\. We run/ism or $line =~ /ERROR: perl: Version .*? is installed, but we need version/ism or $line =~ /ERROR: perl \(.*?\) is installed, but we need version/ism
l!l&&r!l&&!r
803205
$line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ism or $line =~ /Perl version .*? or higher required\. We run/ism or $line =~ /ERROR: perl: Version .*? is installed, but we need version/ism
l!l&&r!l&&!r
623205
$line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ism or $line =~ /Perl version .*? or higher required\. We run/ism
l!l&&r!l&&!r
603207
MC/DC33%2/6
$line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ism or $line =~ /Perl version .*? or higher required\. We run/ism or $line =~ /ERROR: perl: Version .*? is installed, but we need version/ism or $line =~ /ERROR: perl \(.*?\) is installed, but we need version/ism or $line =~ /Error evaling version line 'BEGIN/ism or $line =~ /Could not eval '/ism
$line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ism $line =~ /Perl version .*? or higher required\. We run/ism $line =~ /ERROR: perl: Version .*? is installed, but we need version/ism $line =~ /ERROR: perl \(.*?\) is installed, but we need version/ism $line =~ /Error evaling version line 'BEGIN/ism $line =~ /Could not eval '/ism
Truth table42%3/7
A or B or C or D or E or F
A= $line =~ /(?<!skipped: )Perl .*? required.*?--this is only/ismB= $line =~ /Perl version .*? or higher required\. We run/ismC= $line =~ /ERROR: perl: Version .*? is installed, but we need version/ismD= $line =~ /ERROR: perl \(.*?\) is installed, but we need version/ismE= $line =~ /Error evaling version line 'BEGIN/ismF= $line =~ /Could not eval '/ism
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
602 #?<! - quick hack for https://github.com/cpan-testers/CPAN-Reporter/issues/23
603 $line =~ /Perl version .*? or higher required\. We run/ims || #EU::MM
604 $line =~ /ERROR: perl: Version .*? is installed, but we need version/ims ||
605 $line =~ /ERROR: perl \(.*?\) is installed, but we need version/ims ||
606 $line =~ /Error evaling version line 'BEGIN/ims ||
607 $line =~ /Could not eval '/ims
608 ) {
609 8 $version_error++;
610 8 last;
611 }
612 3205 ▶ if ( $line =~ /No support for OS|OS unsupported/ims ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /No support for OS|OS unsupported/ism) 6 3199 3205
613 6 $unsupported++;
614 6 last;
615 }
616 }
617  
618 # if the test harness had an error, discard the report
619 127 ▶ if ( $harness_error ) {
Branch: 9 branches
BranchTrueFalseTotal
if ($harness_error) { } 2 125 127
elsif ($version_error or $result->{'prereq_pm'} =~ /^\s+!\s+perl\s/ism) { } 12 113 125
elsif ($unsupported) { } 6 107 113
elsif ($result->{'is_make'} and $result->{'phase'} eq 'test' and not _has_test_target()) { } 1 106 107
elsif ($grade ne 'pass' and $result->{'prereq_pm'} =~ m[n/a]ism) { } 14 92 106
elsif ($grade ne 'pass' and $result->{'prereq_pm'} =~ /^\s+!/ism) { } 8 84 92
elsif ($result->{'phase'} eq 'PL' and $grade eq 'pass' and not -f 'Makefile' and not -f 'Build') { } 2 82 84
elsif ($result->{'command'} =~ /Build.*?-j/) { } 2 80 82
elsif ($result->{'is_make'} and $result->{'phase'} eq 'make' and grep {/Makefile out-of-date with respect to Makefile.PL/;} @$output) { } 1 152 153
620 2 $grade = 'discard';
621 2 $msg = 'Test harness failure';
622 }
623 # check for explicit version error or just a perl version prerequisite
624 ▶ elsif ( $version_error || $result->{prereq_pm} =~ m{^\s+!\s+perl\s}ims ) {
Condition100%3/3
$version_error or $result->{"prereq_pm"} =~ /^\s+!\s+perl\s/ism
l!l&&r!l&&!r
84113
MC/DC100%2/2
$version_error or $result->{"prereq_pm"} =~ /^\s+!\s+perl\s/ism
$version_error $result->{"prereq_pm"} =~ /^\s+!\s+perl\s/ism
Truth table100%3/3
A or B
A= $version_errorB= $result->{"prereq_pm"} =~ /^\s+!\s+perl\s/ism
ABresult
1X1
011
000
625 12 $grade = 'na';
626 12 $msg = 'Perl version too low';
627 }
628 # check again for unsupported OS in case we took 'fail' from exit value
629 elsif ( $unsupported ) {
630 6 $grade = 'na';
631 6 $msg = 'This platform is not supported';
632 }
633 # check for Makefile without 'test' target; there are lots
634 # of variations on the error message, e.g. "target test", "target 'test'",
635 # "'test'", "`test'" and so on.
636 ▶ elsif (
Condition100%6/6
$result->{"is_make"} and $result->{"phase"} eq "test" and not _has_test_target()
!ll&&!rl&&r
60461
$result->{"is_make"} and $result->{"phase"} eq "test"
!ll&&!rl&&r
372347
MC/DC100%3/3
$result->{"is_make"} and $result->{"phase"} eq "test" and not _has_test_target()
$result->{"is_make"} $result->{"phase"} eq "test" not _has_test_target()
Truth table100%4/4
A and B and not(C)
A= $result->{"is_make"}B= $result->{"phase"} eq "test"C= not _has_test_target()
ABCresult
0XX0
10X0
1100
1111
637 $result->{is_make} && $result->{phase} eq 'test' && ! _has_test_target()
638 ) {
639 1 $grade = 'unknown';
640 1 $msg = 'No make test target';
641 }
642 # check the prereq report for missing or failure flag '!'
643 ▶ elsif ( $grade ne 'pass' && $result->{prereq_pm} =~ m{n/a}ims ) {
Condition100%3/3
$grade ne "pass" and $result->{"prereq_pm"} =~ m[n/a]ism
!ll&&!rl&&r
88414
MC/DC100%2/2
$grade ne "pass" and $result->{"prereq_pm"} =~ m[n/a]ism
$grade ne "pass" $result->{"prereq_pm"} =~ m[n/a]ism
Truth table100%3/3
A and B
A= $grade ne "pass"B= $result->{"prereq_pm"} =~ m[n/a]ism
ABresult
0X0
100
111
644 14 $grade = 'discard';
645 14 $msg = "Prerequisite missing:\n$result->{prereq_pm}";
646 }
647 ▶ elsif ( $grade ne 'pass' && $result->{prereq_pm} =~ m{^\s+!}ims ) {
Condition100%3/3
$grade ne "pass" and $result->{"prereq_pm"} =~ /^\s+!/ism
!ll&&!rl&&r
8768
MC/DC100%2/2
$grade ne "pass" and $result->{"prereq_pm"} =~ /^\s+!/ism
$grade ne "pass" $result->{"prereq_pm"} =~ /^\s+!/ism
Truth table100%3/3
A and B
A= $grade ne "pass"B= $result->{"prereq_pm"} =~ /^\s+!/ism
ABresult
0X0
100
111
648 8 $grade = 'discard';
649 8 $msg = "Prerequisite version too low:\n$result->{prereq_pm}";
650 }
651 # in PL stage -- if pass but no Makefile or Build, then this should
652 # be recorded as a discard
653 ▶ elsif ( $result->{phase} eq 'PL' && $grade eq 'pass'
Condition100%9/9
$result->{"phase"} eq "PL" and $grade eq "pass" and not -f "Makefile" and not -f "Build"
!ll&&!rl&&r
7932
$result->{"phase"} eq "PL" and $grade eq "pass" and not -f "Makefile"
!ll&&!rl&&r
7635
$result->{"phase"} eq "PL" and $grade eq "pass"
!ll&&!rl&&r
6798
MC/DC100%4/4
$result->{"phase"} eq "PL" and $grade eq "pass" and not -f "Makefile" and not -f "Build"
$result->{"phase"} eq "PL" $grade eq "pass" not -f "Makefile" not -f "Build"
Truth table100%5/5
A and B and not(C) and not(D)
A= $result->{"phase"} eq "PL"B= $grade eq "pass"C= not -f "Makefile"D= not -f "Build"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
654 && ! -f 'Makefile' && ! -f 'Build'
655 ) {
656 2 $grade = 'discard';
657 2 $msg = 'No Makefile or Build file found';
658 }
659 elsif ( $result->{command} =~ /Build.*?-j/ ) {
660 2 $grade = 'discard';
661 2 $msg = '-j is not a valid option for Module::Build (upgrade your CPAN.pm)';
662 }
663 ▶ elsif (
Condition100%6/6
$result->{"is_make"} and $result->{"phase"} eq "make" and grep {/Makefile out-of-date with respect to Makefile.PL/;} @$output
!ll&&!rl&&r
7361
$result->{"is_make"} and $result->{"phase"} eq "make"
!ll&&!rl&&r
24497
MC/DC100%3/3
$result->{"is_make"} and $result->{"phase"} eq "make" and grep {/Makefile out-of-date with respect to Makefile.PL/;} @$output
$result->{"is_make"} $result->{"phase"} eq "make" grep {/Makefile out-of-date with respect to Makefile.PL/;} @$output
Truth table100%4/4
A and B and C
A= $result->{"is_make"}B= $result->{"phase"} eq "make"C= grep {/Makefile out-of-date with respect to Makefile.PL/;} @$output
ABCresult
0XX0
10X0
1100
1111
664 $result->{is_make} && $result->{phase} eq 'make' &&
665 39 grep { /Makefile out-of-date with respect to Makefile.PL/ } @$output
666 ) {
667 1 $grade = 'discard';
668 1 $msg = 'Makefile out-of-date';
669 }
670  
671 # store results
672 127 $result->{grade} = $grade;
673 127 $result->{grade_msg} = $msg;
674  
675 127 return;
676 }
677  
678 #--------------------------------------------------------------------------#
679 # _expand_result - add expensive information like prerequisites and
680 # toolchain that should only be generated if a report will actually
681 # be sent
682 #--------------------------------------------------------------------------#
683  
684 sub _expand_result {
685 354 ▶ my $result = shift;
Subroutine _expand_result: called CC=3 SCAR=11.0
686 354 ▶ return if $result->{expanded}++; # only do this once
Branch: 1 branch
BranchTrueFalseTotal
if $result->{"expanded"}++ 187 167 354
687 167 $result->{prereq_pm} = _prereq_report( $result->{dist} );
688 {
689 # mirror PERL5OPT as in record_command
690 167 ▶ local $ENV{PERL5OPT} = _get_perl5opt() if _is_PL($result->{command});
Branch: 1 branch
BranchTrueFalseTotal
if _is_PL($result->{"command"}) 37 130 167
691 167 $result->{env_vars} = _env_report();
692 }
693 167 $result->{special_vars} = _special_vars_report();
694 167 $result->{toolchain_versions} = _toolchain_report( $result );
695 167 $result->{perl_version} = CPAN::Reporter::History::_format_perl_version();
696 167 return;
697 }
698  
699 #--------------------------------------------------------------------------#
700 # _env_report
701 #--------------------------------------------------------------------------#
702  
703 # Entries bracketed with "/" are taken to be a regex; otherwise literal
704 33 my @env_vars= qw(
705 /HARNESS/
706 /LC_/
707 /PERL/
708 /_TEST/
709 CCFLAGS
710 COMSPEC
711 INCLUDE
712 INSTALL_BASE
713 LANG
714 LANGUAGE
715 LD_LIBRARY_PATH
716 LDFLAGS
717 LIB
718 NON_INTERACTIVE
719 NUMBER_OF_PROCESSORS
720 PATH
721 PREFIX
722 PROCESSOR_IDENTIFIER
723 SHELL
724 TERM
725 TEMP
726 TMPDIR
727 );
728  
729 sub _env_report {
730 176 ▶ my @vars_found;
Subroutine _env_report: called CC=6 SCAR=17.9
731 176 for my $var ( @env_vars ) {
732 3872 ▶ if ( $var =~ m{^/(.+)/$} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($var =~ m[^/(.+)/$]) { } 704 3168 3872
733 704 push @vars_found, grep { /$1/ } keys %ENV;
734 }
735 else {
736 3168 ▶ push @vars_found, $var if exists $ENV{$var};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ENV{$var} 352 2816 3168
737 }
738 }
739  
740 176 my $report = "";
741 176 for my $var ( sort @vars_found ) {
742 2635 my $value = $ENV{$var};
743 2635 ▶ $value = '[undef]' if ! defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 2635 2635
744 2635 $report .= " $var = $value\n";
745 }
746 176 return $report;
747 }
748  
749 #--------------------------------------------------------------------------#
750 # _file_copy_quiet
751 #
752 # manual file copy -- quietly return undef on failure
753 #--------------------------------------------------------------------------#
754  
755 sub _file_copy_quiet {
756 33 ▶ my ($source, $target) = @_;
Subroutine _file_copy_quiet: called CC=4 SCAR=14.0
757 # ensure we have a target directory
758 33 ▶ mkpath( dirname($target) ) or return;
Branch: 1 branch
BranchTrueFalseTotal
mkpath(dirname($target)) or return 0 33 33
759 # read source
760 33 local *FH;
761 33 ▶ open FH, "<$source" or return; ## no critic
Branch: 1 branch
BranchTrueFalseTotal
open FH, "<$source" or return 0 33 33
762 33 my $pm_guts = do { local $/; <FH> };
763 33 close FH;
764 # write target
765 33 ▶ open FH, ">$target" or return; ## no critic
Branch: 1 branch
BranchTrueFalseTotal
open FH, ">$target" or return 0 33 33
766 33 print FH $pm_guts;
767 33 close FH;
768 33 return 1;
769 }
770  
771 #--------------------------------------------------------------------------#
772 # _get_perl5opt
773 #--------------------------------------------------------------------------#
774  
775 sub _get_perl5opt {
776 76 ▶ my $perl5opt = $ENV{PERL5OPT} || q{};
Subroutine _get_perl5opt: called CC=5 SCAR=16.2
Condition100%2/2
$ENV{'PERL5OPT'} || ''
l!l
742
MC/DC100%1/1
$ENV{'PERL5OPT'} || ''
$ENV{'PERL5OPT'}
Truth table100%2/2
A
A= $ENV{'PERL5OPT'}
Aresult
11
00
777 76 ▶ if ( $Autoflush_Lib ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Autoflush_Lib) 76 0 76
778 76 ▶ $perl5opt .= q{ } if length $perl5opt;
Branch: 1 branch
BranchTrueFalseTotal
if length $perl5opt 74 2 76
779 76 ▶ $perl5opt .= "-I$Autoflush_Lib " if $] >= 5.008;
Branch: 1 branch
BranchTrueFalseTotal
if $] >= "5.008" 76 0 76
780 76 $perl5opt .= "-MDevel::Autoflush";
781 }
782 76 return $perl5opt;
783 }
784  
785 #--------------------------------------------------------------------------#
786 # _has_recursive_make
787 #
788 # Ignore Makefile.PL in t directories
789 #--------------------------------------------------------------------------#
790  
791 sub _has_recursive_make {
792 67 ▶ my $PL_count = 0;
Subroutine _has_recursive_make: called CC=1 SCAR=0.0
793 File::Find::find(
794 sub {
795 2318 ▶ if ( $_ eq 't' ) {
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 2 branches
BranchTrueFalseTotal
if ($_ eq 't') { } 63 2255 2318
elsif ($_ eq 'Makefile.PL') { } 73 2182 2255
796 63 $File::Find::prune = 1;
797 }
798 elsif ( $_ eq 'Makefile.PL' ) {
799 73 $PL_count++;
800 }
801 },
802 67 File::Spec->curdir()
803 );
804 67 return $PL_count > 1;
805 }
806  
807 #--------------------------------------------------------------------------#
808 # _has_test_target
809 #--------------------------------------------------------------------------#
810  
811 sub _has_test_target {
812 47 ▶ my $fh = IO::File->new("Makefile") or return;
Subroutine _has_test_target: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
my $fh = "IO::File"->new("Makefile") or return 0 47 47
813 47 return scalar grep { /^test[ ]*:/ } <$fh>;
814 }
815  
816 #--------------------------------------------------------------------------#
817 # _init_result -- create and return a hash of values for use in
818 # report evaluation and dispatch
819 #
820 # takes same argument format as grade_*()
821 #--------------------------------------------------------------------------#
822  
823 sub _init_result {
824 173 ▶ my ($phase, $dist, $system_command, $output, $exit_value) = @_;
Subroutine _init_result: called CC=13 SCAR=34.5
825  
826 173 ▶ unless ( defined $output && defined $exit_value ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $output and defined $exit_value) 0 173 173
Condition33%1/3
defined $output and defined $exit_value
!ll&&!rl&&r
00173
MC/DC0%0/2
defined $output and defined $exit_value
defined $output defined $exit_value
Truth table33%1/3
A and B
A= defined $outputB= defined $exit_value
ABresult
0X0
100
111
827 0 my $missing;
828 0 ▶ if ( ! defined $output && ! defined $exit_value ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $output || defined $exit_value) { } 0 0 0
elsif (defined $output and not defined $exit_value) { } 0 0 0
Condition0%0/3
defined $output || defined $exit_value
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $output || defined $exit_value
defined $output defined $exit_value
Truth table0%0/3
A || B
A= defined $outputB= defined $exit_value
ABresult
1X1
011
000
829 0 $missing = "exit value and output"
830 }
831 ▶ elsif ( defined $output && !defined $exit_value ) {
Condition0%0/3
defined $output and not defined $exit_value
!ll&&!rl&&r
000
MC/DC0%0/2
defined $output and not defined $exit_value
defined $output not defined $exit_value
Truth table0%0/3
A and not(B)
A= defined $outputB= not defined $exit_value
ABresult
0X0
100
111
832 0 $missing = "exit value"
833 }
834 else {
835 0 $missing = "output";
836 }
837 0 $CPAN::Frontend->mywarn(
838 "CPAN::Reporter: had errors capturing $missing. Tests abandoned"
839 );
840 0 return;
841 }
842  
843 173 ▶ if ( $dist->pretty_id =~ m{\w+/Perl6/} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist->pretty_id =~ m[\w+/Perl6/]) 3 170 173
844 3 $CPAN::Frontend->mywarn(
845 "CPAN::Reporter: Won't report a Perl6 distribution."
846 );
847 3 return;
848 }
849  
850 170 ▶ my $result = {
Branch: 1 branch
BranchTrueFalseTotal
ref $output eq 'ARRAY' ? : 166 4 170
851 phase => $phase,
852 dist => $dist,
853 command => $system_command,
854 is_make => _is_make( $system_command ),
855 output => ref $output eq 'ARRAY' ? $output : [ split /\n/, $output ],
856 exit_value => $exit_value,
857 # Note: pretty_id is like "DAGOLDEN/CPAN-Reporter-0.40.tar.gz"
858 dist_basename => basename($dist->pretty_id),
859 dist_name => $dist->base_id,
860 };
861  
862 # Used in messages to user
863 170 ▶ $result->{PL_file} = $result->{is_make} ? "Makefile.PL" : "Build.PL";
Branch: 1 branch
BranchTrueFalseTotal
$result->{'is_make'} ? : 112 58 170
864 170 ▶ $result->{make_cmd} = $result->{is_make} ? $Config{make} : "Build";
Branch: 1 branch
BranchTrueFalseTotal
$result->{'is_make'} ? : 112 58 170
865  
866 # CPAN might fail to find an author object for some strange dists
867 170 my $author = $dist->author;
868 170 ▶ $result->{author} = defined $author ? $author->fullname : "Author";
Branch: 1 branch
BranchTrueFalseTotal
defined $author ? : 170 0 170
869 170 ▶ $result->{author_id} = defined $author ? $author->id : "" ;
Branch: 1 branch
BranchTrueFalseTotal
defined $author ? : 170 0 170
870  
871 170 return $result;
872 }
873  
874 #--------------------------------------------------------------------------#
875 # _is_make
876 #--------------------------------------------------------------------------#
877  
878 sub _is_make {
879 190 ▶ my $command = shift;
Subroutine _is_make: called CC=2 SCAR=6.9
880 190 ▶ return $command =~ m{\b(?:\S*make|Makefile.PL)\b}ims ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$command =~ /\b(?:\S*make|Makefile.PL)\b/ism ? : 126 64 190
881 }
882  
883 #--------------------------------------------------------------------------#
884 # _is_PL
885 #--------------------------------------------------------------------------#
886  
887 sub _is_PL {
888 353 ▶ my $command = shift;
Subroutine _is_PL: called CC=2 SCAR=6.9
889 353 ▶ return $command =~ m{\b(?:Makefile|Build)\.PL\b}ims ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$command =~ /\b(?:Makefile|Build)\.PL\b/ism ? : 76 277 353
890 }
891  
892 #--------------------------------------------------------------------------#
893 # _max_length
894 #--------------------------------------------------------------------------#
895  
896 sub _max_length {
897 352 ▶ my ($first, @rest) = @_;
Subroutine _max_length: called CC=3 SCAR=11.0
898 352 my $max = length $first;
899 352 for my $term ( @rest ) {
900 6688 ▶ $max = length $term if length $term > $max;
Branch: 1 branch
BranchTrueFalseTotal
if length $term > $max 566 6122 6688
901 }
902 352 return $max;
903 }
904  
905  
906 #--------------------------------------------------------------------------#
907 # _parse_tap_harness
908 #
909 # As of Test::Harness 2.99_02, the final line is provided by TAP::Harness
910 # as "Result: STATUS" where STATUS is "PASS", "FAIL" or "NOTESTS"
911 #--------------------------------------------------------------------------#
912  
913  
914 sub _parse_tap_harness {
915 254 ▶ my ($line) = @_;
Subroutine _parse_tap_harness: called CC=6 SCAR=18.2
916 254 ▶ if ( $line =~ m{^Result:\s+([A-Z]+)} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /^Result:\s+([A-Z]+)/) { } 76 178 254
elsif ($line =~ /Bailout called\.\s+Further testing stopped/ms) { } 0 178 178
917 76 ▶ if ( $1 eq 'PASS' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($1 eq 'PASS') { } 20 56 76
elsif ($1 eq 'FAIL') { } 53 3 56
elsif ($1 eq 'NOTESTS') { } 3 0 3
918 20 return ('pass', 'All tests successful');
919 }
920 elsif ( $1 eq 'FAIL' ) {
921 53 return ('fail', 'One or more tests failed');
922 }
923 elsif ( $1 eq 'NOTESTS' ) {
924 3 return ('unknown', 'No tests were run');
925 }
926 }
927 elsif ( $line =~ m{Bailout called\.\s+Further testing stopped}ms ) {
928 0 return ( 'fail', 'Bailed out of tests');
929 }
930 178 return;
931 }
932  
933 #--------------------------------------------------------------------------#
934 # _parse_test_harness
935 #
936 # Output strings taken from Test::Harness::
937 # _show_results() -- for versions < 2.57_03
938 # get_results() -- for versions >= 2.57_03
939 #--------------------------------------------------------------------------#
940  
941 sub _parse_test_harness {
942 0 ▶ my ($line) = @_;
Subroutine _parse_test_harness: not called CC=6 SCAR=37.4
943 0 ▶ if ( $line =~ m{^All tests successful}ms ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($line =~ /^All tests successful/ms) { } 0 0 0
elsif ($line =~ /^FAILED--no tests were run/ms) { } 0 0 0
elsif ($line =~ /^FAILED--.*--no output/ms) { } 0 0 0
elsif ($line =~ /FAILED--Further testing stopped/ms) { } 0 0 0
elsif ($line =~ /^Failed /ms) { } 0 0 0
944 0 return ( 'pass', 'All tests successful' );
945 }
946 elsif ( $line =~ m{^FAILED--no tests were run}ms ) {
947 0 return ( 'unknown', 'No tests were run' );
948 }
949 elsif ( $line =~ m{^FAILED--.*--no output}ms ) {
950 0 return ( 'unknown', 'No tests were run');
951 }
952 elsif ( $line =~ m{FAILED--Further testing stopped}ms ) {
953 0 return ( 'fail', 'Bailed out of tests');
954 }
955 elsif ( $line =~ m{^Failed }ms ) { # must be lowercase
956 0 return ( 'fail', 'One or more tests failed');
957 }
958 else {
959 0 return;
960 }
961 }
962  
963 #--------------------------------------------------------------------------#
964 # _prereq_report
965 #--------------------------------------------------------------------------#
966  
967 33 my @prereq_sections = qw(
968 requires build_requires configure_requires opt_requires opt_build_requires
969 );
970  
971 sub _prereq_report {
972 179 ▶ my $dist = shift;
Subroutine _prereq_report: called CC=27 SCAR=33.2
973 179 my (%need, %have, %prereq_met, $report);
974  
975 # Extract requires/build_requires from CPAN dist
976 179 my $prereq_pm = $dist->prereq_pm;
977  
978 179 ▶ if ( ref $prereq_pm eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $prereq_pm eq "HASH") 179 0 179
979 # CPAN 1.94 returns hash with requires/build_requires # so no need to support old style
980 179 foreach (values %$prereq_pm) {
981 711 ▶ if (defined && ref ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_ and ref $_ ne "HASH") 0 711 711
Condition66%2/3
defined $_ and ref $_ ne "HASH"
!ll&&!rl&&r
27090
MC/DC0%0/2
defined $_ and ref $_ ne "HASH"
defined $_ ref $_ ne "HASH"
Truth table66%2/3
A and B
A= defined $_B= ref $_ ne "HASH"
ABresult
0X0
100
111
982 0 require Data::Dumper;
983 0 warn "Data error detecting prerequisites. Please report it to CPAN::Reporter bug tracker:";
984 0 warn Data::Dumper::Dumper($prereq_pm);
985 0 die "Stopping";
986 }
987 }
988  
989 179 for my $sec ( @prereq_sections ) {
990 895 ▶ $need{$sec} = $prereq_pm->{$sec} if keys %{ $prereq_pm->{$sec} };
Branch: 1 branch
BranchTrueFalseTotal
if keys %{$$prereq_pm{$sec};} 135 760 895
991 }
992 }
993  
994 # Extract configure_requires from META.yml if it exists
995 179 ▶ if ( $dist->{build_dir} && -d $dist->{build_dir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist->{"build_dir"} and -d $dist->{"build_dir"}) 72 107 179
Condition66%2/3
$dist->{"build_dir"} and -d $dist->{"build_dir"}
!ll&&!rl&&r
107072
MC/DC50%1/2
$dist->{"build_dir"} and -d $dist->{"build_dir"}
$dist->{"build_dir"} -d $dist->{"build_dir"}
Truth table66%2/3
A and B
A= $dist->{"build_dir"}B= -d $dist->{"build_dir"}
ABresult
0X0
100
111
996 72 my $meta_yml = File::Spec->catfile($dist->{build_dir}, 'META.yml');
997 72 ▶ if ( -f $meta_yml ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $meta_yml) 4 68 72
998 4 my @yaml = eval { Parse::CPAN::Meta::LoadFile($meta_yml) };
999 4 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 2 2 4
1000 2 $CPAN::Frontend->mywarn(
1001 "CPAN::Reporter: error parsing META.yml\n"
1002 );
1003 }
1004 4 ▶ if ( ref $yaml[0] eq 'HASH' &&
Branch: 1 branch
BranchTrueFalseTotal
if (ref $yaml[0] eq "HASH" and ref $yaml[0]{"configure_requires"} eq "HASH") 2 2 4
Condition66%2/3
ref $yaml[0] eq "HASH" and ref $yaml[0]{"configure_requires"} eq "HASH"
!ll&&!rl&&r
202
MC/DC50%1/2
ref $yaml[0] eq "HASH" and ref $yaml[0]{"configure_requires"} eq "HASH"
ref $yaml[0] eq "HASH" ref $yaml[0]{"configure_requires"} eq "HASH"
Truth table66%2/3
A and B
A= ref $yaml[0] eq "HASH"B= ref $yaml[0]{"configure_requires"} eq "HASH"
ABresult
0X0
100
111
1005 ref $yaml[0]{configure_requires} eq 'HASH'
1006 ) {
1007 2 $need{configure_requires} = $yaml[0]{configure_requires};
1008 }
1009 }
1010 }
1011  
1012 # see what prereqs are satisfied in subprocess
1013 179 for my $section ( @prereq_sections ) {
1014 895 ▶ next unless ref $need{$section} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $need{$section} eq "HASH" 758 137 895
1015 137 my @prereq_list = %{ $need{$section} };
1016 137 ▶ next unless @prereq_list;
Branch: 1 branch
BranchTrueFalseTotal
unless @prereq_list 0 137 137
1017 137 my $prereq_results = _version_finder( @prereq_list );
1018 137 for my $mod ( keys %{$prereq_results} ) {
1019 185 $have{$section}{$mod} = $prereq_results->{$mod}{have};
1020 185 $prereq_met{$section}{$mod} = $prereq_results->{$mod}{met};
1021 }
1022 }
1023  
1024 # find formatting widths
1025 179 my ($name_width, $need_width, $have_width) = (6, 4, 4);
1026 179 for my $section ( @prereq_sections ) {
1027 895 for my $module ( keys %{ $need{$section} } ) {
1028 185 my $name_length = length $module;
1029 185 my $need_length = length $need{$section}{$module};
1030 185 my $have_length = length $have{$section}{$module};
1031 185 ▶ $name_width = $name_length if $name_length > $name_width;
Branch: 1 branch
BranchTrueFalseTotal
if $name_length > $name_width 134 51 185
1032 185 ▶ $need_width = $need_length if $need_length > $need_width;
Branch: 1 branch
BranchTrueFalseTotal
if $need_length > $need_width 14 171 185
1033 185 ▶ $have_width = $have_length if $have_length > $have_width;
Branch: 1 branch
BranchTrueFalseTotal
if $have_length > $have_width 9 176 185
1034 }
1035 }
1036  
1037 179 my $format_str =
1038 " \%1s \%-${name_width}s \%-${need_width}s \%-${have_width}s\n";
1039  
1040 # generate the report
1041 179 for my $section ( @prereq_sections ) {
1042 895 ▶ if ( keys %{ $need{$section} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$need{$section};}) 137 758 895
1043 137 $report .= "$section:\n\n";
1044 137 $report .= sprintf( $format_str, " ", qw/Module Need Have/ );
1045 137 $report .= sprintf( $format_str, " ",
1046 "-" x $name_width,
1047 "-" x $need_width,
1048 "-" x $have_width );
1049 137 for my $module (sort {lc $a cmp lc $b} keys %{ $need{$section} } ) {
1050 185 my $need = $need{$section}{$module};
1051 185 my $have = $have{$section}{$module};
1052 185 ▶ my $bad = $prereq_met{$section}{$module} ? " " : "!";
Branch: 1 branch
BranchTrueFalseTotal
$prereq_met{$section}{$module} ? : 129 56 185
1053 185 $report .=
1054 sprintf( $format_str, $bad, $module, $need, $have);
1055 }
1056 137 $report .= "\n";
1057 }
1058 }
1059  
1060 179 ▶ return $report || " No requirements found\n";
Condition100%2/2
$report || " No requirements found\n"
l!l
13643
MC/DC100%1/1
$report || " No requirements found\n"
$report
Truth table100%2/2
A
A= $report
Aresult
11
00
1061 }
1062  
1063 #--------------------------------------------------------------------------#
1064 # _print_grade_msg -
1065 #--------------------------------------------------------------------------#
1066  
1067 sub _print_grade_msg {
1068 138 ▶ my ($phase, $result) = @_;
Subroutine _print_grade_msg: called CC=3 SCAR=11.6
1069 138 my ($grade, $msg) = ($result->{grade}, $result->{grade_msg});
1070 138 $CPAN::Frontend->myprint( "CPAN::Reporter: $phase result is '$grade'");
1071 138 ▶ $CPAN::Frontend->myprint(", $msg") if defined $msg && length $msg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $msg and length $msg 138 0 138
Condition33%1/3
defined $msg and length $msg
!ll&&!rl&&r
00138
MC/DC0%0/2
defined $msg and length $msg
defined $msg length $msg
Truth table33%1/3
A and B
A= defined $msgB= length $msg
ABresult
0X0
100
111
1072 138 $CPAN::Frontend->myprint(".\n");
1073 138 return;
1074 }
1075  
1076 #--------------------------------------------------------------------------#
1077 # _prompt
1078 #
1079 # Note: always returns lowercase
1080 #--------------------------------------------------------------------------#
1081  
1082 sub _prompt {
1083 328 ▶ my ($config, $option, $grade, $extra) = @_;
Subroutine _prompt: called CC=6 SCAR=18.0
1084 328 ▶ $extra ||= q{};
Condition50%1/2
$extra ||= ""
l!l
0328
MC/DC0%0/1
$extra ||= ""
$extra
Truth table50%1/2
A
A= $extra
Aresult
11
00
1085  
1086 328 my %spec = CPAN::Reporter::Config::_config_spec();
1087  
1088 my $dispatch = CPAN::Reporter::Config::_validate_grade_action_pair(
1089 328 ▶ $option, join(q{ }, "default:no", $config->{$option} || '')
Condition50%1/2
$config->{$option} || ''
l!l
3280
MC/DC0%0/1
$config->{$option} || ''
$config->{$option}
Truth table50%1/2
A
A= $config->{$option}
Aresult
11
00
1090 );
1091 328 ▶ my $action = $dispatch->{$grade} || $dispatch->{default};
Condition66%2/3
$dispatch->{$grade} || $dispatch->{'default'}
l!l&&r!l&&!r
532750
MC/DC0%0/2
$dispatch->{$grade} || $dispatch->{'default'}
$dispatch->{$grade} $dispatch->{'default'}
Truth table66%2/3
A || B
A= $dispatch->{$grade}B= $dispatch->{'default'}
ABresult
1X1
011
000
1092 328 my $intro = $spec{$option}{prompt} . $extra . " (yes/no)";
1093 328 my $prompt;
1094 328 ▶ if ( $action =~ m{^ask/yes}i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($action =~ m[^ask/yes]i) { } 10 318 328
elsif ($action =~ m[^ask(/no)?]i) { } 72 246 318
1095 10 $prompt = CPAN::Shell::colorable_makemaker_prompt( $intro, "yes" );
1096 }
1097 elsif ( $action =~ m{^ask(/no)?}i ) {
1098 72 $prompt = CPAN::Shell::colorable_makemaker_prompt( $intro, "no" );
1099 }
1100 else {
1101 246 $prompt = $action;
1102 }
1103 328 return lc $prompt;
1104 }
1105  
1106 #--------------------------------------------------------------------------#
1107 # _report_text
1108 #--------------------------------------------------------------------------#
1109  
1110 33 my %intro_para = (
1111 'pass' => <<'HERE',
1112 Thank you for uploading your work to CPAN. Congratulations!
1113 All tests were successful.
1114 HERE
1115  
1116 'fail' => <<'HERE',
1117 Thank you for uploading your work to CPAN. However, there was a problem
1118 testing your distribution.
1119  
1120 If you think this report is invalid, please consult the CPAN Testers Wiki
1121 for suggestions on how to avoid getting FAIL reports for missing library
1122 or binary dependencies, unsupported operating systems, and so on:
1123  
1124 http://wiki.cpantesters.org/wiki/CPANAuthorNotes
1125 HERE
1126  
1127 'unknown' => <<'HERE',
1128 Thank you for uploading your work to CPAN. However, attempting to
1129 test your distribution gave an inconclusive result.
1130  
1131 This could be because your distribution had an error during the make/build
1132 stage, did not define tests, tests could not be found, because your tests were
1133 interrupted before they finished, or because the results of the tests could not
1134 be parsed. You may wish to consult the CPAN Testers Wiki:
1135  
1136 http://wiki.cpantesters.org/wiki/CPANAuthorNotes
1137 HERE
1138  
1139 'na' => <<'HERE',
1140 Thank you for uploading your work to CPAN. While attempting to build or test
1141 this distribution, the distribution signaled that support is not available
1142 either for this operating system or this version of Perl. Nevertheless, any
1143 diagnostic output produced is provided below for reference. If this is not
1144 what you expect, you may wish to consult the CPAN Testers Wiki:
1145  
1146 http://wiki.cpantesters.org/wiki/CPANAuthorNotes
1147 HERE
1148  
1149 );
1150  
1151 sub _comment_text {
1152  
1153 # We assemble the completed comment as a series of "parts" which
1154 # will get joined together
1155 117 ▶ my @comment_parts;
Subroutine _comment_text: called CC=8 SCAR=20.9
1156  
1157 # All automated testing gets a preamble
1158 117 ▶ if ($ENV{AUTOMATED_TESTING}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"AUTOMATED_TESTING"}) 111 6 117
1159 111 push @comment_parts,
1160 "this report is from an automated smoke testing program\n"
1161 . "and was not reviewed by a human for accuracy"
1162 }
1163  
1164 # If a comment file is provided, read it and add it to the comment
1165 117 my $confdir = CPAN::Reporter::Config::_get_config_dir();
1166 117 my $comment_file = File::Spec->catfile($confdir, 'comment.txt');
1167 117 ▶ if ( -d $confdir && -f $comment_file && -r $comment_file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $confdir and -f $comment_file and -r $comment_file) 2 115 117
Condition66%4/6
-d $confdir and -f $comment_file and -r $comment_file
!ll&&!rl&&r
11502
-d $confdir and -f $comment_file
!ll&&!rl&&r
01152
MC/DC33%1/3
-d $confdir and -f $comment_file and -r $comment_file
-d $confdir -f $comment_file -r $comment_file
Truth table50%2/4
A and B and C
A= -d $confdirB= -f $comment_fileC= -r $comment_file
ABCresult
0XX0
10X0
1100
1111
1168 2 ▶ open my $fh, '<:encoding(UTF-8)', $comment_file or die($!);
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<:encoding(UTF-8)", $comment_file or die $! 0 2 2
1169 2 my $text;
1170 2 do {
1171 2 local $/ = undef; # No record (line) seperator on input
1172 2 ▶ defined( $text = <$fh> ) or die($!);
Branch: 1 branch
BranchTrueFalseTotal
defined($text = readline $fh) or die $! 0 2 2
1173 };
1174 2 chomp($text);
1175 2 push @comment_parts, $text;
1176 2 close $fh;
1177 }
1178  
1179 # If we have an empty comment so far, add a default value
1180 117 ▶ if (scalar(@comment_parts) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @comment_parts == 0) 5 112 117
1181 5 push @comment_parts, 'none provided';
1182 }
1183  
1184 # Join the parts seperated by a blank line
1185 117 return join "\n\n", @comment_parts;
1186 }
1187  
1188 sub _report_text {
1189 117 ▶ my $data = shift;
Subroutine _report_text: called CC=2 SCAR=7.6
1190 117 my $test_log = join(q{},@{$data->{output}});
1191 117 ▶ if ( length $test_log > MAX_OUTPUT_LENGTH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $test_log > 1000000) 0 117 117
1192 0 $test_log = substr( $test_log, 0, MAX_OUTPUT_LENGTH) . "\n";
1193 0 my $max_k = int(MAX_OUTPUT_LENGTH/1000) . "K";
1194 0 $test_log .= "\n[Output truncated after $max_k]\n\n";
1195 }
1196  
1197 117 my $comment_body = _comment_text();
1198  
1199 # generate report
1200 117 my $output = << "ENDREPORT";
1201 Dear $data->{author},
1202  
1203 This is a computer-generated report for $data->{dist_name}
1204 on perl $data->{perl_version}, created by CPAN-Reporter-$CPAN::Reporter::VERSION\.
1205  
1206 $intro_para{ $data->{grade} }
1207 Sections of this report:
1208  
1209 * Tester comments
1210 * Program output
1211 * Prerequisites
1212 * Environment and other context
1213  
1214 ------------------------------
1215 TESTER COMMENTS
1216 ------------------------------
1217  
1218 Additional comments from tester:
1219  
1220 $comment_body
1221  
1222 ------------------------------
1223 PROGRAM OUTPUT
1224 ------------------------------
1225  
1226 Output from '$data->{command}':
1227  
1228 $test_log
1229 ------------------------------
1230 PREREQUISITES
1231 ------------------------------
1232  
1233 Prerequisite modules loaded:
1234  
1235 $data->{prereq_pm}
1236 ------------------------------
1237 ENVIRONMENT AND OTHER CONTEXT
1238 ------------------------------
1239  
1240 Environment variables:
1241  
1242 $data->{env_vars}
1243 Perl special variables (and OS-specific diagnostics, for MSWin32):
1244  
1245 $data->{special_vars}
1246 Perl module toolchain versions installed:
1247  
1248 $data->{toolchain_versions}
1249 ENDREPORT
1250  
1251 117 return $output;
1252 }
1253  
1254 #--------------------------------------------------------------------------#
1255 # _special_vars_report
1256 #--------------------------------------------------------------------------#
1257  
1258 sub _special_vars_report {
1259 176 ▶ my $special_vars = << "HERE";
Subroutine _special_vars_report: called CC=3 SCAR=16.8
1260 \$^X = $^X
1261 \$UID/\$EUID = $< / $>
1262 \$GID = $(
1263 \$EGID = $)
1264 HERE
1265 176 ▶ if ( $^O eq 'MSWin32' && eval "require Win32" ) { ## no critic
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" and eval "require Win32") 0 176 176
Condition33%1/3
$^O eq "MSWin32" and eval "require Win32"
!ll&&!rl&&r
17600
MC/DC0%0/2
$^O eq "MSWin32" and eval "require Win32"
$^O eq "MSWin32" eval "require Win32"
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= eval "require Win32"
ABresult
0X0
100
111
1266 0 my @getosversion = Win32::GetOSVersion();
1267 0 my $getosversion = join(", ", @getosversion);
1268 0 $special_vars .= " Win32::GetOSName = " . Win32::GetOSName() . "\n";
1269 0 $special_vars .= " Win32::GetOSVersion = $getosversion\n";
1270 0 $special_vars .= " Win32::FsType = " . Win32::FsType() . "\n";
1271 0 $special_vars .= " Win32::IsAdminUser = " . Win32::IsAdminUser() . "\n";
1272 }
1273 176 return $special_vars;
1274 }
1275  
1276 #--------------------------------------------------------------------------#
1277 # _split_redirect
1278 #--------------------------------------------------------------------------#
1279  
1280 sub _split_redirect {
1281 186 ▶ my $command = shift;
Subroutine _split_redirect: called CC=2 SCAR=6.9
1282 186 my ($cmd, $prefix) = ($command =~ m{\A(.+?)(\|.*)\z});
1283 186 ▶ if (defined $cmd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cmd) { } 1 185 186
1284 1 return ($cmd, $prefix);
1285 }
1286 else { # didn't match a redirection
1287 185 return $command
1288 }
1289 }
1290  
1291 #--------------------------------------------------------------------------#
1292 # _temp_filename -- stand-in for File::Temp for backwards compatibility
1293 #
1294 # takes an optional prefix, adds 8 random chars and returns
1295 # an absolute pathname
1296 #
1297 # NOTE -- manual unlink required
1298 #--------------------------------------------------------------------------#
1299  
1300 # @CHARS from File::Temp
1301 33 my @CHARS = (qw/ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1302 a b c d e f g h i j k l m n o p q r s t u v w x y z
1303 0 1 2 3 4 5 6 7 8 9 _
1304 /);
1305  
1306 sub _temp_filename {
1307 500 ▶ my ($prefix) = @_;
Subroutine _temp_filename: called CC=3 SCAR=11.1
1308 500 ▶ $prefix = q{} unless defined $prefix;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $prefix 0 500 500
1309 500 $prefix .= $CHARS[ int( rand(@CHARS) ) ] for 0 .. 7;
1310 500 return File::Spec->catfile(File::Spec->tmpdir(), $prefix);
1311 }
1312  
1313 #--------------------------------------------------------------------------#
1314 # _timeout_wrapper
1315 # Timeout technique adapted from App::cpanminus (thank you Miyagawa!)
1316 #--------------------------------------------------------------------------#
1317  
1318 sub _timeout_wrapper {
1319 15 ▶ my ($cmd, $timeout) = @_;
Subroutine _timeout_wrapper: called CC=1 SCAR=0.0
1320  
1321 # protect shell quotes
1322 15 $cmd = quotemeta($cmd);
1323  
1324 15 my $wrapper = sprintf << 'HERE', $timeout, $cmd, $cmd;
1325 use strict;
1326 my ($pid, $exitcode);
1327 eval {
1328 $pid = fork;
1329 if ($pid) {
1330 local $SIG{CHLD};
1331 local $SIG{ALRM} = sub {die 'Timeout'};
1332 alarm %s;
1333 my $wstat = waitpid $pid, 0;
1334 alarm 0;
1335 $exitcode = $wstat == -1 ? -1 : $?;
1336 } elsif ( $pid == 0 ) {
1337 setpgrp(0,0); # new process group
1338 exec "%s";
1339 }
1340 else {
1341 die "Cannot fork: $!\n" unless defined $pid;
1342 }
1343 };
1344 if ($pid && $@ =~ /Timeout/){
1345 kill -9 => $pid; # and send to our child's whole process group
1346 waitpid $pid, 0;
1347 $exitcode = 9; # force result to look like SIGKILL
1348 }
1349 elsif ($@) {
1350 die $@;
1351 }
1352 print "(%s exited with $exitcode)\n";
1353 HERE
1354 15 return $wrapper;
1355 }
1356  
1357 #--------------------------------------------------------------------------#
1358 # _timeout_wrapper_win32
1359 #--------------------------------------------------------------------------#
1360  
1361 sub _timeout_wrapper_win32 {
1362 0 ▶ my ($cmd, $timeout) = @_;
Subroutine _timeout_wrapper_win32: not called CC=6 SCAR=37.4
1363  
1364 0 ▶ $timeout ||= 0; # just in case upstream doesn't guarantee it
Condition0%0/2
$timeout ||= 0
l!l
00
MC/DC0%0/1
$timeout ||= 0
$timeout
Truth table0%0/2
A
A= $timeout
Aresult
11
00
1365  
1366 0 eval "use Win32::Job ();";
1367 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1368 0 $CPAN::Frontend->mywarn( << 'HERE' );
1369 CPAN::Reporter: you need Win32::Job for inactivity_timeout support.
1370 Continuing without timeout...
1371 HERE
1372 0 return;
1373 }
1374  
1375 0 my ($program) = split " ", $cmd;
1376 0 ▶ if (! File::Spec->file_name_is_absolute( $program ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("File::Spec"->file_name_is_absolute($program)) 0 0 0
1377 0 my $exe = $program . ".exe";
1378 0 my ($path) = grep { -e File::Spec->catfile($_,$exe) }
1379 0 split /$Config{path_sep}/, $ENV{PATH};
1380 0 ▶ if (! $path) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($path) 0 0 0
1381 0 $CPAN::Frontend->mywarn( << "HERE" );
1382 CPAN::Reporter: can't locate $exe in the PATH.
1383 Continuing without timeout...
1384 HERE
1385 0 return;
1386 }
1387 0 $program = File::Spec->catfile($path,$exe);
1388 }
1389  
1390 # protect shell quotes and other things
1391 0 $_ = quotemeta($_) for ($program, $cmd);
1392  
1393 0 my $wrapper = sprintf << 'HERE', $program, $cmd, $timeout;
1394 use strict;
1395 use Win32::Job;
1396 my $executable = "%s";
1397 my $cmd_line = "%s";
1398 my $timeout = %s;
1399  
1400 my $job = Win32::Job->new() or die $^E;
1401 my $ppid = $job->spawn($executable, $cmd_line);
1402 $job->run($timeout);
1403 my $status = $job->status;
1404 my $exitcode = $status->{$ppid}{exitcode};
1405 if ( $exitcode == 293 ) {
1406 $exitcode = 9; # map Win32::Job kill (293) to SIGKILL (9)
1407 }
1408 elsif ( $exitcode & 255 ) {
1409 $exitcode = $exitcode << 8; # how perl expects it
1410 }
1411 print "($cmd_line exited with $exitcode)\n";
1412 HERE
1413 0 return $wrapper;
1414 }
1415  
1416 #--------------------------------------------------------------------------#-
1417 # _toolchain_report
1418 #--------------------------------------------------------------------------#
1419  
1420 33 my @toolchain_mods= qw(
1421 CPAN
1422 CPAN::Meta
1423 Cwd
1424 ExtUtils::CBuilder
1425 ExtUtils::Command
1426 ExtUtils::Install
1427 ExtUtils::MakeMaker
1428 ExtUtils::Manifest
1429 ExtUtils::ParseXS
1430 File::Spec
1431 JSON
1432 JSON::PP
1433 Module::Build
1434 Module::Signature
1435 Parse::CPAN::Meta
1436 Test::Harness
1437 Test::More
1438 YAML
1439 YAML::Syck
1440 version
1441 );
1442  
1443 sub _toolchain_report {
1444 176 ▶ my ($result) = @_;
Subroutine _toolchain_report: called CC=2 SCAR=6.9
1445  
1446 176 my $installed = _version_finder( map { $_ => 0 } @toolchain_mods );
1447 176 $result->{toolchain} = $installed;
1448  
1449 176 my $mod_width = _max_length( keys %$installed );
1450 my $ver_width = _max_length(
1451 176 map { $installed->{$_}{have} } keys %$installed
1452 );
1453  
1454 176 my $format = " \%-${mod_width}s \%-${ver_width}s\n";
1455  
1456 176 my $report = "";
1457 176 $report .= sprintf( $format, "Module", "Have" );
1458 176 $report .= sprintf( $format, "-" x $mod_width, "-" x $ver_width );
1459  
1460 176 for my $var ( sort keys %$installed ) {
1461 $report .= sprintf(" \%-${mod_width}s \%-${ver_width}s\n",
1462 3520 $var, $installed->{$var}{have} );
1463 }
1464  
1465 176 return $report;
1466 }
1467  
1468  
1469 #--------------------------------------------------------------------------#
1470 # _validate_metabase_args
1471 #
1472 # This is a kludge to make metabase transport args a little less
1473 # clunky for novice users
1474 #--------------------------------------------------------------------------#
1475  
1476 sub _validate_metabase_args {
1477 116 ▶ my @transport_args = @_;
Subroutine _validate_metabase_args: called CC=6 SCAR=21.2
1478 116 shift @transport_args; # drop leading 'Metabase'
1479 116 my (%args, $error);
1480  
1481 116 ▶ if ( @transport_args % 2 != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@transport_args % 2 != 0) { } 0 116 116
1482 0 $error = << "TRANSPORT_ARGS";
1483  
1484 CPAN::Reporter: Metabase 'transport' option had odd number of
1485 parameters in the config file. See documentation for proper
1486 configuration format.
1487  
1488 TRANSPORT_ARGS
1489 }
1490 else {
1491 116 %args = @transport_args;
1492  
1493 116 for my $key ( qw/uri id_file/ ) {
1494 232 ▶ if ( ! $args{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{$key}) 0 232 232
1495 0 $error = << "TRANSPORT_ARGS";
1496  
1497 CPAN::Reporter: Metabase 'transport' option did not have
1498 a '$key' parameter in the config file. See documentation for
1499 proper configuration format.
1500  
1501 TRANSPORT_ARGS
1502 }
1503 }
1504 }
1505  
1506 116 ▶ if ( $error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 116 116
1507 0 $CPAN::Frontend->mywarn( $error );
1508 0 return;
1509 }
1510  
1511 116 $args{id_file} = CPAN::Reporter::Config::_normalize_id_file( $args{id_file} );
1512  
1513 116 ▶ if ( ! -r $args{id_file} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-r $args{"id_file"}) 0 116 116
1514 0 $CPAN::Frontend->mywarn( <<"TRANSPORT_ARGS" );
1515  
1516 CPAN::Reporter: Could not find Metabase transport 'id_file' parameter
1517 located at '$args{id_file}'.
1518 See documentation for proper configuration of the 'transport' setting.
1519  
1520 TRANSPORT_ARGS
1521 0 return;
1522 }
1523  
1524 116 return ('Metabase', %args);
1525 }
1526  
1527  
1528 #--------------------------------------------------------------------------#
1529 # _version_finder
1530 #
1531 # module => version pairs
1532 #
1533 # This is done via an external program to show installed versions exactly
1534 # the way they would be found when test programs are run. This means that
1535 # any updates to PERL5LIB will be reflected in the results.
1536 #
1537 # File-finding logic taken from CPAN::Module::inst_file(). Logic to
1538 # handle newer Module::Build prereq syntax is taken from
1539 # CPAN::Distribution::unsat_prereq()
1540 #
1541 #--------------------------------------------------------------------------#
1542  
1543 33 my $version_finder = $INC{'CPAN/Reporter/PrereqCheck.pm'};
1544  
1545 sub _version_finder {
1546 314 ▶ my %prereqs = @_;
Subroutine _version_finder: called CC=7 SCAR=20.8
1547  
1548 314 my $perl = Probe::Perl->find_perl_interpreter();
1549 314 my @prereq_results;
1550  
1551 314 my $prereq_input = _temp_filename( 'CPAN-Reporter-PI-' );
1552 314 ▶ my $fh = IO::File->new( $prereq_input, "w" )
Branch: 1 branch
BranchTrueFalseTotal
my $fh = "IO::File"->new($prereq_input, "w") or die "Could not create temporary '${prereq_input}' for prereq analysis: $!" 0 314 314
1553 or die "Could not create temporary '$prereq_input' for prereq analysis: $!";
1554 314 $fh->print( map { "$_ $prereqs{$_}\n" } keys %prereqs );
1555 314 $fh->close;
1556  
1557 314 ▶ my $prereq_result = capture { system( $perl, $version_finder, '<', $prereq_input ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
1558  
1559 314 unlink $prereq_input;
1560  
1561 314 my %result;
1562 314 for my $line ( split "\n", $prereq_result ) {
1563 3719 ▶ next unless length $line;
Branch: 1 branch
BranchTrueFalseTotal
unless length $line 0 3719 3719
1564 3719 my ($mod, $met, $have) = split " ", $line;
1565 3719 ▶ unless ( defined($mod) && defined($met) && defined($have) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mod and defined $met and defined $have) 0 3719 3719
Condition33%2/6
defined $mod and defined $met and defined $have
!ll&&!rl&&r
003719
defined $mod and defined $met
!ll&&!rl&&r
003719
MC/DC0%0/3
defined $mod and defined $met and defined $have
defined $mod defined $met defined $have
Truth table25%1/4
A and B and C
A= defined $modB= defined $metC= defined $have
ABCresult
0XX0
10X0
1100
1111
1566 0 $CPAN::Frontend->mywarn(
1567 "Error parsing output from CPAN::Reporter::PrereqCheck:\n" .
1568 $line
1569 );
1570 0 next;
1571 }
1572 3719 $result{$mod}{have} = $have;
1573 3719 $result{$mod}{met} = $met;
1574 }
1575 314 return \%result;
1576 }
1577  
1578 33 1;
1579  
1580 # ABSTRACT: Adds CPAN Testers reporting to CPAN.pm
1581  
1582 =pod
1583  
1584 =encoding UTF-8
1585  
1586 =head1 NAME
1587  
1588 CPAN::Reporter - Adds CPAN Testers reporting to CPAN.pm
1589  
1590 =head1 VERSION
1591  
1592 version 1.2018
1593  
1594 =head1 SYNOPSIS
1595  
1596 From the CPAN shell:
1597  
1598 cpan> install Task::CPAN::Reporter
1599 cpan> reload cpan
1600 cpan> o conf init test_report
1601  
1602 Installing L<Task::CPAN::Reporter> will pull in additional dependencies
1603 that new CPAN Testers will need.
1604  
1605 Advanced CPAN Testers with custom L<Test::Reporter::Transport> setups
1606 may wish to install only CPAN::Reporter, which has fewer dependencies.
1607  
1608 =head1 DESCRIPTION
1609  
1610 The CPAN Testers project captures and analyzes detailed results from building
1611 and testing CPAN distributions on multiple operating systems and multiple
1612 versions of Perl. This provides valuable feedback to module authors and
1613 potential users to identify bugs or platform compatibility issues and improves
1614 the overall quality and value of CPAN.
1615  
1616 One way individuals can contribute is to send a report for each module that
1617 they test or install. CPAN::Reporter is an add-on for the CPAN.pm module to
1618 send the results of building and testing modules to the CPAN Testers project.
1619 Full support for CPAN::Reporter is available in CPAN.pm as of version 1.92.
1620  
1621 =for Pod::Coverage configure
1622 grade_PL
1623 grade_make
1624 grade_test
1625 record_command
1626 test
1627  
1628 =head1 GETTING STARTED
1629  
1630 =head2 Installation
1631  
1632 The first step in using CPAN::Reporter is to install it using whatever
1633 version of CPAN.pm is already installed. CPAN.pm will be upgraded as
1634 a dependency if necessary.
1635  
1636 cpan> install CPAN::Reporter
1637  
1638 If CPAN.pm was upgraded, it needs to be reloaded.
1639  
1640 cpan> reload cpan
1641  
1642 =head2 Configuration
1643  
1644 If upgrading from a very old version of CPAN.pm, users may be prompted to renew
1645 their configuration settings, including the 'test_report' option to enable
1646 CPAN::Reporter.
1647  
1648 If not prompted automatically, users should manually initialize CPAN::Reporter
1649 support. After enabling CPAN::Reporter, CPAN.pm will automatically continue
1650 with interactive configuration of CPAN::Reporter options.
1651  
1652 cpan> o conf init test_report
1653  
1654 Users will need to enter an email address in one of the following formats:
1655  
1656 johndoe@example.com
1657 John Doe <johndoe@example.com>
1658 "John Q. Public" <johnqpublic@example.com>
1659  
1660 Users that are new to CPAN::Reporter should accept the recommended values
1661 for other configuration options.
1662  
1663 Users will be prompted to create a I<Metabase profile> file that uniquely
1664 identifies their test reports. See L</"The Metabase"> below for details.
1665  
1666 After completing interactive configuration, be sure to commit (save) the CPAN
1667 configuration changes.
1668  
1669 cpan> o conf commit
1670  
1671 See L<CPAN::Reporter::Config> for advanced configuration settings.
1672  
1673 =head3 The Metabase
1674  
1675 CPAN::Reporter sends test reports to a server known as the Metabase. This
1676 requires an active Internet connection and a profile file. To create the
1677 profile, users will need to run C<<< metabase-profile >>> from a terminal window and
1678 fill the information at the prompts. This will create a file called
1679 C<<< metabase_id.json >>> in the current directory. That file should be moved to the
1680 C<<< .cpanreporter >>> directory inside the user's home directory.
1681  
1682 Users with an existing metabase profile file (e.g. from another machine),
1683 should copy it into the C<<< .cpanreporter >>> directory instead of creating
1684 a new one. Profile files may be located outside the C<<< .cpanreporter >>>
1685 directory by following instructions in L<CPAN::Reporter::Config>.
1686  
1687 =head3 Default Test Comments
1688  
1689 This module puts default text into the "TESTER COMMENTS" section, typically,
1690 "none provided" if doing interactive testing, or, if doing smoke testing that
1691 sets CE<lt>$ENV{AUTOMATED_TESTING}E<gt> to a true value, "this report is from an
1692 automated smoke testing program and was not reviewed by a human for
1693 accuracy." If CE<lt>CPAN::ReporterE<gt> is configured to allow editing of the
1694 report, this can be edited during submission.
1695  
1696 If you wish to override the default comment, you can create a file named
1697 CE<lt>comment.txtE<gt> in the configuration directory (typically C<<< .cpanreporter >>>
1698 under the user's home directory), with the default comment you would
1699 like to appear.
1700  
1701 Note that if your test is an automated smoke
1702 test (CE<lt>$ENV{AUTOMATED_TESTING}E<gt> is set to a true value), the smoke
1703 test notice ("this report is from an automated smoke testing program and
1704 was not reviewed by a human for accuracy") is included along with a blank
1705 line before your CE<lt>comment.txtE<gt>, so that it is always possible to
1706 distinguish automated tests from non-automated tests that use this
1707 module.
1708  
1709 =head2 Using CPAN::Reporter
1710  
1711 Once CPAN::Reporter is enabled and configured, test or install modules with
1712 CPAN.pm as usual.
1713  
1714 For example, to test the File::Marker module:
1715  
1716 cpan> test File::Marker
1717  
1718 If a distribution's tests fail, users will be prompted to edit the report to
1719 add additional information that might help the author understand the failure.
1720  
1721 =head1 UNDERSTANDING TEST GRADES
1722  
1723 CPAN::Reporter will assign one of the following grades to the report:
1724  
1725 =over
1726  
1727 =item *
1728  
1729 C<<< pass >>> -- distribution built and tested correctly
1730  
1731 =item *
1732  
1733 C<<< fail >>> -- distribution failed to test correctly
1734  
1735 =item *
1736  
1737 C<<< unknown >>> -- distribution failed to build, had no test suite or outcome was
1738 inconclusive
1739  
1740 =item *
1741  
1742 C<<< na >>> --- distribution is not applicable to this platform andE<sol>or
1743 version of Perl
1744  
1745 =back
1746  
1747 In returning results of the test suite to CPAN.pm, "pass" and "unknown" are
1748 considered successful attempts to "make test" or "Build test" and will not
1749 prevent installation. "fail" and "na" are considered to be failures and
1750 CPAN.pm will not install unless forced.
1751  
1752 An error from Makefile.PLE<sol>Build.PL or makeE<sol>Build will also be graded as
1753 "unknown" and a failure will be signaled to CPAN.pm.
1754  
1755 If prerequisites specified in C<<< Makefile.PL >>> or C<<< Build.PL >>> are not available,
1756 no report will be generated and a failure will be signaled to CPAN.pm.
1757  
1758 =head1 PRIVACY WARNING
1759  
1760 CPAN::Reporter includes information in the test report about environment
1761 variables and special Perl variables that could be affecting test results in
1762 order to help module authors interpret the results of the tests. This includes
1763 information about paths, terminal, locale, userE<sol>group ID, installed toolchain
1764 modules (e.g. ExtUtils::MakeMaker) and so on.
1765  
1766 These have been intentionally limited to items that should not cause harmful
1767 personal information to be revealed -- it does I<not> include your entire
1768 environment. Nevertheless, please do not use CPAN::Reporter if you are
1769 concerned about the disclosure of this information as part of your test report.
1770  
1771 Users wishing to review this information may choose to edit the report
1772 prior to sending it.
1773  
1774 =head1 BUGS
1775  
1776 Using command_timeout on Linux may cause problems. See
1777 L<https://rt.cpan.org/Ticket/Display.html?id=62310>
1778  
1779 Please report any bugs or feature using the CPAN Request Tracker.
1780 Bugs can be submitted through the web interface at
1781 L<http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Reporter>
1782  
1783 When submitting a bug or request, please include a test-file or a patch to an
1784 existing test-file that illustrates the bug or desired feature.
1785  
1786 =head1 SEE ALSO
1787  
1788 Information about CPAN::Testers:
1789  
1790 =over
1791  
1792 =item *
1793  
1794 L<CPAN::Testers> -- overview of CPAN Testers architecture stack
1795  
1796 =item *
1797  
1798 L<http://www.cpantesters.org> -- project home with all reports
1799  
1800 =item *
1801  
1802 L<http://wiki.cpantesters.org> -- documentation and wiki
1803  
1804 =back
1805  
1806 Additional Documentation:
1807  
1808 =over
1809  
1810 =item *
1811  
1812 L<CPAN::Reporter::Config> -- advanced configuration settings
1813  
1814 =item *
1815  
1816 L<CPAN::Reporter::FAQ> -- hints and tips
1817  
1818 =back
1819  
1820 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
1821  
1822 =head1 SUPPORT
1823  
1824 =head2 Bugs / Feature Requests
1825  
1826 Please report any bugs or feature requests through the issue tracker
1827 at L<https://github.com/cpan-testers/CPAN-Reporter/issues>.
1828 You will be notified automatically of any progress on your issue.
1829  
1830 =head2 Source Code
1831  
1832 This is open source software. The code repository is available for
1833 public review and contribution under the terms of the license.
1834  
1835 L<https://github.com/cpan-testers/CPAN-Reporter>
1836  
1837 git clone https://github.com/cpan-testers/CPAN-Reporter.git
1838  
1839 =head1 AUTHOR
1840  
1841 David Golden <dagolden@cpan.org>
1842  
1843 =head1 CONTRIBUTORS
1844  
1845 =for stopwords Alexandr Ciornii Breno G. de Oliveira Christian Walde Ed J Joel Maslak Kent Fredric Matthew Musgrove Patrice Clement Reini Urban Scott Wiersdorf Slaven Rezic
1846  
1847 =over 4
1848  
1849 =item *
1850  
1851 Alexandr Ciornii <alexchorny@gmail.com>
1852  
1853 =item *
1854  
1855 Breno G. de Oliveira <garu@cpan.org>
1856  
1857 =item *
1858  
1859 Christian Walde <walde.christian@googlemail.com>
1860  
1861 =item *
1862  
1863 Ed J <mohawk2@users.noreply.github.com>
1864  
1865 =item *
1866  
1867 Joel Maslak <jmaslak@antelope.net>
1868  
1869 =item *
1870  
1871 Kent Fredric <kentfredric@gmail.com>
1872  
1873 =item *
1874  
1875 Matthew Musgrove <mr.muskrat@gmail.com>
1876  
1877 =item *
1878  
1879 Patrice Clement <monsieurp@gentoo.org>
1880  
1881 =item *
1882  
1883 Reini Urban <rurban@cpanel.net>
1884  
1885 =item *
1886  
1887 Scott Wiersdorf <scott@perlcode.org>
1888  
1889 =item *
1890  
1891 Slaven Rezic <slaven@rezic.de>
1892  
1893 =back
1894  
1895 =head1 COPYRIGHT AND LICENSE
1896  
1897 This software is Copyright (c) 2006 by David Golden.
1898  
1899 This is free software, licensed under:
1900  
1901 The Apache License, Version 2.0, January 2004
1902  
1903 =cut
1904  
1905 __END__
« blib/lib/CPAN/Reporter/PrereqCheck.pm ↑ Summary blib/lib/CPAN/Reporter/Config.pm »