| 1 |
#line 1 |
| 2 |
package Module::Install::AuthorTests; |
| 3 |
|
| 4 |
use 5.005; |
| 5 |
use strict; |
| 6 |
use Module::Install::Base; |
| 7 |
use Carp (); |
| 8 |
|
| 9 |
#line 16 |
| 10 |
|
| 11 |
use vars qw{$VERSION $ISCORE @ISA}; |
| 12 |
BEGIN { |
| 13 |
$VERSION = '0.002'; |
| 14 |
$ISCORE = 1; |
| 15 |
@ISA = qw{Module::Install::Base}; |
| 16 |
} |
| 17 |
|
| 18 |
#line 42 |
| 19 |
|
| 20 |
sub author_tests { |
| 21 |
my ($self, @dirs) = @_; |
| 22 |
_add_author_tests($self, \@dirs, 0); |
| 23 |
} |
| 24 |
|
| 25 |
#line 56 |
| 26 |
|
| 27 |
sub recursive_author_tests { |
| 28 |
my ($self, @dirs) = @_; |
| 29 |
_add_author_tests($self, \@dirs, 1); |
| 30 |
} |
| 31 |
|
| 32 |
sub _wanted { |
| 33 |
my $href = shift; |
| 34 |
sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 } |
| 35 |
} |
| 36 |
|
| 37 |
sub _add_author_tests { |
| 38 |
my ($self, $dirs, $recurse) = @_; |
| 39 |
return unless $Module::Install::AUTHOR; |
| 40 |
|
| 41 |
my @tests = $self->tests ? (split / /, $self->tests) : 't/*.t'; |
| 42 |
|
| 43 |
# XXX: pick a default, later -- rjbs, 2008-02-24 |
| 44 |
my @dirs = @$dirs ? @$dirs : Carp::confess "no dirs given to author_tests"; |
| 45 |
@dirs = grep { -d } @dirs; |
| 46 |
|
| 47 |
if ($recurse) { |
| 48 |
require File::Find; |
| 49 |
my %test_dir; |
| 50 |
File::Find::find(_wanted(\%test_dir), @dirs); |
| 51 |
$self->tests( join ' ', @tests, map { "$_/*.t" } sort keys %test_dir ); |
| 52 |
} else { |
| 53 |
$self->tests( join ' ', @tests, map { "$_/*.t" } sort @dirs ); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
#line 107 |
| 58 |
|
| 59 |
1; |