]> git.vpit.fr Git - perl/modules/Linux-SysInfo.git/blob - t/boilerplate.t
Makefile.PL beautification. 'make clean' should remove coverage files
[perl/modules/Linux-SysInfo.git] / t / boilerplate.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 3;
7
8 sub not_in_file_ok {
9     my ($filename, %regex) = @_;
10     open my $fh, "<", $filename
11         or die "couldn't open $filename for reading: $!";
12
13     my %violated;
14
15     while (my $line = <$fh>) {
16         while (my ($desc, $regex) = each %regex) {
17             if ($line =~ $regex) {
18                 push @{$violated{$desc}||=[]}, $.;
19             }
20         }
21     }
22
23     if (%violated) {
24         fail("$filename contains boilerplate text");
25         diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
26     } else {
27         pass("$filename contains no boilerplate text");
28     }
29 }
30
31 not_in_file_ok(README =>
32     "The README is used..."       => qr/The README is used/,
33     "'version information here'"  => qr/to provide version information/,
34 );
35
36 not_in_file_ok(Changes =>
37     "placeholder date/time"       => qr(Date/time)
38 );
39
40 sub module_boilerplate_ok {
41     my ($module) = @_;
42     not_in_file_ok($module =>
43         'the great new $MODULENAME'   => qr/ - The great new /,
44         'boilerplate description'     => qr/Quick summary of what the module/,
45         'stub function definition'    => qr/function[12]/,
46     );
47 }
48
49 module_boilerplate_ok('lib/Linux/SysInfo.pm');