This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
improve api entries for hv_clear() and hv_undef()
[perl5.git] / t / porting / podcheck.t
CommitLineData
a67b1afa 1#!/usr/bin/perl -w
f7b649f0
NC
2
3require './test.pl';
a67b1afa
MM
4
5use strict;
6
a67b1afa
MM
7{
8 package My::Pod::Checker;
9 use strict;
10 use parent 'Pod::Checker';
11
12 use vars '@errors'; # a bad, bad hack!
13
14 sub poderror {
15 my $self = shift;
16 my $opts;
17 if (ref $_[0]) {
18 $opts = shift;
19 };
20 ++($self->{_NUM_ERRORS})
21 if(!$opts || ($opts->{-severity} && $opts->{-severity} eq 'ERROR'));
22 ++($self->{_NUM_WARNINGS})
23 if(!$opts || ($opts->{-severity} && $opts->{-severity} eq 'WARNING'));
24 push @errors, $opts;
25 };
26}
27
69f6a9a1
JV
28
29use strict;
30use File::Spec;
f1b865f4 31s{^\.\./lib$}{lib} for @INC;
69f6a9a1
JV
32chdir '..';
33my @files;
34my $manifest = 'MANIFEST';
35
36open my $m, '<', $manifest or die "Can't open '$manifest': $!";
37
38while (<$m>) {
39 chomp;
40 next unless /\s/; # Ignore lines without whitespace (i.e., filename only)
41 my ($file, $separator) = /^(\S+)(\s+)/;
42 next if $file =~ /^cpan\//;
43 next unless ($file =~ /\.(?:pm|pod|pl)$/);
94ca8775 44 next if $file eq 'autodoc.pl';
69f6a9a1 45 push @files, $file;
a67b1afa 46};
cc4c9faa 47@files = sort @files; # so we get consistent results
a67b1afa
MM
48
49sub pod_ok {
50 my ($filename) = @_;
51 local @My::Pod::Checker::errors;
52 my $checker = My::Pod::Checker->new(-quiet => 1);
53 $checker->parse_from_file($filename, undef);
54 my $error_count = $checker->num_errors();
55
f7b649f0 56 if(! ok($error_count <= 0, "POD of $filename")) {
a67b1afa 57 diag( "'$filename' contains POD errors" );
f7b649f0
NC
58 diag(sprintf "%s %s: %s at line %s",
59 $_->{-severity}, $_->{-file}, $_->{-msg}, $_->{-line})
a67b1afa
MM
60 for @My::Pod::Checker::errors;
61 };
62};
63
f7b649f0 64plan (tests => scalar @files);
a67b1afa
MM
65
66pod_ok $_
67 for @files;