2 # Copyright (C) 2001-2005, The Perl Foundation.
8 use Test::More tests => 1;
16 qq{$cwd/docs/pdds/draft},
20 foreach my $dir (@pdddirs) {
22 opendir my $DIRH, $dir
23 or croak "Unable to open directory handle: $!";
24 @pdds = map { qq|$dir/$_| } grep { m/^pdd\d{2,}_.*\.pod$/ }
26 closedir $DIRH or croak "Unable to close directory handle: $!";
27 @pddfiles = (@pddfiles, @pdds);
31 foreach my $pdd (@pddfiles) {
32 my $diag = check_pdd_formatting($pdd);
34 push @diagnostics, $diag;
40 $errmsg = join ("\n" => @diagnostics) . "\n";
43 $errmsg ? fail( qq{\n$errmsg} )
44 : pass( q{All PDDs are formatted correctly} );
46 sub check_pdd_formatting {
49 if ($pdd =~ m{((draft/)?[^/]+)$}) {
54 my @sections_needed = qw(
62 my %sections_seen = map { $_, 0 } @sections_needed;
64 tie @lines, 'Tie::File', $pdd
65 or croak "Unable to tie to $pdd: $!";
66 for (my $i=0; $i<=$#lines; $i++) {
68 ( length( $lines[$i] ) > 78 )
70 ( $lines[$i] !~ m/(^(?:L?<)?http|\$Id:\s+)/ )
72 push @toolong, ($i + 1);
74 foreach my $need ( @sections_needed ) {
75 $sections_seen{$need}++ if $lines[$i] =~ m{^=head1\s+$need};
78 untie @lines or croak "Unable to untie from $pdd: $!";
83 qq{ lines > 78 chars: @toolong\n};
85 foreach my $need ( keys %sections_seen ) {
86 if ( ! $sections_seen{$need} ) {
87 $diag .= qq{$base lacks 'head1' $need section\n};
95 # cperl-indent-level: 4
98 # vim: expandtab shiftwidth=4: