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