[svn:parrot] r36742 - in branches/update_pod: lib/Parrot/Test/Pod t/codingstd
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Sun Feb 15 02:09:59 UTC 2009
Author: jkeenan
Date: Sun Feb 15 02:09:58 2009
New Revision: 36742
URL: https://trac.parrot.org/parrot/changeset/36742
Log:
Re-code pod_todo.t to use Parrot::Test::Pod::Util. Test for presence of
Pod::Simple in Parrot::Test::Pod::Util rather than in each test file.
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 02:07:56 2009 (r36741)
+++ branches/update_pod/lib/Parrot/Test/Pod/Util.pm Sun Feb 15 02:09:58 2009 (r36742)
@@ -6,6 +6,7 @@
use Carp;
use ExtUtils::Manifest qw(maniread);
use Pod::Find qw(contains_pod);
+use Pod::Simple::Text;
use Storable qw(nstore retrieve);
use lib qw( lib );
use Parrot::Config;
@@ -55,6 +56,58 @@
nstore $files_needing_analysis, $sto;
return $files_needing_analysis;
},
+ no_pod_todo => sub {
+ my ($files_needing_analysis, $build_dir) = @_;
+ my $sto = q{.pod_examinable_no_pod_todo.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;
+# }
+ if ($full_file =~ m/(?:pod_todo|fixme)\.t/) {
+ delete $files_needing_analysis->{ $file };
+ next SECOND_FILE;
+ }
+ if (no_pod_todo($full_file)) {
+ delete $files_needing_analysis->{ $file };
+ next SECOND_FILE;
+ }
+ }
+ }
+ nstore $files_needing_analysis, $sto;
+ return $files_needing_analysis;
+ },
);
=head1 Parrot::Test::Pod::Util
@@ -255,6 +308,24 @@
=cut
+# Pulled from Test::Pod
+sub no_pod_todo {
+ my $file = shift;
+ my $checker = Pod::Simple::Text->new;
+
+ my $text;
+ $checker->output_string( \$text );
+ $checker->parse_file($file);
+
+ # if the text contains todo items return false
+ if ( $text =~ m/TODO|FIXME|XXX/ ) {
+ return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
1;
# Local Variables:
Modified: branches/update_pod/t/codingstd/pod_description.t
==============================================================================
--- branches/update_pod/t/codingstd/pod_description.t Sun Feb 15 02:07:56 2009 (r36741)
+++ branches/update_pod/t/codingstd/pod_description.t Sun Feb 15 02:09:58 2009 (r36742)
@@ -8,12 +8,10 @@
use Carp;
use Test::More;
use lib qw( lib );
-use Parrot::Test::Pod::Util;
-
BEGIN {
- eval 'use Pod::Simple';
+ eval 'use Parrot::Test::Pod::Util';
if ($@) {
- plan skip_all => 'Pod::Simple not installed';
+ plan skip_all => 'Prerequisites for Parrot::Test::Pod::Util not satisfied';
exit;
}
}
@@ -50,7 +48,7 @@
);
}
-diag("Found $nempty_description files without DESCRIPTION sections.\n")
+diag("\nFound $nempty_description files without DESCRIPTION sections.\n")
if $nempty_description;
#################### SUBROUTINES ####################
Modified: branches/update_pod/t/codingstd/pod_syntax.t
==============================================================================
--- branches/update_pod/t/codingstd/pod_syntax.t Sun Feb 15 02:07:56 2009 (r36741)
+++ branches/update_pod/t/codingstd/pod_syntax.t Sun Feb 15 02:09:58 2009 (r36742)
@@ -7,12 +7,10 @@
use Carp;
use Test::More;
use lib qw( lib );
-use Parrot::Test::Pod::Util;
-
BEGIN {
- eval 'use Pod::Simple';
+ eval 'use Parrot::Test::Pod::Util';
if ($@) {
- plan skip_all => 'Pod::Simple not installed';
+ plan skip_all => 'Prerequisites for Parrot::Test::Pod::Util not satisfied';
exit;
}
}
Modified: branches/update_pod/t/codingstd/pod_todo.t
==============================================================================
--- branches/update_pod/t/codingstd/pod_todo.t Sun Feb 15 02:07:56 2009 (r36741)
+++ branches/update_pod/t/codingstd/pod_todo.t Sun Feb 15 02:09:58 2009 (r36742)
@@ -5,91 +5,42 @@
use strict;
use warnings;
-use lib qw( . lib ../lib ../../lib );
-
+use Carp;
use Test::More;
-use Parrot::Config;
-use ExtUtils::Manifest qw(maniread);
-
-use vars qw(@failed);
-
+use lib qw( lib );
BEGIN {
- eval 'use Pod::Find';
- if ($@) {
- plan skip_all => 'Pod::Find not installed';
- exit;
- }
- eval 'use Pod::Simple';
+ eval 'use Parrot::Test::Pod::Util';
if ($@) {
- plan skip_all => 'Pod::Simple not installed';
- exit;
- }
- eval 'use Pod::Simple::Text';
- if ($@) {
- plan skip_all => 'Pod::Simple::Text not installed';
+ plan skip_all => 'Prerequisites for Parrot::Test::Pod::Util not satisfied';
exit;
}
}
-plan tests => 1;
+plan tests => 2;
-# RT #44437 this should really be using src_dir insetad of build_dir but it
-# doesn't exist (yet)
-my $build_dir = $PConfig{build_dir};
-my $manifest = maniread("$build_dir/MANIFEST");
-my $manifest_gen = maniread("$build_dir/MANIFEST.generated");
-
-# if we have files passed in at the command line, use them
-my @files;
-if (@ARGV) {
- @files = <@ARGV>;
+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 => 'no_pod_todo',
+} );
+
+my $bad_files = join( "\n", sort @{ $need_testing_ref } );
+my $nbad_files = scalar @{ $need_testing_ref };
+TODO: {
+ local $TODO = "not quite done yet";
+ # only ok if everything passed
+ is(
+ $bad_files,
+ q{},
+ 'No todo items found'
+ );
}
-else {
- diag "finding files with pod, this might take a while.";
- @files = ( sort keys(%$manifest), sort keys(%$manifest_gen) );
-}
-
-foreach my $file (@files) {
- $file = "$build_dir/$file";
- # skip test files looking for todo items as their docs definitely contain
- # todo items: this is how they explain what they're doing.
- next if $file =~ m/pod_todo\.t|fixme\.t/;
-
- # skip binary files (including .pbc files)
- next if -B $file;
-
- # skip missing MANIFEST.generated files
- next unless -e $file;
-
- # skip files without POD
- next unless Pod::Find::contains_pod( $file, 0 );
-
- # skip files without todo items
- next if no_pod_todo($file);
- push @failed, $file;
-}
-
-my $bad_files = join( "\n", @failed );
-is( $bad_files, q{}, 'No todo items found' ); # only ok if everything passed
-
-# Pulled from Test::Pod
-sub no_pod_todo {
- my $file = shift;
- my $checker = Pod::Simple::Text->new;
-
- my $text;
- $checker->output_string( \$text );
- $checker->parse_file($file);
-
- # if the text contains todo items return false
- if ( $text =~ m/TODO|FIXME|XXX/ ) {
- return 0;
- }
- else {
- return 1;
- }
-}
+diag("\nFound $nbad_files files with 'todo', 'fixme' or 'XXX' items.\n")
+ if $nbad_files;
=head1 NAME
More information about the parrot-commits
mailing list