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