Add CPANPLUS 0.78
[p5sagit/p5-mst-13.2.git] / lib / CPANPLUS / Internals / Constants / Report.pm
CommitLineData
6aaee015 1package CPANPLUS::Internals::Constants::Report;
2
3use strict;
4use CPANPLUS::Error;
5
6use File::Spec;
7use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
8
9require Exporter;
10use vars qw[$VERSION @ISA @EXPORT];
11
12use Package::Constants;
13
14
15$VERSION = 0.01;
16@ISA = qw[Exporter];
17@EXPORT = Package::Constants->list( __PACKAGE__ );
18
19### for the version
20require CPANPLUS::Internals;
21
22### OS to regex map ###
23my %OS = (
24 Amiga => 'amigaos',
25 Atari => 'mint',
26 BSD => 'bsdos|darwin|freebsd|openbsd|netbsd',
27 Be => 'beos',
28 BeOS => 'beos',
29 Cygwin => 'cygwin',
30 Darwin => 'darwin',
31 EBCDIC => 'os390|os400|posix-bc|vmesa',
32 HPUX => 'hpux',
33 Linux => 'linux',
34 MSDOS => 'dos|os2|MSWin32|cygwin',
35 'bin\\d*Mac'=> 'MacOS|darwin', # binMac, bin56Mac, bin58Mac...
36 Mac => 'MacOS|darwin',
37 MacPerl => 'MacOS',
38 MacOS => 'MacOS|darwin',
39 MacOSX => 'darwin',
40 MPE => 'mpeix',
41 MPEiX => 'mpeix',
42 OS2 => 'os2',
43 Plan9 => 'plan9',
44 RISCOS => 'riscos',
45 SGI => 'irix',
46 Solaris => 'solaris',
47 Unix => 'aix|bsdos|darwin|dgux|dynixptx|freebsd|'.
48 'linux|hpux|machten|netbsd|next|openbsd|dec_osf|'.
49 'svr4|sco_sv|unicos|unicosmk|solaris|sunos',
50 VMS => 'VMS',
51 VOS => 'VOS',
52 Win32 => 'MSWin32|cygwin',
53 Win32API => 'MSWin32|cygwin',
54);
55
56use constant GRADE_FAIL => 'fail';
57use constant GRADE_PASS => 'pass';
58use constant GRADE_NA => 'na';
59use constant GRADE_UNKNOWN => 'unknown';
60
61use constant MAX_REPORT_SEND
62 => 2;
63
64use constant CPAN_TESTERS_EMAIL
65 => 'cpan-testers@perl.org';
66
67### the cpan mail account for this user ###
68use constant CPAN_MAIL_ACCOUNT
69 => sub {
70 my $username = shift or return;
71 return $username . '@cpan.org';
72 };
73
74### check if this module is platform specific and if we're on that
75### specific platform. Alternately, the module is not platform specific
76### and we're always OK to send out test results.
77use constant RELEVANT_TEST_RESULT
78 => sub {
79 my $mod = shift or return;
80 my $name = $mod->module;
81 my $specific;
82 for my $platform (keys %OS) {
83 if( $name =~ /\b$platform\b/i ) {
84 # beware the Mac != MAC
85 next if($platform eq 'Mac' &&
86 $name !~ /\b$platform\b/);
87 $specific++;
88 return 1 if
89 $^O =~ /^(?:$OS{$platform})$/
90 }
91 };
92 return $specific ? 0 : 1;
93 };
94
95use constant UNSUPPORTED_OS
96 => sub {
97 my $buffer = shift or return;
98 if( $buffer =~
99 /No support for OS|OS unsupported/im ) {
100 return 1;
101 }
102 return 0;
103 };
104
105use constant PERL_VERSION_TOO_LOW
106 => sub {
107 my $buffer = shift or return;
108 # ExtUtils::MakeMaker format
109 if( $buffer =~
110 /Perl .*? required--this is only .*?/m ) {
111 return 1;
112 }
113 # Module::Build format
114 if( $buffer =~
115 /ERROR:( perl:)? Version .*?( of perl)? is installed, but we need version >= .*?/m ) {
116 return 1;
117 }
118 return 0;
119 };
120
121use constant NO_TESTS_DEFINED
122 => sub {
123 my $buffer = shift or return;
124 if( $buffer =~
125 /(No tests defined( for [\w:]+ extension)?\.)/
126 and $buffer !~ /\*\.t/m and
127 $buffer !~ /test\.pl/m
128 ) {
129 return $1
130 }
131
132 return;
133 };
134
135### what stage did the test fail? ###
136use constant TEST_FAIL_STAGE
137 => sub {
138 my $buffer = shift or return;
139 return $buffer =~ /(MAKE [A-Z]+).*/
140 ? lc $1 :
141 'fetch';
142 };
143
144
145use constant MISSING_PREREQS_LIST
146 => sub {
147 my $buffer = shift;
148 my @list = map { s/.pm$//; s|/|::|g; $_ }
149 ($buffer =~
150 m/\bCan\'t locate (\S+) in \@INC/g);
151
152 ### make sure every missing prereq is only
153 ### listed ones
154 { my %seen;
155 @list = grep { !$seen{$_}++ } @list
156 }
157
158 return @list;
159 };
160
161use constant MISSING_EXTLIBS_LIST
162 => sub {
163 my $buffer = shift;
164 my @list =
165 ($buffer =~
166 m/No library found for -l([-\w]+)/g);
167
168 return @list;
169 };
170
171use constant REPORT_MESSAGE_HEADER
172 => sub {
173 my ($version, $author) = @_;
174 return << ".";
175
176Dear $author,
177
178This is a computer-generated error report created automatically by
179CPANPLUS, version $version. Testers personal comments may appear
180at the end of this report.
181
182.
183 };
184
185use constant REPORT_MESSAGE_FAIL_HEADER
186 => sub {
187 my($stage, $buffer) = @_;
188 return << ".";
189
190Thank you for uploading your work to CPAN. However, it appears that
191there were some problems testing your distribution.
192
193TEST RESULTS:
194
195Below is the error stack from stage '$stage':
196
197$buffer
198
199.
200 };
201
202use constant REPORT_MISSING_PREREQS
203 => sub {
204 my ($author,$email,@missing) = @_;
205 $author = ($author && $email)
206 ? "$author ($email)"
207 : 'Your Name Here';
208
209 my $modules = join "\n", @missing;
210 my $prereqs = join "\n",
211 map {"\t'$_'\t=> '0',".
212 " # or a minimum working version"}
213 @missing;
214
215 return << ".";
216
217MISSING PREREQUISITES:
218
219It was observed that the test suite seem to fail without these modules:
220
221$modules
222
223As such, adding the prerequisite module(s) to 'PREREQ_PM' in your
224Makefile.PL should solve this problem. For example:
225
226WriteMakefile(
227 AUTHOR => '$author',
228 ... # other information
229 PREREQ_PM => {
230$prereqs
231 }
232);
233
234If you are interested in making a more flexible Makefile.PL that can
235probe for missing dependencies and install them, ExtUtils::AutoInstall
236at <http://search.cpan.org/dist/ExtUtils-AutoInstall/> may be
237worth a look.
238
239Thanks! :-)
240
241.
242 };
243
244use constant REPORT_MISSING_TESTS
245 => sub {
246 return << ".";
247RECOMMENDATIONS:
248
249It would be very helpful if you could include even a simple test
250script in the next release, so people can verify which platforms
251can successfully install them, as well as avoid regression bugs?
252
253A simple 't/use.t' that says:
254
255#!/usr/bin/env perl -w
256use strict;
257use Test;
258BEGIN { plan tests => 1 }
259
260use Your::Module::Here; ok(1);
261exit;
262__END__
263
264would be appreciated. If you are interested in making a more robust
265test suite, please see the Test::Simple, Test::More and Test::Tutorial
266documentation at <http://search.cpan.org/dist/Test-Simple/>.
267
268Thanks! :-)
269
270.
271 };
272
273use constant REPORT_LOADED_PREREQS
274 => sub {
275 my $mod = shift;
276 my $cb = $mod->parent;
277 my $prq = $mod->status->prereqs || {};
278
279 ### not every prereq may be coming from CPAN
280 ### so maybe we wont find it in our module
281 ### tree at all...
282 ### skip ones that cant be found in teh list
283 ### as reported in #12723
284 my @prq = grep { defined }
285 map { $cb->module_tree($_) }
286 sort keys %$prq;
287
288 ### no prereqs?
289 return '' unless @prq;
290
291 ### some apparently, list what we loaded
292 my $str = << ".";
293PREREQUISITES:
294
295Here is a list of prerequisites you specified and versions we
296managed to load:
297
298.
299 $str .= join '',
300 map { my $want = $prq->{$_->name};
301
302 sprintf "\t%s %-30s %8s %8s\n",
303 do { $_->is_uptodate(
304 version => $want
305 ) ? ' ' : '!'
306 },
307 $_->name,
308 $_->installed_version,
309 $want
310
311 ### might be empty entries in there
312 } grep { defined $_ } @prq;
313
314 return $str;
315 };
316
317use constant REPORT_TESTS_SKIPPED
318 => sub {
319 return << ".";
320
321******************************** NOTE ********************************
322*** ***
323*** The tests for this module were skipped during this build ***
324*** ***
325**********************************************************************
326
327.
328 };
329
330use constant REPORT_MESSAGE_FOOTER
331 => sub {
332 return << ".";
333
334******************************** NOTE ********************************
335The comments above are created mechanically, possibly without manual
336checking by the sender. As there are many people performing automatic
337tests on each upload to CPAN, it is likely that you will receive
338identical messages about the same problem.
339
340If you believe that the message is mistaken, please reply to the first
341one with correction and/or additional informations, and do not take
342it personally. We appreciate your patience. :)
343**********************************************************************
344
345Additional comments:
346
347.
348 };
349
3501;
351
352# Local variables:
353# c-indentation-style: bsd
354# c-basic-offset: 4
355# indent-tabs-mode: nil
356# End:
357# vim: expandtab shiftwidth=4: