From: Max Maischein <corion@corion.net>
Date: Mon, 5 Oct 2009 20:49:09 +0000 (+0200)
Subject: Check POD in lib/, ext/ and pod/
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a67b1afafddaaed84e79a867acc888c9ccfb6460;p=p5sagit%2Fp5-mst-13.2.git

Check POD in lib/, ext/ and pod/
---

diff --git a/MANIFEST b/MANIFEST
index 4ab2ea9..7f11067 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4438,6 +4438,7 @@ t/porting/checkcase.t		Check whether we are case-insensitive-fs-friendly
 t/porting/diag.t		Test completeness of perldiag.pod
 t/porting/maintainers.t		Test that Porting/Maintaners.pl is up to date
 t/porting/manifest.t		Test that this MANIFEST file is well formed
+t/porting/podcheck.t		Test the POD of shipped modules is well formed
 t/README			Instructions for regression tests
 t/re/pat_advanced.t		See if advanced esoteric patterns work
 t/re/pat_advanced_thr.t		See if advanced esoteric patterns work in another thread
diff --git a/t/porting/podcheck.t b/t/porting/podcheck.t
new file mode 100644
index 0000000..d52d66d
--- /dev/null
+++ b/t/porting/podcheck.t
@@ -0,0 +1,85 @@
+#!/usr/bin/perl -w
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+}
+
+use strict;
+
+# Somewhere we chdir and can't load any more modules...
+BEGIN {
+    if ($^O eq 'MSWin32') {
+        require Win32;
+    };
+    require overload;
+};
+
+use Test::More;
+use File::Find ();
+
+{
+    package My::Pod::Checker;
+    use strict;
+    use parent 'Pod::Checker';
+
+    use vars '@errors'; # a bad, bad hack!
+
+    sub poderror {
+        my $self = shift;
+        my $opts;
+        if (ref $_[0]) {
+            $opts = shift;
+        };
+        ++($self->{_NUM_ERRORS})
+            if(!$opts || ($opts->{-severity} && $opts->{-severity} eq 'ERROR'));
+        ++($self->{_NUM_WARNINGS})
+            if(!$opts || ($opts->{-severity} && $opts->{-severity} eq 'WARNING'));
+        push @errors, $opts;
+    };
+}
+
+my @files = @ARGV;
+if (! @files) {
+    chdir '..'
+        or die "Couldn't chdir to ..: $!";
+    chomp( my @d = <DATA> );
+    File::Find::find({
+        no_chdir => 1,
+        wanted   => sub {
+                return unless $File::Find::name =~ /(\.(pod|pm|pl))$/i;
+                push @files, $File::Find::name;
+            },
+        }, grep { m!/$! } @d );
+    push @files, map { chomp; glob($_) } grep { ! m!/$! } @d;
+    @files = sort @files; # so we get consistent results
+};
+
+sub pod_ok {
+    my ($filename) = @_;
+    local @My::Pod::Checker::errors;
+    my $checker = My::Pod::Checker->new(-quiet => 1);
+    $checker->parse_from_file($filename, undef);
+    my $error_count = $checker->num_errors();
+
+    if(! ok $error_count <= 0, "POD of $filename") {
+        diag( "'$filename' contains POD errors" );
+        diag sprintf "%s %s: %s at line %s",
+             $_->{-severity}, $_->{-file}, $_->{-msg}, $_->{-line}
+            for @My::Pod::Checker::errors;
+    };
+};
+
+plan tests => scalar @files;
+
+pod_ok $_
+    for @files;
+
+__DATA__
+lib/
+ext/
+pod/
+AUTHORS
+Changes
+INSTALL
+README*
+*.pod
\ No newline at end of file