[svn:parrot] r36740 - in branches/update_pod: lib/Parrot/Test/Pod t/codingstd
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Sun Feb 15 01:35:14 UTC 2009
Author: jkeenan
Date: Sun Feb 15 01:35:13 2009
New Revision: 36740
URL: https://trac.parrot.org/parrot/changeset/36740
Log:
Refactor more code out of two test files and into Parrot::Test::Pod::Util.
Modified:
branches/update_pod/lib/Parrot/Test/Pod/Util.pm
branches/update_pod/t/codingstd/pod_description.t
branches/update_pod/t/codingstd/pod_syntax.t
branches/update_pod/t/codingstd/pod_todo.t
Modified: branches/update_pod/lib/Parrot/Test/Pod/Util.pm
==============================================================================
--- branches/update_pod/lib/Parrot/Test/Pod/Util.pm Sun Feb 15 01:01:54 2009 (r36739)
+++ branches/update_pod/lib/Parrot/Test/Pod/Util.pm Sun Feb 15 01:35:13 2009 (r36740)
@@ -4,13 +4,57 @@
use strict;
use warnings;
use Carp;
-use Storable qw(nstore retrieve);
+use ExtUtils::Manifest qw(maniread);
use Pod::Find qw(contains_pod);
-use Exporter;
-our @ISA = qw( Exporter );
-our @EXPORT_OK = qw(
- identify_files_for_POD_testing
- oreilly_summary_malformed
+use Storable qw(nstore retrieve);
+use lib qw( lib );
+use Parrot::Config;
+
+our %second_analysis_subs = (
+ oreilly_summary_malformed => sub {
+ my ($files_needing_analysis, $build_dir) = @_;
+ my $sto = q{.pod_examinable_oreilly_summary_malformed.sto};
+ if ( -e $sto ) {
+ eval { $files_needing_analysis = retrieve($sto) };
+ if ($@) {
+ croak "$sto exists on disk but could not retrieve from it";
+ }
+ else {
+ return $files_needing_analysis;
+ }
+ }
+ else {
+ SECOND_FILE: foreach my $file ( keys %{ $files_needing_analysis } ) {
+ my $full_file = qq|$build_dir/$file|;
+
+ # Skip the book, because it uses extended O'Reilly-specific POD
+ if ($full_file =~ m{docs/book/}) {
+ delete $files_needing_analysis->{ $file };
+ next SECOND_FILE;
+ }
+
+ # skip POD generating scripts
+ if ($full_file =~ m/ops_summary\.pl/) {
+ delete $files_needing_analysis->{ $file };
+ next SECOND_FILE;
+ }
+
+ # skip file which includes malformed POD for
+ # other testing purposes
+ if ($full_file =~ m{
+ t/tools/dev/searchops/samples\.pm
+ |
+ languages/pod/test\.pod
+ }x
+ ) {
+ delete $files_needing_analysis->{ $file };
+ next SECOND_FILE;
+ }
+ }
+ }
+ nstore $files_needing_analysis, $sto;
+ return $files_needing_analysis;
+ },
);
=head1 Parrot::Test::Pod::Util
@@ -19,9 +63,7 @@
=head2 Synopsis
- use Parrot::Test::Pod::Util qw(
- identify_files_for_POD_testing
- );
+ use Parrot::Test::Pod::Util;
=head2 Description
@@ -32,6 +74,28 @@
=head2 Functions
+=cut
+
+# RT #44437 this should really be using src_dir instead of build_dir but it
+# does not exist (yet)
+
+sub new {
+ my $class = shift;
+ my $args = shift;
+ $args->{build_dir} = $PConfig{build_dir};
+
+ croak "Cannot run test if build_dir does not yet exist"
+ unless -d $args->{build_dir};
+ croak "Test cannot be run unless MANIFEST exists in build dir"
+ unless -f "$args->{build_dir}/MANIFEST";
+ croak "Test cannot be run unless MANIFEST exists in build dir"
+ unless -f "$args->{build_dir}/MANIFEST.generated";
+
+ $args->{manifest} = maniread("$args->{build_dir}/MANIFEST");
+ $args->{manifest_gen} = maniread("$args->{build_dir}/MANIFEST.generated");
+ return bless $args, $class;
+}
+
=head3 C<identify_files_for_POD_testing()>
B<Purpose:>
@@ -44,12 +108,8 @@
B<Arguments:>
- $need_testing_ref = identify_files_for_POD_testing( {
- argv => [ @ARGV ],
- manifest => $manifest,
- manifest_gen => $manifest_gen,
- build_dir => $build_dir,
- second_analysis => \&oreilly_summary_malformed,
+ $need_testing_ref = $self->identify_files_for_POD_testing( {
+ second_analysis => 'oreilly_summary_malformed',
} );
B<Return Value:>
@@ -69,6 +129,7 @@
=cut
sub identify_files_for_POD_testing {
+ my $self = shift;
my $args = shift;
my $files_needing_analysis = {};
@@ -82,22 +143,22 @@
else {
# go to second-level analysis
$files_needing_analysis =
- $args->{second_analysis}(
+ $second_analysis_subs{$args->{second_analysis}}(
$files_needing_analysis,
- $args->{build_dir}
+ $self->{build_dir},
);
}
}
else {
my @files;
- if ( scalar(@{ $args->{argv} }) ) {
- @files = @{ $args->{argv} };
+ if ( scalar(@{ $self->{argv} }) ) {
+ @files = @{ $self->{argv} };
}
else {
print STDERR "\nFinding files with POD, this may take a minute.\n";
@files = (
- keys(%{ $args->{manifest} }),
- keys(%{ $args->{manifest_gen} })
+ keys(%{ $self->{manifest} }),
+ keys(%{ $self->{manifest_gen} })
);
}
$files_needing_analysis->{$_}++ for @files;
@@ -111,7 +172,7 @@
# do FIRST_FILE
FIRST_FILE: foreach my $file ( keys %{ $files_needing_analysis } ) {
- my $full_file = qq|$args->{build_dir}/$file|;
+ my $full_file = qq|$self->{build_dir}/$file|;
# skip missing MANIFEST.generated files ( -e )
# skip binary files # (including .pbc files) ( -B )
@@ -131,9 +192,9 @@
nstore $files_needing_analysis, $sto;
# go to second-level analysis
$files_needing_analysis =
- $args->{second_analysis}(
+ $second_analysis_subs{$args->{second_analysis}}(
$files_needing_analysis,
- $args->{build_dir}
+ $self->{build_dir},
);
}
@@ -188,57 +249,12 @@
=cut
-sub oreilly_summary_malformed {
- my ($files_needing_analysis, $build_dir) = @_;
- my $sto = q{.pod_examinable_oreilly_summary_malformed.sto};
- if ( -e $sto ) {
- eval { $files_needing_analysis = retrieve($sto) };
- if ($@) {
- croak "$sto exists on disk but could not retrieve from it";
- }
- else {
- return $files_needing_analysis;
- }
- }
- else {
- SECOND_FILE: foreach my $file ( keys %{ $files_needing_analysis } ) {
- my $full_file = qq|$build_dir/$file|;
-
- # Skip the book, because it uses extended O'Reilly-specific POD
- if ($full_file =~ m{docs/book/}) {
- delete $files_needing_analysis->{ $file };
- next SECOND_FILE;
- }
-
- # skip POD generating scripts
- if ($full_file =~ m/ops_summary\.pl/) {
- delete $files_needing_analysis->{ $file };
- next SECOND_FILE;
- }
-
- # skip file which includes malformed POD for other testing purposes
- if ($full_file =~ m{
- t/tools/dev/searchops/samples\.pm
- |
- languages/pod/test\.pod
- }x
- ) {
- delete $files_needing_analysis->{ $file };
- next SECOND_FILE;
- }
- }
- }
- nstore $files_needing_analysis, $sto;
- return $files_needing_analysis;
-}
-
=head2 Author
James E Keenan, refactored from earlier code
=cut
-
1;
# Local Variables:
Modified: branches/update_pod/t/codingstd/pod_description.t
==============================================================================
--- branches/update_pod/t/codingstd/pod_description.t Sun Feb 15 01:01:54 2009 (r36739)
+++ branches/update_pod/t/codingstd/pod_description.t Sun Feb 15 01:35:13 2009 (r36740)
@@ -7,13 +7,8 @@
use Carp;
use Test::More;
-use ExtUtils::Manifest qw(maniread);
use lib qw( lib );
-use Parrot::Config;
-use Parrot::Test::Pod::Util qw(
- identify_files_for_POD_testing
- oreilly_summary_malformed
-);
+use Parrot::Test::Pod::Util;
BEGIN {
eval 'use Pod::Simple';
@@ -23,36 +18,21 @@
}
}
-plan tests => 1;
+plan tests => 2;
-# RT #44437 this should really be using src_dir instead of build_dir but it
-# does not exist (yet)
-my $build_dir = $PConfig{build_dir};
-#print STDERR $build_dir, "\n";
-
-croak "Cannot run test if build_dir does not yet exist"
- unless -d $build_dir;
-croak "Test cannot be run unless MANIFEST exists in build dir"
- unless -f "$build_dir/MANIFEST";
-croak "Test cannot be run unless MANIFEST exists in build dir"
- unless -f "$build_dir/MANIFEST.generated";
-
-my $manifest = maniread("$build_dir/MANIFEST");
-my $manifest_gen = maniread("$build_dir/MANIFEST.generated");
-
-my $need_testing_ref = identify_files_for_POD_testing( {
- argv => [ @ARGV ],
- manifest => $manifest,
- manifest_gen => $manifest_gen,
- build_dir => $build_dir,
- second_analysis => \&oreilly_summary_malformed,
+my $self = Parrot::Test::Pod::Util->new( {
+ argv => [ @ARGV ],
+} );
+ok( defined $self, "Parrot::Test::Pod::Util returned defined value" );
+
+my $need_testing_ref = $self->identify_files_for_POD_testing( {
+ second_analysis => 'oreilly_summary_malformed',
} );
my @empty_description;
foreach my $file ( @{ $need_testing_ref } ) {
- # skip files with valid POD
- #check DESCRIPTION section on valid POD files
+ # check DESCRIPTION section on valid POD files
if ( file_pod_ok($file) and empty_description($file) ) {
push @empty_description, $file;
}
Modified: branches/update_pod/t/codingstd/pod_syntax.t
==============================================================================
--- branches/update_pod/t/codingstd/pod_syntax.t Sun Feb 15 01:01:54 2009 (r36739)
+++ branches/update_pod/t/codingstd/pod_syntax.t Sun Feb 15 01:35:13 2009 (r36740)
@@ -4,16 +4,10 @@
use strict;
use warnings;
-
use Carp;
use Test::More;
-use ExtUtils::Manifest qw(maniread);
use lib qw( lib );
-use Parrot::Config;
-use Parrot::Test::Pod::Util qw(
- identify_files_for_POD_testing
- oreilly_summary_malformed
-);
+use Parrot::Test::Pod::Util;
BEGIN {
eval 'use Pod::Simple';
@@ -23,29 +17,15 @@
}
}
-plan tests => 1;
+plan tests => 2;
+
+my $self = Parrot::Test::Pod::Util->new( {
+ argv => [ @ARGV ],
+} );
+ok( defined $self, "Parrot::Test::Pod::Util returned defined value" );
-# RT #44437 this should really be using src_dir instead of build_dir but it
-# does not exist (yet)
-my $build_dir = $PConfig{build_dir};
-#print STDERR $build_dir, "\n";
-
-croak "Cannot run test if build_dir does not yet exist"
- unless -d $build_dir;
-croak "Test cannot be run unless MANIFEST exists in build dir"
- unless -f "$build_dir/MANIFEST";
-croak "Test cannot be run unless MANIFEST exists in build dir"
- unless -f "$build_dir/MANIFEST.generated";
-
-my $manifest = maniread("$build_dir/MANIFEST");
-my $manifest_gen = maniread("$build_dir/MANIFEST.generated");
-
-my $need_testing_ref = identify_files_for_POD_testing( {
- argv => [ @ARGV ],
- manifest => $manifest,
- manifest_gen => $manifest_gen,
- build_dir => $build_dir,
- second_analysis => \&oreilly_summary_malformed,
+my $need_testing_ref = $self->identify_files_for_POD_testing( {
+ second_analysis => 'oreilly_summary_malformed',
} );
my @failed_syntax;
Modified: branches/update_pod/t/codingstd/pod_todo.t
==============================================================================
--- branches/update_pod/t/codingstd/pod_todo.t Sun Feb 15 01:01:54 2009 (r36739)
+++ branches/update_pod/t/codingstd/pod_todo.t Sun Feb 15 01:35:13 2009 (r36740)
@@ -2,30 +2,6 @@
# Copyright (C) 2001-2009, The Perl Foundation.
# $Id$
-=head1 NAME
-
-t/doc/pod_todo.t - find todo items in pod files
-
-=head1 SYNOPSIS
-
- # test all files
- % prove t/doc/pod_todo.t
-
- # test specific files
- % perl t/doc/pod_todo.t perl_module.pm perl_file.pl
-
-=head1 DESCRIPTION
-
-Tests the all files listed in F<MANIFEST> and F<MANIFEST.generated> that
-appear to contain Pod markup for any todo items. If any files contain the
-string 'TODO', 'FIXME' or 'XXX', they are reported in the test output.
-
-=head1 AUTHOR
-
-Paul Cochrane <paultcochrane at gmail dot com>; stolen from t/doc/pod.t
-
-=cut
-
use strict;
use warnings;
@@ -115,6 +91,30 @@
}
}
+=head1 NAME
+
+t/doc/pod_todo.t - find todo items in pod files
+
+=head1 SYNOPSIS
+
+ # test all files
+ % prove t/doc/pod_todo.t
+
+ # test specific files
+ % perl t/doc/pod_todo.t perl_module.pm perl_file.pl
+
+=head1 DESCRIPTION
+
+Tests the all files listed in F<MANIFEST> and F<MANIFEST.generated> that
+appear to contain Pod markup for any todo items. If any files contain the
+string 'TODO', 'FIXME' or 'XXX', they are reported in the test output.
+
+=head1 AUTHOR
+
+Paul Cochrane <paultcochrane at gmail dot com>; stolen from t/doc/pod.t
+
+=cut
+
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
More information about the parrot-commits
mailing list