File Coverage

blib/lib/Test/Apocalypse/FileChecks.pm
Criterion Covered Total %
statement 33 33 100.0
branch 2 4 50.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 42 45 93.3


line stmt bran cond sub pod time code
1             #
2             # This file is part of Test-Apocalypse
3             #
4             # This software is copyright (c) 2014 by Apocalypse.
5             #
6             # This is free software; you can redistribute it and/or modify it under
7             # the same terms as the Perl 5 programming language system itself.
8             #
9 38     38   4082270 use strict; use warnings;
  38     38   87  
  38         1300  
  38         195  
  38         42  
  38         1800  
10             package Test::Apocalypse::FileChecks;
11             $Test::Apocalypse::FileChecks::VERSION = '1.006';
12             BEGIN {
13 38     38   457 $Test::Apocalypse::FileChecks::AUTHORITY = 'cpan:APOCAL';
14             }
15              
16             # ABSTRACT: Plugin to test for file sanity
17              
18 38     38   153 use Test::More;
  38         40  
  38         256  
19 38     38   11663 use File::Find::Rule 0.32;
  38         7880  
  38         269  
20 38     38   21389 use Test::File 1.29;
  38         207552  
  38         18240  
21              
22             sub do_test {
23 37     37 0 222 my @files = qw( Changes Build.PL Makefile.PL LICENSE MANIFEST MANIFEST.SKIP README META.yml );
24 37         1221 my @pmfiles = File::Find::Rule->file()->name( qr/\.pm$/ )->in( 'lib' );
25              
26             # check SIGNATURE if it's there
27 37 50       62197 if ( -e 'SIGNATURE' ) {
28 37         148 push( @files, 'SIGNATURE' );
29             }
30              
31             # check META.json if it's there
32 37 50       296 if ( -e 'META.json' ) {
33 37         74 push( @files, 'META.json' );
34             }
35              
36 37         259 plan tests => ( ( scalar @files ) * 4 ) + ( ( scalar @pmfiles ) * 3 );
37              
38             # ensure our basic CPAN dist contains everything we need
39 37         6623 foreach my $f ( @files ) {
40 370         120028 file_exists_ok( $f, "file $f exists" );
41 370         132164 file_not_empty_ok( $f, "file $f got data" );
42 370         136604 file_readable_ok( $f, "file $f is readable" );
43 370         126207 file_not_executable_ok( $f, "file $f is not executable" );
44             }
45              
46             # check all *.pm files for executable too
47 37         13357 foreach my $f ( @pmfiles ) {
48 1332         454545 file_not_empty_ok( $f, "file $f got data" );
49 1332         496947 file_readable_ok( $f, "file $f is readable" );
50 1332         494801 file_not_executable_ok( $f, "file $f is not executable" );
51             }
52              
53 37         13986 return;
54             }
55              
56             1;
57              
58             __END__
59              
60             =pod
61              
62             =encoding UTF-8
63              
64             =for :stopwords Apocalypse Niebur Ryan dist
65              
66             =for Pod::Coverage do_test
67              
68             =head1 NAME
69              
70             Test::Apocalypse::FileChecks - Plugin to test for file sanity
71              
72             =head1 VERSION
73              
74             This document describes v1.006 of Test::Apocalypse::FileChecks - released October 25, 2014 as part of Test-Apocalypse.
75              
76             =head1 DESCRIPTION
77              
78             This plugin ensures basic sanity for the files in the dist.
79              
80             =head1 SEE ALSO
81              
82             Please see those modules/websites for more information related to this module.
83              
84             =over 4
85              
86             =item *
87              
88             L<Test::Apocalypse|Test::Apocalypse>
89              
90             =back
91              
92             =head1 AUTHOR
93              
94             Apocalypse <APOCAL@cpan.org>
95              
96             =head1 COPYRIGHT AND LICENSE
97              
98             This software is copyright (c) 2014 by Apocalypse.
99              
100             This is free software; you can redistribute it and/or modify it under
101             the same terms as the Perl 5 programming language system itself.
102              
103             The full text of the license can be found in the
104             F<LICENSE> file included with this distribution.
105              
106             =head1 DISCLAIMER OF WARRANTY
107              
108             THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
109             APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
110             HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
111             OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
112             THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
113             PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
114             IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
115             ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
116              
117             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
118             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
119             THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
120             GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
121             USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
122             DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
123             PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
124             EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
125             SUCH DAMAGES.
126              
127             =cut