File Coverage

inc/Test/UseAllModules.pm
Criterion Covered Total %
statement 32 37 86.4
branch 8 14 57.1
condition 1 6 16.6
subroutine 6 6 100.0
pod 1 1 100.0
total 48 64 75.0


line stmt bran cond sub pod time code
1             #line 1
2             package Test::UseAllModules;
3 1     1   1019  
  1         2  
  1         35  
4 1     1   6 use strict;
  1         1  
  1         33  
5 1     1   10204 use warnings;
  1         16560  
  1         84  
6             use ExtUtils::Manifest qw( maniread );
7              
8             our $VERSION = '0.09';
9 1     1   19  
  1         2  
  1         55  
10             use Exporter;
11              
12             our @ISA = qw/Exporter/;
13             our @EXPORT = qw/all_uses_ok/;
14 1     1   4  
  1         182  
  1         9  
15             use Test::More;
16              
17 1 50 33 1 1 11 sub all_uses_ok {
18             shift if @_ && $_[0] eq 'except';
19 1         3  
20 1         2 my @exceptions = @_;
21             my @modules;
22 1 50       32  
23 0         0 unless (-f 'MANIFEST') {
24 0         0 plan skip_all => 'no MANIFEST';
25             exit;
26             }
27 1         6  
28             my $manifest = maniread();
29 1         10  
30 1         657 READ:
31 46 100       134 foreach my $file (keys %{ $manifest }) {
32 17         71 if (my ($module) = $file =~ m|^lib/(.*)\.pm\s*$|) {
33             $module =~ s|/|::|g;
34 17         30  
35 0 0 0     0 foreach my $rule (@exceptions) {
36             next READ if $module eq $rule || $module =~ /$rule/;
37             }
38 17         36  
39             push @modules, $module;
40             }
41             }
42 1 50       7  
43 0         0 unless (@modules) {
44 0         0 plan skip_all => 'no .pm files are found under the lib directory';
45             exit;
46 1         8 }
47             plan tests => scalar @modules;
48 1         652  
49 1         5 my @failed;
50 17 100       60 foreach my $module (@modules) {
51             use_ok($module) or push @failed, $module;
52             }
53 1 50       19  
54             BAIL_OUT( 'failed: ' . (join ',', @failed) ) if @failed;
55             }
56              
57             1;
58             __END__
59              
60             #line 124