/usr/share/perl5/Test/Kwalitee.pm is in libtest-kwalitee-perl 1.01-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | package Test::Kwalitee;
use Cwd;
use Test::Builder;
use Module::CPANTS::Analyse;
use strict;
use warnings;
use vars qw( $Test $VERSION );
$VERSION = '1.01';
BEGIN { $Test = Test::Builder->new() }
my %test_types;
BEGIN
{
%test_types =
(
extractable => 'distribution is extractable',
has_readme => 'distribution has a readme file',
has_manifest => 'distribution has a MANIFEST',
has_meta_yml => 'distribution has a META.yml file',
has_buildtool => 'distribution has a build tool file',
has_changelog => 'distribution has a changelog',
no_symlinks => 'distribution has no symlinks',
has_tests => 'distribution has tests',
proper_libs => 'distribution has proper libs',
no_pod_errors => 'distribution has no POD errors',
use_strict => 'distribution files all use strict',
has_test_pod => 'distribution has a POD test file',
has_test_pod_coverage => 'distribution has a POD-coverage test file',
);
# These three don't really work unless you have a tarball, so skip them for now
# extracts_nicely => 'distribution extracts nicely',
# has_version => 'distribution has a version',
# has_proper_version => 'distribution has a proper version',
while (my ($subname, $diagnostic) = each %test_types)
{
my $sub = sub
{
my ($dist, $metric) = @_;
$Test->ok( $metric->{code}->( $dist ), $subname, $diagnostic ) ||
$Test->diag( @{ $metric }{qw( remedy error )} );
};
no strict 'refs';
*{ $subname } = $sub;
}
}
sub import
{
my ($class, %args) = @_;
$args{basedir} ||= cwd();
$args{tests} ||= [];
my @tests = @{ $args{tests} } ?
@{ $args{tests} } : keys %test_types;
@tests = keys %test_types if grep { /^-/ } @tests;
my %run_tests;
for my $test ( @tests, @{ $args{tests} } )
{
if ( $test =~ s/^-// )
{
delete $run_tests{$test};
}
else
{
$run_tests{$test} = 1;
}
}
my $analyzer = Module::CPANTS::Analyse->new({
distdir => $args{basedir},
dist => $args{basedir},
});
$Test->plan( tests => scalar keys %run_tests );
for my $generator (@{ $analyzer->mck()->generators() } )
{
next if $generator =~ /Unpack/;
next if $generator =~ /CPAN$/;
next if $generator =~ /Authors$/;
# no distname, so no warnings here
{
local $^W;
$generator->analyse($analyzer);
}
for my $indicator (@{ $generator->kwalitee_indicators() })
{
next unless $run_tests{ $indicator->{name} };
my $sub = __PACKAGE__->can( $indicator->{name} );
next unless $sub;
$sub->( $analyzer->d(), $indicator );
}
}
}
1;
__END__
=head1 NAME
Test::Kwalitee - test the Kwalitee of a distribution before you release it
=head1 SYNOPSIS
# in a separate test file
use Test::More;
eval { require Test::Kwalitee; Test::Kwalitee->import() };
plan( skip_all => 'Test::Kwalitee not installed; skipping' ) if $@;
=head1 DESCRIPTION
Kwalitee is an automatically-measurable gauge of how good your software is.
That's very different from quality, which a computer really can't measure in a
general sense. (If you can, you've solved a hard problem in computer science.)
In the world of the CPAN, the CPANTS project (CPAN Testing Service; also a
funny acronym on its own) measures Kwalitee with several metrics. If you plan
to release a distribution to the CPAN -- or even within your own organization
-- testing its Kwalitee before creating a release can help you improve your
quality as well.
C<Test::Kwalitee> and a short test file will do this for you automatically.
=head1 USAGE
Create a test file as shown in the synopsis. Run it. It will run all of the
potential Kwalitee tests on the current distribution, if possible. If any
fail, it will report those as regular diagnostics.
If you ship this test and a user does not have C<Test::Kwalitee> installed,
nothing bad will happen.
To run only a handful of tests, pass their names to the module's C<import()>
method:
eval
{
require Test::Kwalitee;
Test::Kwalitee->import( tests => [ qw( use_strict has_tests ) ] );
};
To disable a test, pass its name with a leading minus (C<->) to C<import()>:
eval
{
require Test::Kwalitee;
Test::Kwalitee->import( tests =>
[ qw( -has_test_pod -has_test_pod_coverage ) ]
);
};
As of version 1.00, the tests include:
=over 4
=item * extractable
Is the distribution extractable?
=item * has_readme
Does the distribution have a F<README> file?
=item * have_manifest
Does the distribution have a F<MANIFEST>?
=item * have_meta_yml
Does the distribution have a F<META.yml> file?
=item * have_buildtool
Does the distribution have a build tool file?
=item * have_changelog
Does the distribution have a changelog?
=item * no_symlinks
Does the distribution have no symlinks?
=item * have_tests
Does the distribution have tests?
=item * proper_libs
Does the distribution have proper libs?
=item * no_pod_errors
Does the distribution have no POD errors?
=item * use_strict
Does the distribution files all use strict?
=item * have_test_pod
Does the distribution have a POD test file?
=item * have_test_pod_coverage
Does the distribution have a POD-coverage test file?
=back
=head1 AUTHOR
chromatic, E<lt>chromatic at wgz dot orgE<gt>
With thanks to CPANTS and Thomas Klausner, as well as test tester Chris Dolan.
=head1 BUGS
No known bugs.
=head1 COPYRIGHT
Copyright (c) 2005 - 2008, chromatic. Some rights reserved.
This module is free software; you can use, redistribute, and modify it under
the same terms as Perl 5.8.x.
|