| 1 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | package Dist::Zilla::Plugin::CheckExtraTests; | ||||||||||
| 5 | # ABSTRACT: check xt tests before release | ||||||||||
| 6 | |||||||||||
| 7 | 3 | our $VERSION = '0.029'; | |||||||||
| 8 | |||||||||||
| 9 | # Dependencies | ||||||||||
| 10 | 3 | ▶ | use Dist::Zilla 4.3 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | ▶ | use Moose 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 3 | ▶ | use namespace::autoclean 0.09; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | # extends, roles, attributes, etc. | ||||||||||
| 15 | |||||||||||
| 16 | 3 | 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 | 3 | has default_jobs => ( | |||||||||
| 26 | is => 'ro', | ||||||||||
| 27 | isa => 'Int', # non-negative | ||||||||||
| 28 | default => 1, | ||||||||||
| 29 | ); | ||||||||||
| 30 | |||||||||||
| 31 | # methods | ||||||||||
| 32 | |||||||||||
| 33 | 3 | ▶ | sub before_release { | ||||||||
|
Subroutine
before_release: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||
| 34 | 3 | my ( $self, $tgz ) = @_; | |||||||||
| 35 | 3 | $tgz = $tgz->absolute; | |||||||||
| 36 | |||||||||||
| 37 | 3 | { require Path::Tiny; Path::Tiny->VERSION(0.013) } | |||||||||
| 38 | |||||||||||
| 39 | 3 | my $build_root = Path::Tiny::path( $self->zilla->root )->child('.build'); | |||||||||
| 40 | 3 | ▶ | $build_root->mkpath unless -d $build_root; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 3 | my $tmpdir = Path::Tiny->tempdir( DIR => $build_root ); | |||||||||
| 43 | |||||||||||
| 44 | 3 | $self->log("Extracting $tgz to $tmpdir"); | |||||||||
| 45 | |||||||||||
| 46 | 3 | require Archive::Tar; | |||||||||
| 47 | |||||||||||
| 48 | 3 | my @files = do { | |||||||||
| 49 | 3 | my $wd = File::pushd::pushd($tmpdir); | |||||||||
| 50 | 3 | Archive::Tar->extract_archive("$tgz"); | |||||||||
| 51 | }; | ||||||||||
| 52 | |||||||||||
| 53 | 3 | ▶ | $self->log_fatal( [ "Failed to extract archive: %s", Archive::Tar->error ] ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | unless @files; | ||||||||||
| 55 | |||||||||||
| 56 | # Run tests on the extracted tarball: | ||||||||||
| 57 | 3 | my $target = $tmpdir->child( $self->zilla->dist_basename ); | |||||||||
| 58 | |||||||||||
| 59 | 3 | local $ENV{RELEASE_TESTING} = 1; | |||||||||
| 60 | 3 | local $ENV{AUTHOR_TESTING} = 1; | |||||||||
| 61 | |||||||||||
| 62 | { | ||||||||||
| 63 | # chdir in | ||||||||||
| 64 | 3 | require File::pushd; | |||||||||
| 65 | 3 | my $wd = File::pushd::pushd($target); | |||||||||
| 66 | |||||||||||
| 67 | # make | ||||||||||
| 68 | 3 | my @builders = @{ $self->zilla->plugins_with( -BuildRunner ) }; | |||||||||
| 69 | 3 | ▶ | die "no BuildRunner plugins specified" unless @builders; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 3 | $_->build for @builders; | |||||||||
| 71 | |||||||||||
| 72 | 3 | my $jobs = $self->default_jobs; | |||||||||
| 73 | 3 | ▶ | my @v = $self->zilla->logger->get_debug ? ('-v') : (); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | |||||||||||
| 75 | 3 | require App::Prove; | |||||||||
| 76 | 3 | App::Prove->VERSION('3.00'); | |||||||||
| 77 | |||||||||||
| 78 | 3 | my $app = App::Prove->new; | |||||||||
| 79 | 3 | $app->process_args( '-j', $jobs, @v, qw/-r -b xt/ ); | |||||||||
| 80 | 3 | ▶ | $app->run or $self->log_fatal("Fatal errors in xt tests"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | 2 | $self->log("all's well; removing $tmpdir"); | |||||||||
| 84 | 2 | $tmpdir->remove_tree( { safe => 0 } ); | |||||||||
| 85 | |||||||||||
| 86 | 2 | return; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||
| 90 | |||||||||||
| 91 | 3 | 1; | |||||||||
| 92 | |||||||||||
| 93 | __END__ | ||||||||||