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   4623257 use strict; use warnings;
  38     38   54  
  38         1344  
  38         157  
  38         76  
  38         1750  
10             package Test::Apocalypse::FileChecks;
11             $Test::Apocalypse::FileChecks::VERSION = '1.004';
12             BEGIN {
13 38     38   513 $Test::Apocalypse::FileChecks::AUTHORITY = 'cpan:APOCAL';
14             }
15              
16             # ABSTRACT: Plugin to test for file sanity
17              
18 38     38   154 use Test::More;
  38         82  
  38         313  
19 38     38   10379 use File::Find::Rule 0.32;
  38         10793  
  38         272  
20 38     38   20711 use Test::File 1.29;
  38         186369  
  38         15012  
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         1258 my @pmfiles = File::Find::Rule->file()->name( qr/\.pm$/ )->in( 'lib' );
25              
26             # check SIGNATURE if it's there
27 37 50       58016 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         296 plan tests => ( ( scalar @files ) * 4 ) + ( ( scalar @pmfiles ) * 3 );
37              
38             # ensure our basic CPAN dist contains everything we need
39 37         8103 foreach my $f ( @files ) {
40 370         104932 file_exists_ok( $f, "file $f exists" );
41 370         116328 file_not_empty_ok( $f, "file $f got data" );
42 370         121175 file_readable_ok( $f, "file $f is readable" );
43 370         116365 file_not_executable_ok( $f, "file $f is not executable" );
44             }
45              
46             # check all *.pm files for executable too
47 37         12062 foreach my $f ( @pmfiles ) {
48 1332         429237 file_not_empty_ok( $f, "file $f got data" );
49 1332         431864 file_readable_ok( $f, "file $f is readable" );
50 1332         427646 file_not_executable_ok( $f, "file $f is not executable" );
51             }
52              
53 37         13579 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.004 of Test::Apocalypse::FileChecks - released October 24, 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