File Coverage

blib/lib/Wetware/Test/Utilities.pm
Criterion Covered Total %
statement 33 33 100.0
branch 3 4 75.0
condition n/a
subroutine 11 11 100.0
pod 4 4 100.0
total 51 52 98.0


line stmt bran cond sub pod time code
1             #-------------------------------------------------------------------------------
2             # $URL$
3             # $Date$
4             # $Author$
5             # $Revision$
6             #-------------------------------------------------------------------------------
7             package Wetware::Test::Utilities;
8              
9 2     2   13 use strict;
  2         12  
  2         76  
10 2     2   17 use warnings;
  2         5  
  2         58  
11 2     2   912 use FindBin qw($Bin);
  2         1483  
  2         264  
12 2     2   15 use File::Basename qw(basename);
  2         4  
  2         138  
13              
14 2     2   12 use File::Spec;
  2         13  
  2         85  
15              
16             #------------------------------------------------------------------------------
17              
18             our $VERSION = 0.03;
19              
20             #------------------------------------------------------------------------------
21             # So we do NOT need to export them....
22             # Since we expect that we will work with Test::Class Cases...
23             # but may work outside of the Test::Class cases....
24             #
25 2     2   10 use Exporter;
  2         4  
  2         72  
26 2     2   9 use base qw(Exporter);
  2         5  
  2         746  
27              
28             our %EXPORT_TAGS = ( 'all' => [ qw(
29             is_testsuite_module
30             path_to_data_dir
31             path_to_data_dir_from
32             readable_file_path
33             ) ] );
34              
35             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
36              
37             #------------------------------------------------------------------------------
38              
39             sub readable_file_path {
40 3     3 1 3808 my ( $file_path ) = @_;
41 3 100       13 return unless $file_path;
42 2         77 return ( -r $file_path );
43             }
44              
45             sub is_testsuite_module {
46 2     2 1 3054 my ( $file_path ) = @_;
47            
48 2 50       8 return unless readable_file_path($file_path);
49            
50 2         107 my $file_name = basename( $file_path );
51            
52 2         11 return $file_name =~ m{^TestSuite\.pm$};
53             }
54              
55             # hum.... what if we have a TestSuite for Foo in blib?
56             # do we need a get_resource_from_INC() method?
57             sub path_to_data_dir_from {
58 4     4 1 16485 my ($path ) = @_;
59 4         17 $path =~ s{/t/.*}{/t/};
60 4         122 $path = File::Spec->join( $path, 'test_data' );
61 4         20 return $path;
62             }
63              
64             sub path_to_data_dir {
65 2     2 1 2020 return path_to_data_dir_from($Bin);
66             }
67              
68             #------------------------------------------------------------------------------
69              
70             1;
71              
72             __END__