3 # t/pod-spelling.t -- Test POD spelling.
5 # Copyright 2008 Russ Allbery <rra@stanford.edu>
7 # This program is free software; you may redistribute it and/or modify it
8 # under the same terms as Perl itself.
10 # Called to skip all tests with a reason.
12 print "1..0 # Skipped: @_\n";
16 # Skip all spelling tests unless flagged to run maintainer tests.
17 skip_all "Spelling tests only run for maintainer"
18 unless $ENV{RRA_MAINTAINER_TESTS};
20 # Make sure we have prerequisites. hunspell is currently not supported due to
21 # lack of support for contractions.
22 eval 'use Test::Pod 1.00';
23 skip_all "Test::Pod 1.00 required for testing POD" if $@;
24 eval 'use Pod::Spell';
25 skip_all "Pod::Spell required to test POD spelling" if $@;
27 my %options = (aspell => [ qw(-d en_US --home-dir=./ list) ],
28 ispell => [ qw(-d american -l -p /dev/null) ]);
29 SEARCH: for my $program (qw/aspell ispell/) {
30 for my $dir (split ':', $ENV{PATH}) {
31 if (-x "$dir/$program") {
32 @spell = ("$dir/$program", @{ $options{$program} });
34 last SEARCH if @spell;
37 skip_all "aspell or ispell required to test POD spelling" unless @spell;
39 # Run the test, one for each POD file.
41 my @pod = all_pod_files ();
42 my $count = scalar @pod;
46 my $child = open (CHILD, '-|');
47 if (not defined $child) {
48 die "Cannot fork: $!\n";
49 } elsif ($child == 0) {
50 my $pid = open (SPELL, '|-', @spell)
51 or die "Cannot run @spell: $!\n";
52 open (POD, '<', $pod) or die "Cannot open $pod: $!\n";
53 my $parser = Pod::Spell->new;
54 $parser->parse_from_filehandle (\*POD, \*SPELL);
62 print "ok $n # skip - @spell failed: $?\n";
69 print " - Misspelled words found in $pod\n";