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