lib/CPANPLUS/Internals/Constants/Report.pm

filter: Statementstmt 98.3% 173 / 176 Branchbran 71.0% 27 / 38 Conditioncond 57.1% 8 / 14 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 95.6% 44 / 46 Podpod n/a totaltotal 90.0% 254 / 282 CC 26 SCAR 10.5
CC
26
Cov
91%
__ANON__
8.8
__ANON__
5.2
__ANON__
4.0
CRAP 2.9
« blib/lib/CPANPLUS/Module/Fake.pm ↑ Summary lib/CPANPLUS/Error.pm »
1 package CPANPLUS::Internals::Constants::Report;
2  
3 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use CPANPLUS::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 20 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 ▶use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 20 require Exporter;
10 20 ▶use vars qw[$VERSION @ISA @EXPORT];
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 20 ▶use Package::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 20 $VERSION = "0.9914";
15 20 @ISA = qw[Exporter];
16 20 @EXPORT = Package::Constants->list( __PACKAGE__ );
17  
18 ### OS to regex map ###
19 20 my %OS = (
20 Amiga => 'amigaos',
21 Atari => 'mint',
22 BSD => 'bsdos|bitrig|darwin|freebsd|openbsd|netbsd',
23 Be => 'beos',
24 BeOS => 'beos',
25 Cygwin => 'cygwin',
26 Darwin => 'darwin',
27 EBCDIC => 'os390|os400|posix-bc|vmesa',
28 HPUX => 'hpux',
29 Linux => 'linux',
30 MSDOS => 'dos|os2|MSWin32|cygwin',
31 'bin\\d*Mac'=> 'MacOS|darwin', # binMac, bin56Mac, bin58Mac...
32 Mac => 'MacOS|darwin',
33 MacPerl => 'MacOS',
34 MacOS => 'MacOS|darwin',
35 MacOSX => 'darwin',
36 MPE => 'mpeix',
37 MPEiX => 'mpeix',
38 OS2 => 'os2',
39 Plan9 => 'plan9',
40 RISCOS => 'riscos',
41 SGI => 'irix',
42 Solaris => 'solaris',
43 Unix => 'aix|bsdos|bitrig|darwin|dgux|dynixptx|freebsd|'.
44 'linux|hpux|machten|netbsd|next|openbsd|dec_osf|'.
45 'svr4|sco_sv|unicos|unicosmk|solaris|sunos',
46 VMS => 'VMS',
47 VOS => 'VOS',
48 Win32 => 'MSWin32|cygwin',
49 Win32API => 'MSWin32|cygwin',
50 );
51  
52 20 ▶use constant GRADE_FAIL => 'fail';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 20 ▶use constant GRADE_PASS => 'pass';
Subroutine BEGIN: called CC=1 SCAR=0.0
54 20 ▶use constant GRADE_NA => 'na';
Subroutine BEGIN: called CC=1 SCAR=0.0
55 20 ▶use constant GRADE_UNKNOWN => 'unknown';
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 20 use constant MAX_REPORT_SEND
58 20 ▶ => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 20 use constant CPAN_TESTERS_EMAIL
61 20 ▶ => 'cpan-testers@perl.org';
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 ### the cpan mail account for this user ###
64 use constant CPAN_MAIL_ACCOUNT
65 => sub {
66 1 ▶ my $username = shift or return;
Subroutine __ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
my $username = shift() or return 0 1 1
67 1 return $username . '@cpan.org';
68 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
69  
70 ### check if this module is platform specific and if we're on that
71 ### specific platform. Alternately, the module is not platform specific
72 ### and we're always OK to send out test results.
73 use constant RELEVANT_TEST_RESULT
74 => sub {
75 2 ▶ my $mod = shift or return;
Subroutine __ANON__: called CC=8 SCAR=21.7
Branch: 1 branch
BranchTrueFalseTotal
my $mod = shift() or return 0 2 2
76 2 my $name = $mod->module;
77 2 my $specific;
78 2 for my $platform (keys %OS) {
79 56 ▶ if( $name =~ /^$platform\b/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^$platform\b/i) 1 55 56
80 # beware the Mac != MAC
81 1 ▶ next if($platform eq 'Mac' &&
Branch: 1 branch
BranchTrueFalseTotal
if $platform eq "Mac" and not $name =~ /^$platform\b/ 0 1 1
Condition33%1/3
$platform eq "Mac" and not $name =~ /^$platform\b/
!ll&&!rl&&r
100
MC/DC0%0/2
$platform eq "Mac" and not $name =~ /^$platform\b/
$platform eq "Mac" not $name =~ /^$platform\b/
Truth table33%1/3
A and not(B)
A= $platform eq "Mac"B= not $name =~ /^$platform\b/
ABresult
0X0
100
111
82 $name !~ /^$platform\b/);
83 1 $specific++;
84 1 ▶ return 1 if
Branch: 1 branch
BranchTrueFalseTotal
if $^O =~ /^(?:$OS{$platform})$/ 0 1 1
85 $^O =~ /^(?:$OS{$platform})$/
86 }
87 };
88 2 ▶ return $specific ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$specific ? : 1 1 2
89 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
90  
91 use constant UNSUPPORTED_OS
92 => sub {
93 4 ▶ my $buffer = shift or return;
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
my $buffer = shift() or return 0 4 4
94 4 ▶ if( $buffer =~
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer =~ /No support for OS|OS unsupported/im) 3 1 4
95 /No support for OS|OS unsupported/im ) {
96 3 return 1;
97 }
98 1 return 0;
99 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
100  
101 use constant PERL_VERSION_TOO_LOW
102 => sub {
103 4 ▶ my $buffer = shift or return;
Subroutine __ANON__: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
my $buffer = shift() or return 0 4 4
104 # ExtUtils::MakeMaker format
105 4 ▶ if( $buffer =~
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer =~ /Perl .*? required--this is only .*?/m) 1 3 4
106 /Perl .*? required--this is only .*?/m ) {
107 1 return 1;
108 }
109 # Module::Build format
110 3 ▶ if( $buffer =~
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer =~ /ERROR:( perl:)? Version .*?( of perl)? is installed, but we need version >= .*?/m) 2 1 3
111 /ERROR:( perl:)? Version .*?( of perl)? is installed, but we need version >= .*?/m ) {
112 2 return 1;
113 }
114 1 return 0;
115 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
116  
117 use constant NO_TESTS_DEFINED
118 => sub {
119 8 ▶ my $buffer = shift or return;
Subroutine __ANON__: called CC=5 SCAR=16.6
Branch: 1 branch
BranchTrueFalseTotal
my $buffer = shift() or return 0 8 8
120 8 ▶ if( $buffer =~
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer =~ /(No tests defined( for [\w:]+ extension)?\.)/ and not $buffer =~ /\*\.t/m and not $buffer =~ /test\.pl/m) 3 5 8
Condition66%4/6
$buffer =~ /(No tests defined( for [\w:]+ extension)?\.)/ and not $buffer =~ /\*\.t/m and not $buffer =~ /test\.pl/m
!ll&&!rl&&r
503
$buffer =~ /(No tests defined( for [\w:]+ extension)?\.)/ and not $buffer =~ /\*\.t/m
!ll&&!rl&&r
503
MC/DC33%1/3
$buffer =~ /(No tests defined( for [\w:]+ extension)?\.)/ and not $buffer =~ /\*\.t/m and not $buffer =~ /test\.pl/m
$buffer =~ /(No tests defined( for [\w:]+ extension)?\.)/ not $buffer =~ /\*\.t/m not $buffer =~ /test\.pl/m
Truth table50%2/4
A and not(B) and not(C)
A= $buffer =~ /(No tests defined( for [\w:]+ extension)?\.)/B= not $buffer =~ /\*\.t/mC= not $buffer =~ /test\.pl/m
ABCresult
0XX0
10X0
1100
1111
121 /(No tests defined( for [\w:]+ extension)?\.)/
122 and $buffer !~ /\*\.t/m and
123 $buffer !~ /test\.pl/m
124 ) {
125 3 return $1
126 }
127  
128 5 return;
129 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
130  
131 ### what stage did the test fail? ###
132 use constant TEST_FAIL_STAGE
133 => sub {
134 2 ▶ my $buffer = shift or return;
Subroutine __ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
my $buffer = shift() or return 0 2 2
135 2 ▶ return $buffer =~ /(MAKE [A-Z]+).*/
Branch: 1 branch
BranchTrueFalseTotal
$buffer =~ /(MAKE [A-Z]+).*/ ? : 1 1 2
136 ? lc $1 :
137 'fetch';
138 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
139  
140  
141 use constant MISSING_PREREQS_LIST
142 => sub {
143 2 ▶ my $buffer = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
144 2 my $last = ( split /\[ERROR\] .+? MAKE TEST/, $buffer )[-1];
145 2 my @list = map { s/.pm$//; s|/|::|g; $_ }
146 ($last =~
147 m/\bCan\'t locate (\S+) in \@INC/g);
148  
149 ### make sure every missing prereq is only
150 ### listed once
151 2 { my %seen;
152 2 @list = grep { !$seen{$_}++ } @list
153 }
154  
155 2 return @list;
156 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
157  
158 use constant MISSING_EXTLIBS_LIST
159 => sub {
160 1 ▶ my $buffer = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
161 1 my @list =
162 ($buffer =~
163 m/No library found for -l([-\w]+)/g);
164  
165 1 return @list;
166 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
167  
168 use constant REPORT_MESSAGE_HEADER
169 => sub {
170 1 ▶ my ($version, $author) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
171 1 return << ".";
172  
173 Dear $author,
174  
175 This is a computer-generated error report created automatically by
176 CPANPLUS, version $version. Testers personal comments may appear
177 at the end of this report.
178  
179 .
180 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
181  
182 use constant REPORT_MESSAGE_FAIL_HEADER
183 => sub {
184 1 ▶ my($stage, $buffer) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
185 1 return << ".";
186  
187 Thank you for uploading your work to CPAN. However, it appears that
188 there were some problems testing your distribution.
189  
190 TEST RESULTS:
191  
192 Below is the error stack from stage '$stage':
193  
194 $buffer
195  
196 .
197 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
198  
199 use constant REPORT_MESSAGE_PASS_HEADER
200 => sub {
201 0 ▶ my($stage, $buffer) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
202 0 return << ".";
203  
204 Thank you for uploading your work to CPAN. Congratulations!
205 All tests were successful.
206  
207 TEST RESULTS:
208  
209 Below is the error stack from stage '$stage':
210  
211 $buffer
212  
213 .
214 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
215  
216 use constant REPORT_MISSING_PREREQS
217 => sub {
218 2 ▶ my ($author,$email,@missing) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
219 2 ▶ $author = ($author && $email)
Branch: 1 branch
BranchTrueFalseTotal
$author && $email ? : 1 1 2
Condition66%2/3
$author and $email
!ll&&!rl&&r
101
MC/DC50%1/2
$author and $email
$author $email
Truth table66%2/3
A and B
A= $authorB= $email
ABresult
0X0
100
111
220 ? "$author ($email)"
221 : 'Your Name Here';
222  
223 2 my $modules = join "\n", @missing;
224 my $prereqs = join "\n",
225 2 map {"\t'$_'\t=> '0',".
226 " # or a minimum working version"}
227 @missing;
228  
229 2 return << ".";
230  
231 MISSING PREREQUISITES:
232  
233 It was observed that the test suite seem to fail without these modules:
234  
235 $modules
236  
237 As such, adding the prerequisite module(s) to 'PREREQ_PM' in your
238 Makefile.PL should solve this problem. For example:
239  
240 WriteMakefile(
241 AUTHOR => '$author',
242 ... # other information
243 PREREQ_PM => {
244 $prereqs
245 }
246 );
247  
248 Thanks! :-)
249  
250 .
251 20 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
252  
253 use constant REPORT_MISSING_TESTS
254 => sub {
255 1 ▶ return << ".";
Subroutine __ANON__: called CC=1 SCAR=0.0
256 RECOMMENDATIONS:
257  
258 It would be very helpful if you could include even a simple test
259 script in the next release, so people can verify which platforms
260 can successfully install them, as well as avoid regression bugs?
261  
262 A simple 't/use.t' that says:
263  
264 #!/usr/bin/env perl -w
265 use strict;
266 use Test;
267 BEGIN { plan tests => 1 }
268  
269 use Your::Module::Here; ok(1);
270 exit;
271 __END__
« blib/lib/CPANPLUS/Module/Fake.pm ↑ Summary lib/CPANPLUS/Error.pm »