Login
No longer generating the PolicySummary when running the "test" action.
[gknop/Perl-Critic.git] / inc / Perl / Critic / BuildUtilities.pm
CommitLineData
34cc6052
ES
1##############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7
8package Perl::Critic::BuildUtilities;
9
df6dee2b 10use 5.006001;
34cc6052
ES
11use strict;
12use warnings;
13
7963ad6d 14use English q<-no_match_vars>;
70f3f307 15
9b6b3b02 16our $VERSION = '1.105_01';
34cc6052
ES
17
18use base qw{ Exporter };
19
496afbe0 20our @EXPORT_OK = qw<
26dc721f
ES
21 required_module_versions
22 build_required_module_versions
70f3f307
ES
23 recommended_module_versions
24 test_wrappers_to_generate
496afbe0 25 get_PL_files
70f3f307 26 dump_unlisted_or_optional_module_versions
7963ad6d 27 emit_tar_warning_if_necessary
496afbe0
ES
28>;
29
30
7963ad6d
ES
31use Devel::CheckOS qw< os_is >;
32
34cc6052 33
26dc721f
ES
34sub required_module_versions {
35 return (
36 'B::Keywords' => 1.05,
37 'Carp' => 0,
38 'Config::Tiny' => 2,
39 'English' => 0,
40 'Exception::Class' => 1.23,
41 'Exporter' => 0,
42 'File::Basename' => 0,
43 'File::Find' => 0,
44 'File::Path' => 0,
45 'File::Spec' => 0,
46 'File::Spec::Unix' => 0,
47 'File::Temp' => 0,
48 'Getopt::Long' => 0,
49 'IO::String' => 0,
d7a56cc3 50 'List::MoreUtils' => 0.19,
26dc721f
ES
51 'List::Util' => 0,
52 'Module::Pluggable' => 3.1,
fab47f2e
TW
53 'PPI' => '1.208',
54 'PPI::Document' => '1.208',
55 'PPI::Document::File' => '1.208',
56 'PPI::Node' => '1.208',
57 'PPI::Token::Quote::Single' => '1.208',
58 'PPI::Token::Whitespace' => '1.208',
26dc721f
ES
59 'Pod::PlainText' => 0,
60 'Pod::Select' => 0,
61 'Pod::Usage' => 0,
62 'Readonly' => 1.03,
63 'Scalar::Util' => 0,
64 'String::Format' => 1.13,
76d741ca 65 'Test::Builder' => 0.92,
26dc721f
ES
66 'base' => 0,
67 'charnames' => 0,
68 'overload' => 0,
69 'strict' => 0,
70 'version' => 0,
71 'warnings' => 0,
72 'overload' => 0,
73 'strict' => 0,
74 'version' => 0,
75 'warnings' => 0,
76 );
77}
78
79
80sub build_required_module_versions {
81 return (
82 'lib' => 0,
83 'Test::More' => 0,
84 );
85}
86
87
34cc6052
ES
88sub recommended_module_versions {
89 return (
6bacb99c 90 'Email::Address' => '1.889',
34cc6052
ES
91 'File::HomeDir' => 0,
92 'Perl::Tidy' => 0,
eb6e0777 93 'Readonly::XS' => 0,
5d6f7fbc 94 'PPIx::Regexp' => 0,
bf14ed6c
ES
95
96 # If the following changes, the corresponding change needs to be made
26185e38 97 # in $Perl::Critic::Utils::Constants::_MODULE_VERSION_TERM_ANSICOLOR.
bf14ed6c 98 'Term::ANSIColor' => '2.02',
34cc6052
ES
99
100 # All of these are for Documentation::PodSpelling
101 'File::Which' => 0,
102 'IPC::Open2' => 1,
103 'Pod::Spell' => 1,
104 'Text::ParseWords' => 3,
105 );
106}
107
496afbe0 108
34cc6052 109sub test_wrappers_to_generate {
70f3f307 110 my @tests_to_be_wrapped = qw<
34cc6052
ES
111 t/00_modules.t
112 t/01_config.t
113 t/01_config_bad_perlcriticrc.t
2798ab37 114 t/01_policy_config.t
34cc6052
ES
115 t/02_policy.t
116 t/03_pragmas.t
34c9f396 117 t/04_options_processor.t
34cc6052
ES
118 t/05_utils.t
119 t/05_utils_ppi.t
0d512192 120 t/05_utils_pod.t
34cc6052 121 t/06_violation.t
2560297d 122 t/07_command.t
34cc6052
ES
123 t/07_perlcritic.t
124 t/08_document.t
125 t/09_theme.t
34c9f396
JRT
126 t/10_user_profile.t
127 t/11_policy_factory.t
128 t/12_policy_listing.t
129 t/12_theme_listing.t
34cc6052
ES
130 t/13_bundled_policies.t
131 t/14_policy_parameters.t
132 t/15_statistics.t
2a6eef29 133 t/20_policies.t
492ab247 134 t/20_policy_pod_spelling.t
6a181acf
ES
135 t/20_policy_prohibit_evil_modules.t
136 t/20_policy_prohibit_hard_tabs.t
137 t/20_policy_prohibit_trailing_whitespace.t
138 t/20_policy_require_consistent_newlines.t
139 t/20_policy_require_interpolation_of_metachars.t
492ab247 140 t/20_policy_require_tidy_code.t
0d512192 141 xt/author/80_policysummary.t
34cc6052 142 t/92_memory_leaks.t
0d512192 143 xt/author/94_includes.t
70f3f307 144 >;
34cc6052
ES
145
146 return
147 map
0d512192 148 { "xt/author/generated/${_}_without_optional_dependencies.t" }
34cc6052
ES
149 @tests_to_be_wrapped;
150}
151
8ddad51b 152my @TARGET_FILES = qw<
8ddad51b 153 t/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.run
d33d2185 154 t/NamingConventions/Capitalization.run
8ddad51b
ES
155 t/Variables/RequireLocalizedPunctuationVars.run
156>;
157
496afbe0 158sub get_PL_files {
8ddad51b 159 my %PL_files = map { ( "$_.PL" => $_ ) } @TARGET_FILES;
6d34b243 160
90806b21 161 $PL_files{'xt/author/generate_without_optional_dependencies_wrappers.PL'} =
0d512192 162 [ test_wrappers_to_generate() ];
496afbe0 163
6d34b243 164 return \%PL_files;
496afbe0
ES
165}
166
70f3f307
ES
167sub dump_unlisted_or_optional_module_versions {
168 print
169 "\nVersions of optional/unlisted/indirect dependencies:\n\n";
170
171 my @unlisted_modules = (
172 qw<
70f3f307
ES
173 >,
174 keys %{ { recommended_module_versions() } },
175 );
176
177 foreach my $module (sort @unlisted_modules) {
178 my $version;
179
910d5187 180 if ($module eq 'Readonly::XS') {
f56c0ad2 181 eval 'use Readonly; use Readonly::XS; $version = $Readonly::XS::VERSION;';
910d5187
ES
182 }
183 else {
184 eval "use $module; \$version = \$${module}::VERSION;";
185 }
70f3f307
ES
186 if ($EVAL_ERROR) {
187 $version = 'not installed';
188 } elsif (not defined $version) {
189 $version = 'undef';
190 }
191
192 print " $module = $version\n";
193 }
194
195 print "\n";
196
197 return;
198}
34cc6052 199
7963ad6d
ES
200sub emit_tar_warning_if_necessary {
201 if ( os_is( qw<Solaris> ) ) {
202 print <<'END_OF_TAR_WARNING';
203NOTE: tar(1) on some Solaris systems cannot deal well with long file
204names.
205
206If you get warnings about missing files below, please ensure that you
207extracted the Perl::Critic tarball using GNU tar.
208
209END_OF_TAR_WARNING
210 }
211}
212
b005b12c
ES
213
214
215
34cc6052
ES
2161;
217
218__END__
219
220=head1 NAME
221
222Perl::Critic::BuildUtilities - Common bits of compiling Perl::Critic.
223
224
225=head1 DESCRIPTION
226
227Various utilities used in assembling Perl::Critic, primary for use by
228*.PL programs that generate code.
229
230
231=head1 IMPORTABLE SUBROUTINES
232
233=over
234
235=item C<recommended_module_versions()>
236
237Returns a hash mapping between recommended (but not required) modules
238for Perl::Critic and the minimum version required of each module,
239
240
241=item C<test_wrappers_to_generate()>
242
243Returns a list of test wrappers to be generated by
90806b21 244F<xt/author/generate_without_optional_dependencies_wrappers.PL>.
34cc6052 245
496afbe0
ES
246
247=item C<get_PL_files()>
248
249Returns a reference to a hash with a mapping from the name of a .PL
250program to an array of the parameters to be passed to it, suited for
251use by L<Module::Build::API/"PL_files"> or
252L<ExtUtils::MakeMaker/"PL_FILES">. May print to C<STDOUT> messages
253about what it is doing.
254
255
70f3f307
ES
256=item C<dump_unlisted_or_optional_module_versions()>
257
258Prints to C<STDOUT> a list of all the unlisted (e.g. things in core
11f53956
ES
259like L<Exporter|Exporter>), optional (e.g.
260L<File::Which|File::Which>), or potentially indirect (e.g.
261L<Readonly::XS|Readonly::XS>) dependencies, plus their versions, if
70f3f307
ES
262they're installed.
263
34cc6052 264
7963ad6d
ES
265=item C<emit_tar_warning_if_necessary()>
266
267On some Solaris systems, C<tar(1)> can't deal with long file names and
268thus files are not correctly extracted from the tarball. So this
269prints a warning if the current system is Solaris.
270
271
34cc6052
ES
272=back
273
274
275=head1 AUTHOR
276
277Elliot Shank C<< <perl@galumph.com> >>
278
279
280=head1 LICENCE AND COPYRIGHT
281
072692c8 282Copyright (c) 2007-2010, Elliot Shank C<< <perl@galumph.com> >>. All
7537474e 283rights reserved.
34cc6052
ES
284
285This program is free software; you can redistribute it and/or modify
286it under the same terms as Perl itself. The full text of this license
287can be found in the LICENSE file included with this module.
288
289=cut
290
291##############################################################################
292# Local Variables:
293# mode: cperl
294# cperl-indent-level: 4
295# fill-column: 78
296# indent-tabs-mode: nil
297# c-indentation-style: bsd
298# End:
96fed375 299# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :