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
|
# Declare our package
package Test::Apocalypse::FileChecks;
use strict; use warnings;
# Initialize our version
use vars qw( $VERSION );
$VERSION = '0.05';
use Test::More;
sub do_test {
my %MODULES = (
'File::Find::Rule' => '0.32',
'Test::File' => '1.29',
);
while (my ($module, $version) = each %MODULES) {
eval "use $module $version"; ## no critic ( ProhibitStringyEval )
next unless $@;
if ( $ENV{RELEASE_TESTING} ) {
die 'Could not load release-testing module ' . $module;
} else {
plan skip_all => $module . ' not available for testing';
}
}
# Run the test!
my @files = qw( Changes Build.PL Makefile.PL LICENSE MANIFEST MANIFEST.SKIP README META.yml );
my @pmfiles = File::Find::Rule->file()->name( '*.pm' )->in( 'lib' );
# check SIGNATURE if it's there
if ( -e 'SIGNATURE' ) {
push( @files, 'SIGNATURE' );
}
plan tests => ( ( scalar @files ) * 4 ) + ( ( scalar @pmfiles ) * 3 );
# ensure our basic CPAN dist contains everything we need
foreach my $f ( @files ) {
file_exists_ok( $f, "file $f exists" );
file_not_empty_ok( $f, "file $f got data" );
file_readable_ok( $f, "file $f is readable" );
file_not_executable_ok( $f, "file $f is not executable" );
}
# check all *.pm files for executable too
foreach my $f ( @pmfiles ) {
file_not_empty_ok( $f, "file $f got data" );
file_readable_ok( $f, "file $f is readable" );
file_not_executable_ok( $f, "file $f is not executable" );
}
return;
}
1;
__END__
=for stopwords dist
=head1 NAME
Test::Apocalypse::FileChecks - Plugin to test for file sanity
=head1 SYNOPSIS
# Please do not use this module directly.
=head1 ABSTRACT
This plugin ensures basic sanity for the files in the dist.
=head1 DESCRIPTION
This plugin ensures basic sanity for the files in the dist.
=head1 SEE ALSO
L<Test::Apocalypse>
L<Test::File>
=head1 AUTHOR
Apocalypse E<lt>apocal@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright 2009 by Apocalypse
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
|