Move CPANPLUS from lib/ to ext/
[p5sagit/p5-mst-13.2.git] / ext / CPANPLUS / 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
4443dd53 14### for the version
15require CPANPLUS::Internals;
6aaee015 16
4443dd53 17$VERSION = $CPANPLUS::Internals::VERSION = $CPANPLUS::Internals::VERSION;
6aaee015 18@ISA = qw[Exporter];
19@EXPORT = Package::Constants->list( __PACKAGE__ );
20
6aaee015 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
6aaee015 234Thanks! :-)
235
236.
237 };
238
239use constant REPORT_MISSING_TESTS
240 => sub {
241 return << ".";
242RECOMMENDATIONS:
243
244It would be very helpful if you could include even a simple test
245script in the next release, so people can verify which platforms
246can successfully install them, as well as avoid regression bugs?
247
248A simple 't/use.t' that says:
249
250#!/usr/bin/env perl -w
251use strict;
252use Test;
253BEGIN { plan tests => 1 }
254
255use Your::Module::Here; ok(1);
256exit;
257__END__
258
259would be appreciated. If you are interested in making a more robust
260test suite, please see the Test::Simple, Test::More and Test::Tutorial
261documentation at <http://search.cpan.org/dist/Test-Simple/>.
262
263Thanks! :-)
264
265.
266 };
267
268use constant REPORT_LOADED_PREREQS
269 => sub {
270 my $mod = shift;
271 my $cb = $mod->parent;
272 my $prq = $mod->status->prereqs || {};
273
274 ### not every prereq may be coming from CPAN
275 ### so maybe we wont find it in our module
276 ### tree at all...
277 ### skip ones that cant be found in teh list
278 ### as reported in #12723
279 my @prq = grep { defined }
280 map { $cb->module_tree($_) }
281 sort keys %$prq;
282
283 ### no prereqs?
284 return '' unless @prq;
285
286 ### some apparently, list what we loaded
287 my $str = << ".";
288PREREQUISITES:
289
290Here is a list of prerequisites you specified and versions we
291managed to load:
292
293.
294 $str .= join '',
622d31ac 295 map { sprintf "\t%s %-30s %8s %8s\n",
296 @$_
297
298 } [' ', 'Module Name', 'Have', 'Want'],
299 map { my $want = $prq->{$_->name};
300 [ do { $_->is_uptodate(
6aaee015 301 version => $want
302 ) ? ' ' : '!'
622d31ac 303 },
304 $_->name,
305 $_->installed_version,
306 $want
307 ],
6aaee015 308 ### might be empty entries in there
309 } grep { defined $_ } @prq;
310
311 return $str;
312 };
313
314use constant REPORT_TESTS_SKIPPED
315 => sub {
316 return << ".";
317
318******************************** NOTE ********************************
319*** ***
320*** The tests for this module were skipped during this build ***
321*** ***
322**********************************************************************
323
324.
325 };
326
327use constant REPORT_MESSAGE_FOOTER
328 => sub {
329 return << ".";
330
331******************************** NOTE ********************************
332The comments above are created mechanically, possibly without manual
333checking by the sender. As there are many people performing automatic
334tests on each upload to CPAN, it is likely that you will receive
335identical messages about the same problem.
336
337If you believe that the message is mistaken, please reply to the first
338one with correction and/or additional informations, and do not take
339it personally. We appreciate your patience. :)
340**********************************************************************
341
342Additional comments:
343
344.
345 };
346
3471;
348
349# Local variables:
350# c-indentation-style: bsd
351# c-basic-offset: 4
352# indent-tabs-mode: nil
353# End:
354# vim: expandtab shiftwidth=4: