Commit | Line | Data |
a67b1afa |
1 | #!/usr/bin/perl -w |
2 | BEGIN { |
3 | chdir 't' if -d 't'; |
4 | @INC = '../lib'; |
5 | } |
6 | |
7 | use strict; |
8 | |
9 | # Somewhere we chdir and can't load any more modules... |
10 | BEGIN { |
11 | if ($^O eq 'MSWin32') { |
12 | require Win32; |
13 | }; |
14 | require overload; |
15 | }; |
16 | |
17 | use 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 | |
41 | use strict; |
42 | use File::Spec; |
43 | chdir '..'; |
44 | my @files; |
45 | my $manifest = 'MANIFEST'; |
46 | |
47 | open my $m, '<', $manifest or die "Can't open '$manifest': $!"; |
48 | |
49 | while (<$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 | |
59 | sub 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 | |
74 | plan tests => scalar @files; |
75 | |
76 | pod_ok $_ |
77 | for @files; |
78 | |
79 | __DATA__ |
80 | lib/ |
81 | ext/ |
82 | pod/ |
83 | AUTHORS |
84 | Changes |
85 | INSTALL |
86 | README* |
9dab8649 |
87 | *.pod |