blib/lib/CPANPLUS/Internals/Constants/Report.pm untested

filter: Statementstmt 0.0% 0 / 181 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 26 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 30 Podpod n/a totaltotal 0.0% 0 / 263 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package CPANPLUS::Internals::Constants::Report;
2  
3 use strict;
4 use CPANPLUS::Error;
5  
6 use File::Spec;
7 use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
8  
9 require Exporter;
10 use vars qw[$VERSION @ISA @EXPORT];
11  
12 use Package::Constants;
13  
14 $VERSION = "0.9912";
15 @ISA = qw[Exporter];
16 @EXPORT = Package::Constants->list( __PACKAGE__ );
17  
18 ### OS to regex map ###
19 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 use constant GRADE_FAIL => 'fail';
53 use constant GRADE_PASS => 'pass';
54 use constant GRADE_NA => 'na';
55 use constant GRADE_UNKNOWN => 'unknown';
56  
57 use constant MAX_REPORT_SEND
58 => 2;
59  
60 use constant CPAN_TESTERS_EMAIL
61 => 'cpan-testers@perl.org';
62  
63 ### the cpan mail account for this user ###
64 use constant CPAN_MAIL_ACCOUNT
65 => sub {
66 my $username = shift or return;
67 return $username . '@cpan.org';
68 };
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 my $mod = shift or return;
76 my $name = $mod->module;
77 my $specific;
78 for my $platform (keys %OS) {
79 if( $name =~ /^$platform\b/i ) {
80 # beware the Mac != MAC
81 next if($platform eq 'Mac' &&
82 $name !~ /^$platform\b/);
83 $specific++;
84 return 1 if
85 $^O =~ /^(?:$OS{$platform})$/
86 }
87 };
88 return $specific ? 0 : 1;
89 };
90  
91 use constant UNSUPPORTED_OS
92 => sub {
93 my $buffer = shift or return;
94 if( $buffer =~
95 /No support for OS|OS unsupported/im ) {
96 return 1;
97 }
98 return 0;
99 };
100  
101 use constant PERL_VERSION_TOO_LOW
102 => sub {
103 my $buffer = shift or return;
104 # ExtUtils::MakeMaker format
105 if( $buffer =~
106 /Perl .*? required--this is only .*?/m ) {
107 return 1;
108 }
109 # Module::Build format
110 if( $buffer =~
111 /ERROR:( perl:)? Version .*?( of perl)? is installed, but we need version >= .*?/m ) {
112 return 1;
113 }
114 return 0;
115 };
116  
117 use constant NO_TESTS_DEFINED
118 => sub {
119 my $buffer = shift or return;
120 if( $buffer =~
121 /(No tests defined( for [\w:]+ extension)?\.)/
122 and $buffer !~ /\*\.t/m and
123 $buffer !~ /test\.pl/m
124 ) {
125 return $1
126 }
127  
128 return;
129 };
130  
131 ### what stage did the test fail? ###
132 use constant TEST_FAIL_STAGE
133 => sub {
134 my $buffer = shift or return;
135 return $buffer =~ /(MAKE [A-Z]+).*/
136 ? lc $1 :
137 'fetch';
138 };
139  
140  
141 use constant MISSING_PREREQS_LIST
142 => sub {
143 my $buffer = shift;
144 my $last = ( split /\[ERROR\] .+? MAKE TEST/, $buffer )[-1];
145 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 { my %seen;
152 @list = grep { !$seen{$_}++ } @list
153 }
154  
155 return @list;
156 };
157  
158 use constant MISSING_EXTLIBS_LIST
159 => sub {
160 my $buffer = shift;
161 my @list =
162 ($buffer =~
163 m/No library found for -l([-\w]+)/g);
164  
165 return @list;
166 };
167  
168 use constant REPORT_MESSAGE_HEADER
169 => sub {
170 my ($version, $author) = @_;
171 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 };
181  
182 use constant REPORT_MESSAGE_FAIL_HEADER
183 => sub {
184 my($stage, $buffer) = @_;
185 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 };
198  
199 use constant REPORT_MESSAGE_PASS_HEADER
200 => sub {
201 my($stage, $buffer) = @_;
202 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 };
215  
216 use constant REPORT_MISSING_PREREQS
217 => sub {
218 my ($author,$email,@missing) = @_;
219 $author = ($author && $email)
220 ? "$author ($email)"
221 : 'Your Name Here';
222  
223 my $modules = join "\n", @missing;
224 my $prereqs = join "\n",
225 map {"\t'$_'\t=> '0',".
226 " # or a minimum working version"}
227 @missing;
228  
229 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 };
252  
253 use constant REPORT_MISSING_TESTS
254 => sub {
255 return << ".";
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__