-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTestingMania.pm
More file actions
251 lines (178 loc) · 7.2 KB
/
TestingMania.pm
File metadata and controls
251 lines (178 loc) · 7.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
package Dist::Zilla::PluginBundle::TestingMania;
# ABSTRACT: test your dist with every testing plugin conceivable
use strict;
use warnings;
# VERSION
use List::Util 1.33 qw( any );
use Moose;
use namespace::autoclean;
with 'Dist::Zilla::Role::PluginBundle::Easy';
=head1 SYNOPSIS
In F<dist.ini>:
[@TestingMania]
=for test_synopsis
1;
__END__
=head1 DESCRIPTION
This plugin bundle collects all the testing plugins for L<Dist::Zilla> which
exist (and are not deprecated). This is for the most paranoid people who
want to test their dist seven ways to Sunday.
Simply add the following near the end of F<dist.ini>:
[@TestingMania]
=head2 Testing plugins
=over 4
=item *
L<Dist::Zilla::Plugin::Test::Compile>, which performs tests to syntax check your
dist.
=item *
L<Dist::Zilla::Plugin::Test::Perl::Critic>, which checks your code against best
practices. See L<Test::Perl::Critic> and L<Perl::Critic> for details.
You can set a perlcritic config file:
[@TestingMania]
critic_config = perlcriticrc
=item *
L<Dist::Zilla::Plugin::Test::DistManifest>, which tests F<MANIFEST> for
correctness. See L<Test::DistManifest> for details.
=item *
L<Dist::Zilla::Plugin::Test::EOL>, which ensures the correct line endings are
used (and also checks for trailing whitespace). See L<Test::EOL> for details.
=item *
L<Dist::Zilla::Plugin::Test::Version>, which tests that your dist has
version numbers, and that they are valid. See L<Test::Version> for exactly
what that means.
You can set C<strict_version> and C<has_version>, and they'll be passed through to
the plugin as C<is_strict> and C<has_version> respectively. See the
documentation of L<Test::Version> for a description of these options.
=item *
L<Dist::Zilla::Plugin::Test::Kwalitee>, which performs some basic kwalitee checks.
I<Kwalitee> is an automatically-measurable guage of how good your software is.
It bears only a B<superficial> resemblance to the human-measurable guage of
actual quality. See L<Test::Kwalitee> for a description of the tests.
=item *
L<Dist::Zilla::Plugin::MetaTests>, which performs some extra tests on
F<META.yml>. See L<Test::CPAN::Meta> for what that means.
=item *
L<Dist::Zilla::Plugin::Test::CPAN::Meta::JSON>, which performs some extra tests
on F<META.json>, if it exists. See L<Test::CPAN::Meta::JSON> for what that
means.
=item *
L<Dist::Zilla::Plugin::Test::MinimumVersion>, which tests for the minimum
required version of perl. Give the highest version of perl you intend to
require as C<max_target_perl>. The generated test will fail if you accidentally
used features from a version of perl newer than that. See
L<Test::MinimumVersion> for details and limitations.
=item *
L<Dist::Zilla::Plugin::MojibakeTests>, which tests for the correct
source/documentation character encoding.
=item *
L<Dist::Zilla::Plugin::Test::NoTabs>, which ensures you don't use I<The Evil
Character>. See L<Test::NoTabs> for details. If you wish to exclude this plugin,
see L</"Disabling Tests">.
=item *
L<Dist::Zilla::Plugin::PodCoverageTests>, which checks that you have Pod
documentation for the things you should have it for. See L<Test::Pod::Coverage>
for what that means.
=item *
L<Dist::Zilla::Plugin::PodSyntaxTests>, which checks that your Pod is
well-formed. See L<Test::Pod> and L<perlpod> for details.
=item *
L<Dist::Zilla::Plugin::Test::Portability>, which performs some basic tests to
ensure portability of file names. See L<Test::Portability::Files> for what
that means.
=item *
L<Dist::Zilla::Plugin::Test::Synopsis>, which does syntax checking on the code
from your SYNOPSIS section. See L<Test::Synopsis> for details and limitations.
=item *
L<Dist::Zilla::Plugin::Test::UnusedVars>, which checks your dist for unused
variables. See L<Test::Vars> for details.
=item *
L<Dist::Zilla::Plugin::Test::Pod::LinkCheck>, which checks the links in your POD.
See L<Test::Pod::LinkCheck> for details.
=item *
L<Dist::Zilla::Plugin::Test::CPAN::Changes>, which checks your changelog for
conformance with L<CPAN::Changes::Spec>. See L<Test::CPAN::Changes> for details.
Set C<changelog> in F<dist.ini> if you don't use F<Changes>:
[@TestingMania]
changelog = CHANGELOG
=back
=head2 Disabling Tests
To exclude a testing plugin, specify them with C<disable> in F<dist.ini>
[@TestingMania]
disable = Test::DistManifest
disable = Test::Kwalitee
=head2 Enabling Tests
This pluginbundle may have some testing plugins that aren't
enabled by default. This option allows you to turn them on. Attempting to add
plugins which are not listed above will have I<no effect>.
To enable a testing plugin, specify them in F<dist.ini>:
[@TestingMania]
enable = Test::Compile
=for Pod::Coverage configure mvp_multivalue_args
=cut
has enable => (
is => 'ro',
isa => 'ArrayRef[Str]',
lazy => 1,
default => sub { $_[0]->payload->{enable} || [] },
);
has disable => (
is => 'ro',
isa => 'ArrayRef[Str]',
lazy => 1,
default => sub { $_[0]->payload->{disable} || [] },
);
sub mvp_multivalue_args { qw(enable disable) }
sub configure {
my $self = shift;
my %plugins = (
'Test::CPAN::Changes' => $self->config_slice('changelog'),
'Test::CPAN::Meta::JSON'=> 1, # prunes itself if META.json isn't there
'Test::Pod::LinkCheck' => 1,
'Test::Version' => $self->config_slice('has_version', { strict_version => 'is_strict' }),
'Test::Compile' => 1,
'Test::Perl::Critic' => $self->config_slice('critic_config'),
'Test::DistManifest' => 1,
'Test::EOL' => 1,
'Test::Kwalitee' => 1,
MetaTests => 1, # should only be loaded if MetaYAML is loaded, or the file exists in the dist
'Test::MinimumVersion' => $self->config_slice('max_target_perl'),
MojibakeTests => 1,
'Test::NoTabs' => 1,
PodCoverageTests => 1,
PodSyntaxTests => 1,
'Test::Portability' => 1,
'Test::Synopsis' => 1,
'Test::UnusedVars' => 1,
);
my %synonyms = (
'NoTabsTests' => 'Test::NoTabs',
'EOLTests' => 'Test::EOL',
);
my @include = ();
my @disable =
map { $synonyms{$_} ? $synonyms{$_} : $_ }
map { (split /,\s?/, $_) }
@{ $self->disable };
foreach my $plugin (keys %plugins) {
next if ( # Skip...
any { $_ eq $plugin } @disable or # plugins they asked to skip
any { $_ eq $plugin } @include or # plugins we already included
!$plugins{$plugin} # plugins in the list, but which we don't want to add
);
push(@include, ref $plugins{$plugin}
? [ $plugin => $plugins{$plugin} ]
: $plugin);
}
my @enable =
map { $synonyms{$_} ? $synonyms{$_} : $_ }
map { (split /,\s?/, $_) }
@{ $self->enable };
foreach my $plugin (@enable) {
next unless any { $_ eq $plugin } %plugins; # Skip the plugin unless it is in the list of actual testing plugins
push(@include, $plugin) unless ( any { $_ eq $plugin } @include or any { $_ eq $plugin } @disable);
}
$self->add_plugins(@include);
}
__PACKAGE__->meta->make_immutable();
no Moose;
1;