Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 87 lines (75 sloc) 1.883 kb
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
1 #! perl
076fd47 @mikehh delete VERSION from the test as it has been removed from the pdd docs
mikehh authored
2 # Copyright (C) 2001-2011, Parrot Foundation.
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
3
4 use strict;
5 use warnings;
6
7 use Test::More tests => 1;
8 use Carp;
9 use Tie::File;
10
b9fead9 @Util [t] pdd_format.t - Changed error message to report relative path, for ed...
Util authored
11 my @pdddirs = qw(
12 ./docs/pdds
13 ./docs/pdds/draft
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
14 );
15
16 my @pddfiles = ();
17 foreach my $dir (@pdddirs) {
d0e9f56 @Util [t] pdd_format.t - Include pdd_template.pod when scanning
Util authored
18 die "Directory '$dir' is not found, or not a directory" if not -d $dir;
19
20 my @pdds = glob "$dir/pdd*.pod"
21 or warn "No PDD files found in directory '$dir'";
22
b683e97 @fperrad [codingstd] update test with new requirement of POD documentation
fperrad authored
23 push @pddfiles, @pdds;
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
24 }
25
26 my @diagnostics = ();
27 foreach my $pdd (@pddfiles) {
28 my $diag = check_pdd_formatting($pdd);
29 if ( $diag ) {
30 push @diagnostics, $diag;
31 }
32 }
33
bdf0325 @Util [t] pdd_format.t - Removed duplicate info from error mesage
Util authored
34 for my $msg (@diagnostics) {
35 diag($msg);
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
36 }
bdf0325 @Util [t] pdd_format.t - Removed duplicate info from error mesage
Util authored
37 cmp_ok( scalar(@diagnostics), '==', 0, 'PDDs are formatted correctly' );
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
38
39 sub check_pdd_formatting {
40 my $pdd = shift;
b9fead9 @Util [t] pdd_format.t - Changed error message to report relative path, for ed...
Util authored
41
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
42 my $diag = q{};
43 my @toolong = ();
44 my @sections_needed = qw(
b683e97 @fperrad [codingstd] update test with new requirement of POD documentation
fperrad authored
45 Abstract
46 Description
47 Implementation
48 References
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
49 );
f58251b @Util [t] pdd_format.t - Changed to check the mandatory sections more thorough...
Util authored
50 my %sections_seen;
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
51 my @lines;
52 tie @lines, 'Tie::File', $pdd
53 or croak "Unable to tie to $pdd: $!";
54 for (my $i=0; $i<=$#lines; $i++) {
a610eca @jkeenan Adjust test of conformance of PDDs to coding standards to account for HT...
jkeenan authored
55 if (
56 ( length( $lines[$i] ) > 78 )
57 and
e068fd0 @paultcochrane [codingstd] removing exceptions for SVN Id tags
paultcochrane authored
58 ( $lines[$i] !~ m/^(?:F|L)<|<http/ )
a610eca @jkeenan Adjust test of conformance of PDDs to coding standards to account for HT...
jkeenan authored
59 ) {
60 push @toolong, ($i + 1);
61 }
f58251b @Util [t] pdd_format.t - Changed to check the mandatory sections more thorough...
Util authored
62 if ( $lines[$i] =~ m{^=head2\s+(.+?)\s*$} ) {
63 $sections_seen{$1}++;
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
64 }
65 }
66 untie @lines or croak "Unable to untie from $pdd: $!";
67 if ( @toolong ) {
68 $diag .=
b9fead9 @Util [t] pdd_format.t - Changed error message to report relative path, for ed...
Util authored
69 qq{$pdd has } .
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
70 scalar(@toolong) .
71 qq{ lines > 78 chars: @toolong\n};
72 }
f58251b @Util [t] pdd_format.t - Changed to check the mandatory sections more thorough...
Util authored
73 foreach my $need (@sections_needed) {
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
74 if ( ! $sections_seen{$need} ) {
b9fead9 @Util [t] pdd_format.t - Changed error message to report relative path, for ed...
Util authored
75 $diag .= qq{$pdd lacks 'head2' $need section\n};
86df7f7 @jkeenan Adding t/codingstd/pdd_format.t to check formatting of PDDs in docs/pdds...
jkeenan authored
76 }
77 }
78 return $diag;
79 }
80
81 # Local Variables:
82 # mode: cperl
83 # cperl-indent-level: 4
84 # fill-column: 100
85 # End:
86 # vim: expandtab shiftwidth=4:
Something went wrong with that request. Please try again.