File Coverage

blib/lib/Dist/Zilla/Plugin/RunExtraTests.pm
Criterion Covered Total %
statement 31 37 83.7
branch 11 22 50.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 0 1 0.0
total 49 69 71.0


line stmt bran cond sub pod time code
1 1     1   1531 use strict;
  1         1  
  1         32  
2 1     1   3 use warnings;
  1         1  
  1         54  
3              
4             package Dist::Zilla::Plugin::RunExtraTests;
5             # ABSTRACT: support running xt tests via dzil test
6              
7             our $VERSION = '0.027';
8              
9             # Dependencies
10 1     1   3 use Dist::Zilla 4.3 ();
  1         18  
  1         16  
11 1     1   3 use Moose 2;
  1         32  
  1         6  
12 1     1   3994 use namespace::autoclean 0.09;
  1         18  
  1         5  
13              
14             # extends, roles, attributes, etc.
15              
16             with 'Dist::Zilla::Role::TestRunner';
17              
18             # methods
19              
20             sub test {
21 3     3 0 2804474 my ($self, $target, $arg) = @_;
22              
23 3         15 my %dirs; @dirs{ glob('xt/*') } = ();
  3         222  
24 3 100       32 delete $dirs{'xt/author'} unless $ENV{AUTHOR_TESTING};
25 3 50       21 delete $dirs{'xt/smoke'} unless $ENV{AUTOMATED_TESTING};
26 3 50       23 delete $dirs{'xt/release'} unless $ENV{RELEASE_TESTING};
27              
28 3         18 my @dirs = sort keys %dirs;
29 3 100       26 return unless @dirs;
30              
31             # If the dist hasn't been built yet, then build it:
32 1 50       15 unless ( -d 'blib' ) {
33 0         0 my @builders = @{ $self->zilla->plugins_with( -BuildRunner ) };
  0         0  
34 0 0       0 die "no BuildRunner plugins specified" unless @builders;
35 0         0 $_->build for @builders;
36 0 0       0 die "no blib; failed to build properly?" unless -d 'blib';
37             }
38              
39 1 50 33     66 my $jobs = $arg && exists $arg->{jobs}
    50          
40             ? $arg->{jobs}
41             : $self->can('default_jobs')
42             ? $self->default_jobs
43             : 1;
44 1 50       31 my @v = $self->zilla->logger->get_debug ? ('-v') : ();
45              
46 1         634 require App::Prove;
47 1         23064 App::Prove->VERSION('3.00');
48              
49 1         7 my $app = App::Prove->new;
50 1         64 $app->process_args( '-j', $jobs, @v, qw/-r -b/, @dirs );
51 1 50       1514 $app->run or $self->log_fatal("Fatal errors in xt tests");
52 0           return;
53             }
54              
55             __PACKAGE__->meta->make_immutable;
56              
57             1;
58              
59             __END__
60              
61             =pod
62              
63             =encoding UTF-8
64              
65             =head1 NAME
66              
67             Dist::Zilla::Plugin::RunExtraTests - support running xt tests via dzil test
68              
69             =head1 VERSION
70              
71             version 0.027
72              
73             =head1 SYNOPSIS
74              
75             In your dist.ini:
76              
77             [RunExtraTests]
78              
79             =head1 DESCRIPTION
80              
81             Runs F<xt> tests when the test phase is run (e.g. C<dzil test>, C<dzil release>
82             etc). F<xt/release>, F<xt/author>, and F<xt/smoke> will be tested based on the
83             values of the appropriate environment variables (C<RELEASE_TESTING>,
84             C<AUTHOR_TESTING>, and C<AUTOMATED_TESTING>), which are set by C<dzil test>.
85             Additionally, all other F<xt> files and directories will always be run.
86              
87             If C<RunExtraTests> is listed after one of the normal test-running
88             plugins (e.g. C<MakeMaker> or C<ModuleBuild>), then the dist will not
89             be rebuilt between running the normal tests and the extra tests.
90              
91             =for Pod::Coverage::TrustPod test
92              
93             =head1 SEE ALSO
94              
95             =over 4
96              
97             =item *
98              
99             L<Dist::Zilla>
100              
101             =back
102              
103             =head1 AUTHORS
104              
105             =over 4
106              
107             =item *
108              
109             David Golden <dagolden@cpan.org>
110              
111             =item *
112              
113             Jesse Luehrs <doy@cpan.org>
114              
115             =back
116              
117             =head1 COPYRIGHT AND LICENSE
118              
119             This software is Copyright (c) 2015 by David Golden.
120              
121             This is free software, licensed under:
122              
123             The Apache License, Version 2.0, January 2004
124              
125             =cut