diff options
| author | Russ Allbery <rra@stanford.edu> | 2010-02-21 17:45:56 -0800 | 
|---|---|---|
| committer | Russ Allbery <rra@stanford.edu> | 2010-02-21 17:45:56 -0800 | 
| commit | ae14bea1375dd5923d4a73e167b27bee13feb7b7 (patch) | |
| tree | c1222395732cf8ce2cca32f013f080d19736f474 /tests/docs/pod-spelling-t | |
| parent | 57aba51dc26ebf0bdd034f6cb418a9ea5f1fc0be (diff) | |
| parent | 60210334fa3dbd5dd168199063c6ee850d750d0c (diff) | |
Merge commit 'upstream/0.10' into debian
Diffstat (limited to 'tests/docs/pod-spelling-t')
| -rwxr-xr-x | tests/docs/pod-spelling-t | 80 | 
1 files changed, 80 insertions, 0 deletions
| diff --git a/tests/docs/pod-spelling-t b/tests/docs/pod-spelling-t new file mode 100755 index 0000000..6993e4c --- /dev/null +++ b/tests/docs/pod-spelling-t @@ -0,0 +1,80 @@ +#!/usr/bin/perl +# +# Check for spelling errors in POD documentation +# +# Checks all POD files in the tree for spelling problems using Pod::Spell and +# either aspell or ispell.  aspell is preferred.  This test is disabled unless +# RRA_MAINTAINER_TESTS is set, since spelling dictionaries vary too much +# between environments. +# +# Copyright 2008, 2009 Russ Allbery <rra@stanford.edu> +# +# See LICENSE for licensing terms. + +use strict; +use Test::More; + +# Skip all spelling tests unless the maintainer environment variable is set. +plan skip_all => 'spelling tests only run for maintainer' +    unless $ENV{RRA_MAINTAINER_TESTS}; + +# Load required Perl modules. +eval 'use Test::Pod 1.00'; +plan skip_all => 'Test::Pod 1.00 required for testing POD' if $@; +eval 'use Pod::Spell'; +plan skip_all => 'Pod::Spell required to test POD spelling' if $@; + +# Locate a spell-checker.  hunspell is not currently supported due to its lack +# of support for contractions (at least in the version in Debian). +my @spell; +my %options = (aspell => [ qw(-d en_US --home-dir=./ list) ], +               ispell => [ qw(-d american -l -p /dev/null) ]); +SEARCH: for my $program (qw/aspell ispell/) { +    for my $dir (split ':', $ENV{PATH}) { +        if (-x "$dir/$program") { +            @spell = ("$dir/$program", @{ $options{$program} }); +        } +        last SEARCH if @spell; +    } +} +plan skip_all => 'aspell or ispell required to test POD spelling' +    unless @spell; + +# Prerequisites are satisfied, so we're going to do some testing.  Figure out +# what POD files we have and from that develop our plan. +$| = 1; +my @pod = map { +    my $pod = "$ENV{SOURCE}/../" . $_; +    $pod =~ s,[^/.][^/]*/../,,g; +    $pod; +} qw(client/wallet.pod server/keytab-backend server/wallet-admin +     server/wallet-backend server/wallet-report); +plan tests => scalar @pod; + +# Finally, do the checks. +for my $pod (@pod) { +    my $child = open (CHILD, '-|'); +    if (not defined $child) { +        BAIL_OUT ("cannot fork: $!"); +    } elsif ($child == 0) { +        my $pid = open (SPELL, '|-', @spell) +            or BAIL_OUT ("cannot run @spell: $!"); +        open (POD, '<', $pod) or BAIL_OUT ("cannot open $pod: $!"); +        my $parser = Pod::Spell->new; +        $parser->parse_from_filehandle (\*POD, \*SPELL); +        close POD; +        close SPELL; +        exit ($? >> 8); +    } else { +        my @words = <CHILD>; +        close CHILD; +      SKIP: { +            skip "@spell failed for $pod", 1 unless $? == 0; +            for (@words) { +                s/^\s+//; +                s/\s+$//; +            } +            is ("@words", '', $pod); +        } +    } +} | 
