File Coverage

t/boilerplate.t
Criterion Covered Total %
statement 24 29 82.7
branch 3 6 50.0
condition 0 2 0.0
subroutine 5 5 100.0
pod n/a
total 32 42 76.1


line stmt bran cond sub pod time code
1             #!perl -T
2              
3 1     1   5 use strict;
  1         1  
  1         30  
4 1     1   3 use warnings;
  1         1  
  1         20  
5 1     1   544 use Test::More tests => 3;
  1         13958  
  1         8  
6              
7             sub not_in_file_ok {
8 3     3   9 my ($filename, %regex) = @_;
9 3 50       83 open( my $fh, '<', $filename )
10             or die "couldn't open $filename for reading: $!";
11              
12 3         3 my %violated;
13              
14 3         34 while (my $line = <$fh>) {
15 1114         1867 while (my ($desc, $regex) = each %regex) {
16 3025 50       11345 if ($line =~ $regex) {
17 0   0     0 push @{$violated{$desc}||=[]}, $.;
  0         0  
18             }
19             }
20             }
21              
22 3 50       8 if (%violated) {
23 0         0 fail("$filename contains boilerplate text");
24 0         0 diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
  0         0  
25             } else {
26 3         22 pass("$filename contains no boilerplate text");
27             }
28             }
29              
30             sub module_boilerplate_ok {
31 1     1   3 my ($module) = @_;
32 1         7 not_in_file_ok($module =>
33             'the great new $MODULENAME' => qr/ - The great new /,
34             'boilerplate description' => qr/Quick summary of what the module/,
35             'stub function definition' => qr/function[12]/,
36             );
37             }
38              
39 1         2 TODO: {
40 1         2 local $TODO = "Need to replace the boilerplate text";
41              
42 1         7 not_in_file_ok(README =>
43             "The README is used..." => qr/The README is used/,
44             "'version information here'" => qr/to provide version information/,
45             );
46              
47 1         338 not_in_file_ok(Changes =>
48             "placeholder date/time" => qr(Date/time)
49             );
50              
51 1         207 module_boilerplate_ok('lib/Dancer2/Plugin/HTTP/Auth/Extensible.pm');
52              
53              
54             }
55