sort @files once, outside the loop.
[p5sagit/p5-mst-13.2.git] / t / porting / podcheck.t
CommitLineData
a67b1afa 1#!/usr/bin/perl -w
f7b649f0 2
3require './test.pl';
a67b1afa 4
5use strict;
6
7# Somewhere we chdir and can't load any more modules...
8BEGIN {
9 if ($^O eq 'MSWin32') {
10 require Win32;
11 };
12 require overload;
13};
14
a67b1afa 15{
16 package My::Pod::Checker;
17 use strict;
18 use parent 'Pod::Checker';
19
20 use vars '@errors'; # a bad, bad hack!
21
22 sub poderror {
23 my $self = shift;
24 my $opts;
25 if (ref $_[0]) {
26 $opts = shift;
27 };
28 ++($self->{_NUM_ERRORS})
29 if(!$opts || ($opts->{-severity} && $opts->{-severity} eq 'ERROR'));
30 ++($self->{_NUM_WARNINGS})
31 if(!$opts || ($opts->{-severity} && $opts->{-severity} eq 'WARNING'));
32 push @errors, $opts;
33 };
34}
35
69f6a9a1 36
37use strict;
38use File::Spec;
39chdir '..';
40my @files;
41my $manifest = 'MANIFEST';
42
43open my $m, '<', $manifest or die "Can't open '$manifest': $!";
44
45while (<$m>) {
46 chomp;
47 next unless /\s/; # Ignore lines without whitespace (i.e., filename only)
48 my ($file, $separator) = /^(\S+)(\s+)/;
49 next if $file =~ /^cpan\//;
50 next unless ($file =~ /\.(?:pm|pod|pl)$/);
51 push @files, $file;
a67b1afa 52};
cc4c9faa 53@files = sort @files; # so we get consistent results
a67b1afa 54
55sub pod_ok {
56 my ($filename) = @_;
57 local @My::Pod::Checker::errors;
58 my $checker = My::Pod::Checker->new(-quiet => 1);
59 $checker->parse_from_file($filename, undef);
60 my $error_count = $checker->num_errors();
61
f7b649f0 62 if(! ok($error_count <= 0, "POD of $filename")) {
a67b1afa 63 diag( "'$filename' contains POD errors" );
f7b649f0 64 diag(sprintf "%s %s: %s at line %s",
65 $_->{-severity}, $_->{-file}, $_->{-msg}, $_->{-line})
a67b1afa 66 for @My::Pod::Checker::errors;
67 };
68};
69
f7b649f0 70plan (tests => scalar @files);
a67b1afa 71
72pod_ok $_
73 for @files;
74
75__DATA__
76lib/
77ext/
78pod/
79AUTHORS
80Changes
81INSTALL
82README*
9dab8649 83*.pod