module skeleton
[catagits/Catalyst-Manual-Monthly.git] / t / boilerplate.t
CommitLineData
7784ea92 1#!perl -T
2
3use 5.006;
4use strict;
5use warnings;
6use Test::More tests => 3;
7
8sub 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
31sub module_boilerplate_ok {
32 my ($module) = @_;
33 not_in_file_ok($module =>
34 'the great new $MODULENAME' => qr/ - The great new /,
35 'boilerplate description' => qr/Quick summary of what the module/,
36 'stub function definition' => qr/function[12]/,
37 );
38}
39
40TODO: {
41 local $TODO = "Need to replace the boilerplate text";
42
43 not_in_file_ok(README =>
44 "The README is used..." => qr/The README is used/,
45 "'version information here'" => qr/to provide version information/,
46 );
47
48 not_in_file_ok(Changes =>
49 "placeholder date/time" => qr(Date/time)
50 );
51
52 module_boilerplate_ok('lib/Catalyst/Manual/Monthly.pm');
53
54
55}
56