File Coverage

blib/lib/Test/NoSmartComments.pm
Criterion Covered Total %
statement 30 31 96.7
branch 1 2 50.0
condition n/a
subroutine 8 9 88.8
pod 3 3 100.0
total 42 45 93.3


line stmt bran cond sub pod time code
1             #
2             # This file is part of Test-NoSmartComments
3             #
4             # This software is Copyright (c) 2011 by Chris Weyl.
5             #
6             # This is free software, licensed under:
7             #
8             # The GNU Lesser General Public License, Version 2.1, February 1999
9             #
10             package Test::NoSmartComments;
11             our $AUTHORITY = 'cpan:RSRCHBOY';
12             # git description: 0.004-7-gfc4f436
13             $Test::NoSmartComments::VERSION = '0.005';
14              
15             # ABSTRACT: Make sure no Smart::Comments escape into the wild
16              
17 2     2   47928 use strict;
  2         13  
  2         89  
18 2     2   11 use warnings;
  2         3  
  2         115  
19              
20 2     2   12 use base 'Test::Builder::Module';
  2         2  
  2         257  
21              
22             my $CLASS = __PACKAGE__;
23              
24 2     2   1427 use Module::ScanDeps;
  2         103553  
  2         180  
25 2     2   1235 use ExtUtils::Manifest qw( maniread );
  2         14273  
  2         1371  
26              
27             our @EXPORT = qw{
28             no_smart_comments_in
29             no_smart_comments_in_all
30             no_smart_comments_in_tests
31             };
32              
33              
34 1     1 1 482 sub no_smart_comments_in_all { _no_smart_comments_in_matching(qr!^lib/.*\.pm$!) }
35 0     0 1 0 sub no_smart_comments_in_tests { _no_smart_comments_in_matching(qr!^t/.*\.t$!) }
36              
37             sub _no_smart_comments_in_matching {
38 1     1   2 my $like = shift @_;
39              
40 1         6 my $tb = $CLASS->builder;
41 1         11 my $manifest = maniread();
42 1         80 my @files = sort grep { $like } keys %$manifest;
  2         7  
43 1         2 local $Test::Builder::Level = $Test::Builder::Level + 2;
44 1         4 no_smart_comments_in($_) for @files;
45              
46 1         4 return;
47             }
48              
49             sub no_smart_comments_in {
50 4     4 1 641 my $file = shift @_;
51 4         26 my $tb = $CLASS->builder;
52              
53 4 50       82 $tb->diag("No such file: $file") unless -f $file;
54              
55 4         17 my $dep = scan_deps(files => [ $file ], recurse => 0);
56 4         11048 $tb->ok(!exists $dep->{'Smart/Comments.pm'}, "$file w/o Smart::Comments");
57 4         1424 return;
58             }
59              
60             1;
61              
62             __END__