Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Module / Install / AuthorTests.pm
CommitLineData
3fea05b9 1package Module::Install::AuthorTests;
2
3use 5.005;
4use strict;
5use Module::Install::Base;
6use Carp ();
7
8=head1 NAME
9
10Module::Install::AuthorTests - designate tests only run by module authors
11
12=head1 VERSION
13
140.002
15
16=cut
17
18use vars qw{$VERSION $ISCORE @ISA};
19BEGIN {
20 $VERSION = '0.002';
21 $ISCORE = 1;
22 @ISA = qw{Module::Install::Base};
23}
24
25=head1 COMMANDS
26
27This plugin adds the following Module::Install commands:
28
29=head2 author_tests
30
31 author_tests('xt');
32
33This declares that the test files found in the directory F<./xt> should be run
34only if the module is being built by an author. For an explanation, see below.
35
36You may declare multiple test directories by passing a list of tests. Since
37tests are not recursive by default, it should be safe to use a subdirectory of
38F<./t> for author tests, like:
39
40 author_tests('t/author');
41
42=cut
43
44sub author_tests {
45 my ($self, @dirs) = @_;
46 _add_author_tests($self, \@dirs, 0);
47}
48
49=head2 recursive_author_tests
50
51 recursive_author_tests('xt');
52
53This acts like C<author_tests>, but will look for tests in directories below
54F<./xt> as well as in the directory itself.
55
56=cut
57
58sub recursive_author_tests {
59 my ($self, @dirs) = @_;
60 _add_author_tests($self, \@dirs, 1);
61}
62
63sub _wanted {
64 my $href = shift;
65 sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 }
66}
67
68sub _add_author_tests {
69 my ($self, $dirs, $recurse) = @_;
70 return unless $Module::Install::AUTHOR;
71
72 my @tests = $self->tests ? (split / /, $self->tests) : 't/*.t';
73
74 # XXX: pick a default, later -- rjbs, 2008-02-24
75 my @dirs = @$dirs ? @$dirs : Carp::confess "no dirs given to author_tests";
76 @dirs = grep { -d } @dirs;
77
78 if ($recurse) {
79 require File::Find;
80 my %test_dir;
81 File::Find::find(_wanted(\%test_dir), @dirs);
82 $self->tests( join ' ', @tests, map { "$_/*.t" } sort keys %test_dir );
83 } else {
84 $self->tests( join ' ', @tests, map { "$_/*.t" } sort @dirs );
85 }
86}
87
88=head1 HOW IT WORKS
89
90"Is this being run by an author?" is determined internally by Module::Install,
91but at the time of the writing of this version it's determined by the existence
92of a directory called F<.author> in F<./inc>. (On VMS, it's F<_author>.) This
93directory is created when Module::Install's F<Makefile.PL> is run in a
94directory where no F<./inc> directory exists.
95
96=head1 BUGS
97
98Please report any bugs or feature requests through the web interface at
99L<http://rt.cpan.org>. I will be notified, and then you'll automatically be
100notified of progress on your bug as I make changes.
101
102=head1 COPYRIGHT
103
104Copyright 2008, Ricardo SIGNES. This program is free software; you can
105redistribute it and/or modify it under the same terms as Perl itself.
106
107=cut
108
1091;