[libdist-zilla-plugin-test-podspelling-perl] 06/10: save the file object, so we can munge it later even if it was renamed

Axel Beckert abe at deuxchevaux.org
Mon May 25 10:05:49 UTC 2015


This is an automated email from the git hooks/post-receive script.

abe pushed a commit to annotated tag v2.006007
in repository libdist-zilla-plugin-test-podspelling-perl.

commit 658673451a25743a617b62005e491d7dbf8dd836
Author: Karen Etheridge <ether at cpan.org>
Date:   Mon Mar 3 20:33:09 2014 -0800

    save the file object, so we can munge it later even if it was renamed
---
 Changes                                   |  1 +
 lib/Dist/Zilla/Plugin/Test/PodSpelling.pm | 34 +++++++++++++++++------
 t/renamed.t                               | 45 +++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 8 deletions(-)

diff --git a/Changes b/Changes
index 12ae280..5407834 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 Revision history for Perl extension {{$dist->name}}
 
 {{$NEXT}}
+	- munge the file properly even if [ExtraTests] has already moved it
 
 2.006006  2014-02-27
 	- require Dist::Zilla 5
diff --git a/lib/Dist/Zilla/Plugin/Test/PodSpelling.pm b/lib/Dist/Zilla/Plugin/Test/PodSpelling.pm
index 3d3973d..febae3d 100644
--- a/lib/Dist/Zilla/Plugin/Test/PodSpelling.pm
+++ b/lib/Dist/Zilla/Plugin/Test/PodSpelling.pm
@@ -52,6 +52,31 @@ has directories => (
 	}
 );
 
+has _files => (
+	is      => 'rw',
+	isa     => 'ArrayRef[Dist::Zilla::Role::File]',
+);
+
+sub gather_files {
+	my ($self) = @_;
+
+	my $data = $self->merged_section_data;
+	return unless $data and %$data;
+
+	my @files;
+	for my $name (keys %$data) {
+		my $file = Dist::Zilla::File::InMemory->new({
+			name    => $name,
+			content => ${ $data->{$name} },
+		});
+		$self->add_file($file);
+		push @files, $file;
+	}
+
+	$self->_files(\@files);
+	return;
+}
+
 sub add_stopword {
 	my ( $self, $data ) = @_;
 
@@ -71,14 +96,7 @@ sub add_stopword {
 sub munge_files {
 	my ($self) = @_;
 
-	my $data = $self->merged_section_data;
-	return unless $data and %$data;
-
-	for my $file (@{ $self->zilla->files }) {
-		next unless exists $data->{$file->name};
-
-		$self->munge_file($file);
-	}
+	$self->munge_file($_) foreach @{ $self->_files };
 	return;
 }
 
diff --git a/t/renamed.t b/t/renamed.t
new file mode 100644
index 0000000..4e4443e
--- /dev/null
+++ b/t/renamed.t
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::DZil;
+use File::pushd 'pushd';
+use Test::Script 1.05;
+
+my $tzil
+	= Builder->from_config(
+		{
+			dist_root    => 'corpus/a',
+		},
+		{
+			add_files => {
+				'source/lib/Foo.pm' => "package Foo;\n1;\n",
+				'source/dist.ini' => simple_ini(
+					[ GatherDir => ],
+					[ MakeMaker => ],
+					[ ExtraTests => ],
+					['Test::PodSpelling']
+				)
+			}
+		},
+	);
+
+$tzil->build;
+
+my $fn
+	= $tzil
+	->tempdir
+	->subdir('build')
+	->subdir('t')
+	->file('author-pod-spell.t')
+	;
+
+ok ( -e $fn, 'test file exists');
+
+{
+	my $wd = pushd $tzil->tempdir->subdir('build');
+	$tzil->plugin_named('MakeMaker')->build;
+
+	script_compiles( '' . $fn->relative, 'check test compiles' );
+}
+
+done_testing;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-plugin-test-podspelling-perl.git



More information about the Pkg-perl-cvs-commits mailing list