| 1 | package Dist::Zilla::Plugin::TestRelease 6.040; | ||||||||||
| 2 | # ABSTRACT: extract archive and run tests before releasing the dist | ||||||||||
| 3 | |||||||||||
| 4 | 3 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | with 'Dist::Zilla::Role::BeforeRelease'; | |||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use Dist::Zilla::Pragmas; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | #pod =head1 DESCRIPTION | ||||||||||
| 12 | #pod | ||||||||||
| 13 | #pod This plugin runs before a release happens. It will extract the to-be-released | ||||||||||
| 14 | #pod archive into a temporary directory and use the TestRunner plugins to run its | ||||||||||
| 15 | #pod tests. If the tests fail, the release is aborted and the temporary directory | ||||||||||
| 16 | #pod is left in place. If the tests pass, the temporary directory is cleaned up and | ||||||||||
| 17 | #pod the release process continues. | ||||||||||
| 18 | #pod | ||||||||||
| 19 | #pod This will set the RELEASE_TESTING and AUTHOR_TESTING env vars while running the | ||||||||||
| 20 | #pod test suite. | ||||||||||
| 21 | #pod | ||||||||||
| 22 | #pod =head1 CREDITS | ||||||||||
| 23 | #pod | ||||||||||
| 24 | #pod This plugin was originally contributed by Christopher J. Madsen. | ||||||||||
| 25 | #pod | ||||||||||
| 26 | #pod =cut | ||||||||||
| 27 | |||||||||||
| 28 | 3 | ▶ | use File::pushd (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 3 | ▶ | use Dist::Zilla::Path; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 1 | ▶ | sub before_release { | ||||||||
|
Subroutine
before_release: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 32 | 1 | my ($self, $tgz) = @_; | |||||||||
| 33 | 1 | $tgz = $tgz->absolute; | |||||||||
| 34 | |||||||||||
| 35 | 1 | my $build_root = $self->zilla->root->child('.build'); | |||||||||
| 36 | 1 | ▶ | $build_root->mkpath unless -d $build_root; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 1 | my $tmpdir = path( File::Temp::tempdir(DIR => $build_root) ); | |||||||||
| 39 | |||||||||||
| 40 | 1 | $self->log("Extracting $tgz to $tmpdir"); | |||||||||
| 41 | |||||||||||
| 42 | 1 | require Archive::Tar; | |||||||||
| 43 | |||||||||||
| 44 | 1 | my @files = do { | |||||||||
| 45 | 1 | my $wd = File::pushd::pushd($tmpdir); | |||||||||
| 46 | 1 | Archive::Tar->extract_archive("$tgz"); | |||||||||
| 47 | }; | ||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | $self->log_fatal([ "Failed to extract archive: %s", Archive::Tar->error ]) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | unless @files; | ||||||||||
| 51 | |||||||||||
| 52 | # Run tests on the extracted tarball: | ||||||||||
| 53 | 1 | my $target = $tmpdir->child( $self->zilla->dist_basename ); | |||||||||
| 54 | |||||||||||
| 55 | 1 | local $ENV{RELEASE_TESTING} = 1; | |||||||||
| 56 | 1 | local $ENV{AUTHOR_TESTING} = 1; | |||||||||
| 57 | 1 | $self->zilla->run_tests_in($target); | |||||||||
| 58 | |||||||||||
| 59 | 1 | $self->log("all's well; removing $tmpdir"); | |||||||||
| 60 | 1 | $tmpdir->remove_tree({ safe => 0 }); | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||
| 64 | 3 | 1; | |||||||||
| 65 | |||||||||||
| 66 | __END__ | ||||||||||