| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 3 |  |  | 3 |  | 2040234 | use strict; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 96 |  | 
| 2 | 3 |  |  | 3 |  | 11 | use warnings; | 
|  | 3 |  |  |  |  | 2 |  | 
|  | 3 |  |  |  |  | 147 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | package Dist::Zilla::Plugin::CheckExtraTests; | 
| 5 |  |  |  |  |  |  | # ABSTRACT: check xt tests before release | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.027'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | # Dependencies | 
| 10 | 3 |  |  | 3 |  | 9 | use Dist::Zilla 4.3 (); | 
|  | 3 |  |  |  |  | 66 |  | 
|  | 3 |  |  |  |  | 43 |  | 
| 11 | 3 |  |  | 3 |  | 9 | use Moose 2; | 
|  | 3 |  |  |  |  | 189 |  | 
|  | 3 |  |  |  |  | 15 |  | 
| 12 | 3 |  |  | 3 |  | 12215 | use namespace::autoclean 0.09; | 
|  | 3 |  |  |  |  | 57 |  | 
|  | 3 |  |  |  |  | 15 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | # extends, roles, attributes, etc. | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | with 'Dist::Zilla::Role::BeforeRelease'; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | #pod =attr default_jobs | 
| 19 |  |  |  |  |  |  | #pod | 
| 20 |  |  |  |  |  |  | #pod This attribute is the default value that should be used as the C<jobs> argument | 
| 21 |  |  |  |  |  |  | #pod for prerelease tests. | 
| 22 |  |  |  |  |  |  | #pod | 
| 23 |  |  |  |  |  |  | #pod =cut | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | has default_jobs => ( | 
| 26 |  |  |  |  |  |  | is      => 'ro', | 
| 27 |  |  |  |  |  |  | isa     => 'Int', # non-negative | 
| 28 |  |  |  |  |  |  | default => 1, | 
| 29 |  |  |  |  |  |  | ); | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | # methods | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | sub before_release { | 
| 34 | 3 |  |  | 3 | 0 | 471596 | my ( $self, $tgz ) = @_; | 
| 35 | 3 |  |  |  |  | 61 | $tgz = $tgz->absolute; | 
| 36 |  |  |  |  |  |  |  | 
| 37 | 3 |  |  |  |  | 584 | { require Path::Tiny; Path::Tiny->VERSION(0.013) } | 
|  | 3 |  |  |  |  | 35 |  | 
|  | 3 |  |  |  |  | 104 |  | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 3 |  |  |  |  | 130 | my $build_root = Path::Tiny::path( $self->zilla->root )->child('.build'); | 
| 40 | 3 | 50 |  |  |  | 636 | $build_root->mkpath unless -d $build_root; | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 3 |  |  |  |  | 816 | my $tmpdir = Path::Tiny->tempdir( DIR => $build_root ); | 
| 43 |  |  |  |  |  |  |  | 
| 44 | 3 |  |  |  |  | 1718 | $self->log("Extracting $tgz to $tmpdir"); | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 3 |  |  |  |  | 3827 | require Archive::Tar; | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 3 |  |  |  |  | 124573 | my @files = do { | 
| 49 | 3 |  |  |  |  | 28 | my $wd = File::pushd::pushd($tmpdir); | 
| 50 | 3 |  |  |  |  | 425 | Archive::Tar->extract_archive("$tgz"); | 
| 51 |  |  |  |  |  |  | }; | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 3 | 50 |  |  |  | 142382 | $self->log_fatal( [ "Failed to extract archive: %s", Archive::Tar->error ] ) | 
| 54 |  |  |  |  |  |  | unless @files; | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | # Run tests on the extracted tarball: | 
| 57 | 3 |  |  |  |  | 193 | my $target = $tmpdir->child( $self->zilla->dist_basename ); | 
| 58 |  |  |  |  |  |  |  | 
| 59 | 3 |  |  |  |  | 487 | local $ENV{RELEASE_TESTING} = 1; | 
| 60 | 3 |  |  |  |  | 17 | local $ENV{AUTHOR_TESTING}  = 1; | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | { | 
| 63 |  |  |  |  |  |  | # chdir in | 
| 64 | 3 |  |  |  |  | 4 | require File::pushd; | 
|  | 3 |  |  |  |  | 26 |  | 
| 65 | 3 |  |  |  |  | 17 | my $wd = File::pushd::pushd($target); | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | # make | 
| 68 | 3 |  |  |  |  | 539 | my @builders = @{ $self->zilla->plugins_with( -BuildRunner ) }; | 
|  | 3 |  |  |  |  | 111 |  | 
| 69 | 3 | 50 |  |  |  | 1222 | die "no BuildRunner plugins specified" unless @builders; | 
| 70 | 3 |  |  |  |  | 32 | $_->build for @builders; | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 3 |  |  |  |  | 1421438 | my $jobs = $self->default_jobs; | 
| 73 | 3 | 50 |  |  |  | 99 | my @v = $self->zilla->logger->get_debug ? ('-v') : (); | 
| 74 |  |  |  |  |  |  |  | 
| 75 | 3 |  |  |  |  | 1557 | require App::Prove; | 
| 76 | 3 |  |  |  |  | 132371 | App::Prove->VERSION('3.00'); | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 3 |  |  |  |  | 33 | my $app = App::Prove->new; | 
| 79 | 3 |  |  |  |  | 306 | $app->process_args( '-j', $jobs, @v, qw/-r -b xt/ ); | 
| 80 | 3 | 100 |  |  |  | 5439 | $app->run or $self->log_fatal("Fatal errors in xt tests"); | 
| 81 |  |  |  |  |  |  | } | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 2 |  |  |  |  | 625760 | $self->log("all's well; removing $tmpdir"); | 
| 84 | 2 |  |  |  |  | 1361 | $tmpdir->remove_tree( { safe => 0 } ); | 
| 85 |  |  |  |  |  |  |  | 
| 86 | 2 |  |  |  |  | 7090 | return; | 
| 87 |  |  |  |  |  |  | } | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | 1; | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | __END__ | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | =pod | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =encoding UTF-8 | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | =head1 NAME | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | Dist::Zilla::Plugin::CheckExtraTests - check xt tests before release | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | =head1 VERSION | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | version 0.027 | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | In your dist.ini: | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | [CheckExtraTests] | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | Runs all xt tests before release.  Dies if any fail.  Sets RELEASE_TESTING | 
| 116 |  |  |  |  |  |  | and AUTHOR_TESTING. | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | If you use L<Dist::Zilla::Plugin::TestRelease>, you should consider using | 
| 119 |  |  |  |  |  |  | L<Dist::Zilla::Plugin::RunExtraTests> instead, which enables xt tests to | 
| 120 |  |  |  |  |  |  | run as part of C<[TestRelease]> and is thus a bit more efficient as the | 
| 121 |  |  |  |  |  |  | distribution is only built once for testing. | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | =head2 default_jobs | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | This attribute is the default value that should be used as the C<jobs> argument | 
| 128 |  |  |  |  |  |  | for prerelease tests. | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | =for Pod::Coverage::TrustPod before_release | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =over 4 | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | =item * | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | L<Dist::Zilla> | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | =back | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =head1 SUPPORT | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | =head2 Bugs / Feature Requests | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | Please report any bugs or feature requests through the issue tracker | 
| 149 |  |  |  |  |  |  | at L<https://github.com/dagolden/Dist-Zilla-Plugin-CheckExtraTests/issues>. | 
| 150 |  |  |  |  |  |  | You will be notified automatically of any progress on your issue. | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | =head2 Source Code | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | This is open source software.  The code repository is available for | 
| 155 |  |  |  |  |  |  | public review and contribution under the terms of the license. | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | L<https://github.com/dagolden/Dist-Zilla-Plugin-CheckExtraTests> | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | git clone https://github.com/dagolden/Dist-Zilla-Plugin-CheckExtraTests.git | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | =head1 AUTHORS | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  | =over 4 | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  | =item * | 
| 166 |  |  |  |  |  |  |  | 
| 167 |  |  |  |  |  |  | David Golden <dagolden@cpan.org> | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  | =item * | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  | Jesse Luehrs <doy@cpan.org> | 
| 172 |  |  |  |  |  |  |  | 
| 173 |  |  |  |  |  |  | =back | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | =head1 CONTRIBUTORS | 
| 176 |  |  |  |  |  |  |  | 
| 177 |  |  |  |  |  |  | =for stopwords Christopher J. Madsen David H. Adler Karen Etheridge Kent Fredric Olivier Mengue Ricardo Signes | 
| 178 |  |  |  |  |  |  |  | 
| 179 |  |  |  |  |  |  | =over 4 | 
| 180 |  |  |  |  |  |  |  | 
| 181 |  |  |  |  |  |  | =item * | 
| 182 |  |  |  |  |  |  |  | 
| 183 |  |  |  |  |  |  | Christopher J. Madsen <cjm@cpan.org> | 
| 184 |  |  |  |  |  |  |  | 
| 185 |  |  |  |  |  |  | =item * | 
| 186 |  |  |  |  |  |  |  | 
| 187 |  |  |  |  |  |  | David H. Adler <dha@pobox.com> | 
| 188 |  |  |  |  |  |  |  | 
| 189 |  |  |  |  |  |  | =item * | 
| 190 |  |  |  |  |  |  |  | 
| 191 |  |  |  |  |  |  | Karen Etheridge <ether@cpan.org> | 
| 192 |  |  |  |  |  |  |  | 
| 193 |  |  |  |  |  |  | =item * | 
| 194 |  |  |  |  |  |  |  | 
| 195 |  |  |  |  |  |  | Kent Fredric <kentfredric@gmail.com> | 
| 196 |  |  |  |  |  |  |  | 
| 197 |  |  |  |  |  |  | =item * | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | Olivier Mengue <dolmen@cpan.org> | 
| 200 |  |  |  |  |  |  |  | 
| 201 |  |  |  |  |  |  | =item * | 
| 202 |  |  |  |  |  |  |  | 
| 203 |  |  |  |  |  |  | Ricardo Signes <rjbs@cpan.org> | 
| 204 |  |  |  |  |  |  |  | 
| 205 |  |  |  |  |  |  | =back | 
| 206 |  |  |  |  |  |  |  | 
| 207 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 208 |  |  |  |  |  |  |  | 
| 209 |  |  |  |  |  |  | This software is Copyright (c) 2015 by David Golden. | 
| 210 |  |  |  |  |  |  |  | 
| 211 |  |  |  |  |  |  | This is free software, licensed under: | 
| 212 |  |  |  |  |  |  |  | 
| 213 |  |  |  |  |  |  | The Apache License, Version 2.0, January 2004 | 
| 214 |  |  |  |  |  |  |  | 
| 215 |  |  |  |  |  |  | =cut |