Mark all .t and .pm files as non executable
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / pod-spelling.t
index 3ac4f75..41c9027 100644 (file)
@@ -1,14 +1,22 @@
 #!/usr/bin/perl
 #
 # t/pod-spelling.t -- Test POD spelling.
+#
+# Copyright 2008 Russ Allbery <rra@stanford.edu>
+#
+# This program is free software; you may redistribute it and/or modify it
+# under the same terms as Perl itself.
 
 # Called to skip all tests with a reason.
 sub skip_all {
-    print "1..1\n";
-    print "ok 1 # skip - @_\n";
+    print "1..0 # Skipped: @_\n";
     exit;
 }
 
+# Skip all spelling tests unless flagged to run maintainer tests.
+skip_all "Spelling tests only run for maintainer"
+    unless $ENV{RRA_MAINTAINER_TESTS};
+
 # Make sure we have prerequisites.  hunspell is currently not supported due to
 # lack of support for contractions.
 eval 'use Test::Pod 1.00';
@@ -16,13 +24,17 @@ skip_all "Test::Pod 1.00 required for testing POD" if $@;
 eval 'use Pod::Spell';
 skip_all "Pod::Spell required to test POD spelling" if $@;
 my @spell;
-for my $dir (split ':', $ENV{PATH}) {
-    if (-x "$dir/ispell") {
-        @spell = ("$dir/ispell", '-d', 'american', '-l');
+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;
     }
-    last if @spell;
 }
-skip_all "ispell required to test POD spelling" unless @spell;
+skip_all "aspell or ispell required to test POD spelling" unless @spell;
 
 # Run the test, one for each POD file.
 $| = 1;
@@ -35,7 +47,8 @@ for my $pod (@pod) {
     if (not defined $child) {
         die "Cannot fork: $!\n";
     } elsif ($child == 0) {
-        my $pid = open (SPELL, '|-', @spell) or die "Cannot run @spell: $!\n";
+        my $pid = open (SPELL, '|-', @spell)
+            or die "Cannot run @spell: $!\n";
         open (POD, '<', $pod) or die "Cannot open $pod: $!\n";
         my $parser = Pod::Spell->new;
         $parser->parse_from_filehandle (\*POD, \*SPELL);
@@ -46,7 +59,7 @@ for my $pod (@pod) {
         my @words = <CHILD>;
         close CHILD;
         if ($? != 0) {
-            print "ok $n # skip - @spell failed\n";
+            print "ok $n # skip - @spell failed: $?\n";
         } elsif (@words) {
             for (@words) {
                 s/^\s+//;