[Bps-public-commit] test-spelling branch, set-pod-parser, created. 5bee432b31386332b676b99a5658824231d41e2f
Thomas Sibley
trs at bestpractical.com
Mon Dec 17 14:48:08 EST 2012
The branch, set-pod-parser has been created
at 5bee432b31386332b676b99a5658824231d41e2f (commit)
- Log -----------------------------------------------------------------
commit 2fa8464648ea69d0ce14aa80af1b24e28dee8502
Author: Ivan Tubert-Brohman <itub at cpan.org>
Date: Tue Aug 2 18:36:39 2005 -0800
initial import of Test-Spelling 0.10 from CPAN
git-cpan-module: Test-Spelling
git-cpan-version: 0.10
git-cpan-authorid: ITUB
git-cpan-file: authors/id/I/IT/ITUB/Test-Spelling-0.10.tar.gz
diff --git a/Changes b/Changes
new file mode 100644
index 0000000..0bf754b
--- /dev/null
+++ b/Changes
@@ -0,0 +1,5 @@
+Revision history for Test-Spelling
+
+0.10 2005-08-02
+ - First version
+
diff --git a/MANIFEST b/MANIFEST
new file mode 100644
index 0000000..dbfd90b
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,8 @@
+Changes
+lib/Test/Spelling.pm
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+t/load.t
+t/pod.t
diff --git a/META.yml b/META.yml
new file mode 100644
index 0000000..57c610b
--- /dev/null
+++ b/META.yml
@@ -0,0 +1,14 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Test-Spelling
+version: 0.10
+version_from: lib/Test/Spelling.pm
+installdirs: site
+requires:
+ File::Spec: 0
+ Pod::Spell: 1.01
+ Test::Builder::Tester: 0
+ Test::More: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..e56a6aa
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,14 @@
+use 5.006;
+use ExtUtils::MakeMaker;
+
+WriteMakefile (
+ 'NAME' => 'Test::Spelling',
+ 'VERSION_FROM' => 'lib/Test/Spelling.pm',
+ 'PREREQ_PM' => {
+ 'Pod::Spell' => '1.01',
+ 'Test::More' => 0,
+ 'Test::Builder::Tester' => 0,
+ 'File::Spec' => 0,
+ },
+);
+
diff --git a/README b/README
new file mode 100644
index 0000000..1f7bec1
--- /dev/null
+++ b/README
@@ -0,0 +1,54 @@
+Test::Spelling version 0.10
+===========================
+
+ "Test::Spelling" lets you check the spelling of a POD file, and report
+ its results in standard "Test::Simple" fashion. This module requires the
+ spell program.
+
+ use Test::More;
+ use Test::Spelling;
+ plan tests => $num_tests;
+ pod_file_spelling_ok( $file, "POD file spelling OK" );
+
+ Module authors can include the following in a t/pod_spell.t file and
+ have "Test::Spelling" automatically find and check all POD files in a
+ module distribution:
+
+ use Test::More;
+ use Test::Spelling;
+ all_pod_files_spelling_ok();
+
+ Note, however that it is not really recommended to include this test
+ with a CPAN distribution, or a package that will run in an uncontrolled
+ environment, because there's no way of predicting if spell will be
+ available or the wordlist used will give the same results (what if it's
+ in a different language, for example?).
+
+ You can add your own stopwords (words that should be ignored by the
+ spell check):
+
+ add_stopwords(qw(adsf thiswordiscorrect));
+
+INSTALLATION
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+
+DEPENDENCIES
+ perl-5.6.0+
+ Pod::Spell 1.01
+ Test::More 0
+ Test::Builder::Tester 0
+ File::Spec 0
+
+
+COPYRIGHT AND LICENSE
+
+Copyright (C) 2005 Ivan Tubert-Brohman <itub at cpan.org>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
new file mode 100644
index 0000000..6ed4fd2
--- /dev/null
+++ b/lib/Test/Spelling.pm
@@ -0,0 +1,284 @@
+package Test::Spelling;
+
+use 5.006;
+use strict;
+use Pod::Spell;
+use Test::Builder;
+use File::Spec;
+use IPC::Open2;
+
+our $VERSION = '0.10';
+
+my $Test = Test::Builder->new;
+my $Spell_cmd = 'spell';
+
+sub import {
+ my $self = shift;
+ my $caller = caller;
+ no strict 'refs';
+ *{$caller.'::pod_file_spelling_ok'} = \&pod_file_spelling_ok;
+ *{$caller.'::all_pod_files_spelling_ok'} = \&all_pod_files_spelling_ok;
+ *{$caller.'::add_stopwords'} = \&add_stopwords;
+ *{$caller.'::set_spell_cmd'} = \&set_spell_cmd;
+ *{$caller.'::all_pod_files'} = \&all_pod_files
+ unless defined &{$caller. '::all_pod_files'};
+
+ $Test->exported_to($caller);
+ $Test->plan(@_);
+}
+
+
+sub pod_file_spelling_ok {
+ my $file = shift;
+ my $name = @_ ? shift : "POD spelling for $file";
+
+ if ( !-f $file ) {
+ $Test->ok( 0, $name );
+ $Test->diag( "$file does not exist" );
+ return;
+ }
+
+ my $checker = Pod::Spell->new;
+ my($fh_in, $fh_out);
+ my $pid = open2($fh_in, $fh_out, $Spell_cmd);
+
+ $checker->parse_from_file($file, $fh_out);
+ close $fh_out or die;
+ my @words = <$fh_in>;
+ close $fh_in or die;
+
+ chomp for @words;
+ @words = grep { !$Pod::Wordlist::Wordlist{$_} } @words;
+ my %seen;
+ @seen{@words} = ();
+ @words = map " $_\n", sort keys %seen;
+
+ my $ok = !@words;
+ $Test->ok( $ok, $name );
+ if ( !$ok ) {
+ $Test->diag("Errors:\n" . join '', @words);
+ }
+
+ return $ok;
+}
+
+sub all_pod_files_spelling_ok {
+ my @files = all_pod_files(@_);
+
+ $Test->plan( tests => scalar @files );
+
+ my $ok = 1;
+ foreach my $file ( @files ) {
+ pod_file_spelling_ok( $file, ) or undef $ok;
+ }
+ return $ok;
+}
+
+sub all_pod_files {
+ my @queue = @_ ? @_ : _starting_points();
+ my @pod = ();
+
+ while ( @queue ) {
+ my $file = shift @queue;
+ if ( -d $file ) {
+ local *DH;
+ opendir DH, $file or next;
+ my @newfiles = readdir DH;
+ closedir DH;
+
+ @newfiles = File::Spec->no_upwards( @newfiles );
+ @newfiles = grep { $_ ne "CVS" && $_ ne ".svn" } @newfiles;
+
+ push @queue, map "$file/$_", @newfiles;
+ }
+ if ( -f $file ) {
+ push @pod, $file if _is_perl( $file );
+ }
+ } # while
+ return @pod;
+}
+
+sub _starting_points {
+ return 'blib' if -e 'blib';
+ return 'lib';
+}
+
+sub _is_perl {
+ my $file = shift;
+
+ return 1 if $file =~ /\.PL$/;
+ return 1 if $file =~ /\.p(l|m|od)$/;
+ return 1 if $file =~ /\.t$/;
+
+ local *FH;
+ open FH, $file or return;
+ my $first = <FH>;
+ close FH;
+
+ return 1 if defined $first && ($first =~ /^#!.*perl/);
+
+ return;
+}
+
+
+sub add_stopwords {
+ for (@_) {
+ my $word = $_;
+ chomp $word;
+ next if $word =~ /^# Error:/ or $word =~ /^# Looks like/
+ or $word =~ /Failed test/;
+ $word =~ s/^#\s*//;
+ $Pod::Wordlist::Wordlist{$word} = 1;
+ }
+}
+
+sub set_spell_cmd {
+ $Spell_cmd = shift;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::Spelling - check for spelling errors in POD files
+
+=head1 SYNOPSIS
+
+C<Test::Spelling> lets you check the spelling of a POD file, and report
+its results in standard C<Test::Simple> fashion. This module requires the
+F<spell> program.
+
+ use Test::More;
+ use Test::Spelling;
+ plan tests => $num_tests;
+ pod_file_spelling_ok( $file, "POD file spelling OK" );
+
+Module authors can include the following in a F<t/pod_spell.t> file and
+have C<Test::Spelling> automatically find and check all POD files in a
+module distribution:
+
+ use Test::More;
+ use Test::Spelling;
+ all_pod_files_spelling_ok();
+
+Note, however that it is not really recommended to include this test with a
+CPAN distribution, or a package that will run in an uncontrolled environment,
+because there's no way of predicting if F<spell> will be available or the
+wordlist used will give the same results (what if it's in a different language,
+for example?).
+
+You can add your own stopwords (words that should be ignored by the spell
+check):
+
+ add_stopwords(qw(adsf thiswordiscorrect));
+
+=head1 DESCRIPTION
+
+Check POD files for spelling mistakes, using
+C<Pod::Spell> and F<spell> to do the heavy lifting.
+
+=head1 FUNCTIONS
+
+=head2 pod_file_spelling_ok( FILENAME[, TESTNAME ] )
+
+C<pod_file_spelling_ok()> will okay the test if the POD has no spelling errors.
+
+When it fails, C<pod_file_spelling_ok()> will show any spelling errors as
+diagnostics.
+
+The optional second argument TESTNAME is the name of the test. If it
+is omitted, C<pod_file_spelling_ok()> chooses a default test name "POD spelling
+for FILENAME".
+
+=head2 all_pod_files_spelling_ok( [@files/@directories] )
+
+Checks all the files in C<@files> for POD spelling. It runs L<all_pod_files()>
+on each file/directory, and calls the C<plan()> function for you (one test for
+each function), so you can't have already called C<plan>.
+
+If C<@files> is empty or not passed, the function finds all POD files in
+the F<blib> directory if it exists, or the F<lib> directory if not.
+A POD file is one that ends with F<.pod>, F<.pl> and F<.pm>, or any file
+where the first line looks like a shebang line.
+
+If you're testing a module, just make a F<t/pod.t>:
+
+ use Test::More;
+ use Test::Spelling;
+ all_pod_files_spelling_ok();
+
+Returns true if all pod files are ok, or false if any fail.
+
+=head2 all_pod_files( [@dirs] )
+
+Returns a list of all the Perl files in I<$dir> and in directories below.
+If no directories are passed, it defaults to F<blib> if F<blib> exists,
+or else F<lib> if not. Skips any files in CVS or .svn directories.
+
+A Perl file is:
+
+=over 4
+
+=item * Any file that ends in F<.PL>, F<.pl>, F<.pm>, F<.pod> or F<.t>.
+
+=item * Any file that has a first line with a shebang and "perl" on it.
+
+=back
+
+The order of the files returned is machine-dependent. If you want them
+sorted, you'll have to sort them yourself.
+
+=head2 add_stopwords(@words)
+
+Add words that should be skipped by the spell check. A suggested use is to list
+these words, one per line, in the __DATA__ section of your test file, and just
+call
+
+ add_stopwords(<DATA>);
+
+As a convenience, C<add_stopwords> will automatically ignore a comment mark and
+one or more spaces from the beginning of the line, and it will ignore lines
+that say '# Error:' or '# Looks like' or /Failed test/. The reason? Let's say
+you run a test and get this result:
+
+ 1..1
+ not ok 1 - POD spelling for lib/Test/Spelling.pm
+ # Failed test (lib/Test/Spelling.pm at line 70)
+ # Errors:
+ # stopwords
+ # Looks like you failed 1 tests of 1.
+
+Let's say you decide that all the words that were marked as errors are really
+correct. The diagnostic lines are printed to STDERR; that means that, if you
+have a decent shell, you can type something like
+
+ perl t/spell.t 2>> t/spell.t
+
+which will append the diagnostic lines to the end of your test file. Assuming
+you already have a __DATA__ line in your test file, that should be enough to
+ensure that the test passes the next time.
+
+=head2 set_spell_cmd($command)
+
+If the F<spell> program has a different name or is not in your path, you can
+specify an alternative with C<set_spell_cmd>. Any command that takes text
+from standard input and prints a list of misspelled words, one per line, to
+standard output will do. For example, you can use C<aspell -l>.
+
+=head1 AUTHOR
+
+Ivan Tubert-Brohman C<< <itub at cpan.org> >>
+
+Heavily based on L<Test::Pod> by Andy Lester and brian d foy.
+
+=head1 COPYRIGHT
+
+Copyright 2004, Ivan Tubert-Brohman, All Rights Reserved.
+
+You may use, modify, and distribute this package under the
+same terms as Perl itself.
+
+=cut
+
diff --git a/t/load.t b/t/load.t
new file mode 100644
index 0000000..c8cf2fb
--- /dev/null
+++ b/t/load.t
@@ -0,0 +1,7 @@
+#!perl -T
+
+use Test::More tests=>1;
+
+BEGIN {
+ use_ok( 'Test::Spelling' );
+}
diff --git a/t/pod.t b/t/pod.t
new file mode 100644
index 0000000..df0c600
--- /dev/null
+++ b/t/pod.t
@@ -0,0 +1,5 @@
+#!perl -Tw
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
commit 54af14d59fee457f7e11bf2f6370eacc6711efd6
Author: Ivan Tubert-Brohman <itub at cpan.org>
Date: Tue Nov 15 18:11:50 2005 -0800
import Test-Spelling 0.11 from CPAN
git-cpan-module: Test-Spelling
git-cpan-version: 0.11
git-cpan-authorid: ITUB
git-cpan-file: authors/id/I/IT/ITUB/Test-Spelling-0.11.tar.gz
diff --git a/Changes b/Changes
index 0bf754b..b5a86ca 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,11 @@
Revision history for Test-Spelling
+0.11 2005-11-15
+ - Some documentation fixes.
+ - Added note about per-file stopwords by Chris Dolan.
+ - Use a temporary file instead of open2() to solve win32 portability
+ issues. (Thanks to Chris Laco!)
+
0.10 2005-08-02
- First version
diff --git a/META.yml b/META.yml
index 57c610b..dead18d 100644
--- a/META.yml
+++ b/META.yml
@@ -1,13 +1,14 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Test-Spelling
-version: 0.10
+version: 0.11
version_from: lib/Test/Spelling.pm
installdirs: site
requires:
+ Carp: 0
File::Spec: 0
+ File::Temp: 0
Pod::Spell: 1.01
- Test::Builder::Tester: 0
Test::More: 0
distribution_type: module
diff --git a/Makefile.PL b/Makefile.PL
index e56a6aa..eae33c4 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -7,8 +7,9 @@ WriteMakefile (
'PREREQ_PM' => {
'Pod::Spell' => '1.01',
'Test::More' => 0,
- 'Test::Builder::Tester' => 0,
'File::Spec' => 0,
+ 'File::Temp' => 0,
+ 'Carp' => 0,
},
);
diff --git a/README b/README
index 1f7bec1..b80a4ae 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Test::Spelling version 0.10
+Test::Spelling version 0.11
===========================
"Test::Spelling" lets you check the spelling of a POD file, and report
@@ -29,6 +29,15 @@ Test::Spelling version 0.10
add_stopwords(qw(adsf thiswordiscorrect));
+ These stopwords are global for the test. See L<Pod::Spell> for a variety of
+ ways to add per-file stopwords to each .pm file.
+
+CHANGES SINCE VERSION 0.10
+ - Some documentation fixes.
+ - Added note about per-file stopwords by Chris Dolan.
+ - Use a temporary file instead of open2() to solve win32 portability
+ issues. (Thanks to Chris Laco!)
+
INSTALLATION
perl Makefile.PL
@@ -43,6 +52,7 @@ DEPENDENCIES
Test::More 0
Test::Builder::Tester 0
File::Spec 0
+ File::Temp 0
COPYRIGHT AND LICENSE
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 6ed4fd2..1524966 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -2,15 +2,18 @@ package Test::Spelling;
use 5.006;
use strict;
+use warnings;
use Pod::Spell;
use Test::Builder;
use File::Spec;
-use IPC::Open2;
+use File::Temp;
+use Carp;
-our $VERSION = '0.10';
+our $VERSION = '0.11';
-my $Test = Test::Builder->new;
-my $Spell_cmd = 'spell';
+my $Test = Test::Builder->new;
+my $Spell_cmd = 'spell';
+my $Spell_temp = File::Temp->new->filename;
sub import {
my $self = shift;
@@ -28,6 +31,8 @@ sub import {
}
+my $Pipe_err = 0;
+
sub pod_file_spelling_ok {
my $file = shift;
my $name = @_ ? shift : "POD spelling for $file";
@@ -38,23 +43,26 @@ sub pod_file_spelling_ok {
return;
}
+ # save digested POD to temp file
my $checker = Pod::Spell->new;
- my($fh_in, $fh_out);
- my $pid = open2($fh_in, $fh_out, $Spell_cmd);
+ $checker->parse_from_file($file, $Spell_temp);
- $checker->parse_from_file($file, $fh_out);
- close $fh_out or die;
- my @words = <$fh_in>;
- close $fh_in or die;
+ # run spell command and fetch output
+ open ASPELL, "$Spell_cmd < $Spell_temp|"
+ or croak "Couldn't run spellcheck command '$Spell_cmd'";
+ my @words = <ASPELL>;
+ close ASPELL or die;
+ # clean up words, remove stopwords, select unique errors
chomp for @words;
@words = grep { !$Pod::Wordlist::Wordlist{$_} } @words;
my %seen;
@seen{@words} = ();
@words = map " $_\n", sort keys %seen;
+ # emit output
my $ok = !@words;
- $Test->ok( $ok, $name );
+ $Test->ok( $ok, "$name");
if ( !$ok ) {
$Test->diag("Errors:\n" . join '', @words);
}
@@ -124,10 +132,9 @@ sub _is_perl {
sub add_stopwords {
for (@_) {
my $word = $_;
- chomp $word;
- next if $word =~ /^# Error:/ or $word =~ /^# Looks like/
- or $word =~ /Failed test/;
- $word =~ s/^#\s*//;
+ $word =~ s/^#?\s*//;
+ $word =~ s/\s+$//;
+ next if $word =~ /\s/ or $word =~ /:/;
$Pod::Wordlist::Wordlist{$word} = 1;
}
}
@@ -166,18 +173,24 @@ module distribution:
Note, however that it is not really recommended to include this test with a
CPAN distribution, or a package that will run in an uncontrolled environment,
because there's no way of predicting if F<spell> will be available or the
-wordlist used will give the same results (what if it's in a different language,
-for example?).
+word list used will give the same results (what if it's in a different language,
+for example?). You can have the test, but don't add it to F<MANIFEST> (or add
+it to F<MANIFEST.SKIP> to make sure you don't add it by accident). Anyway,
+your users don't really need to run this test, as it is unlikely that the
+documentation will acquire typos while in transit. :-)
You can add your own stopwords (words that should be ignored by the spell
check):
- add_stopwords(qw(adsf thiswordiscorrect));
+ add_stopwords(qw(asdf thiswordiscorrect));
+
+These stopwords are global for the test. See L<Pod::Spell> for a variety of
+ways to add per-file stopwords to each .pm file.
=head1 DESCRIPTION
-Check POD files for spelling mistakes, using
-C<Pod::Spell> and F<spell> to do the heavy lifting.
+Check POD files for spelling mistakes, using L<Pod::Spell> and F<spell> to do
+the heavy lifting.
=head1 FUNCTIONS
@@ -203,7 +216,7 @@ the F<blib> directory if it exists, or the F<lib> directory if not.
A POD file is one that ends with F<.pod>, F<.pl> and F<.pm>, or any file
where the first line looks like a shebang line.
-If you're testing a module, just make a F<t/pod.t>:
+If you're testing a module, just make a F<t/spell.t>:
use Test::More;
use Test::Spelling;
@@ -260,6 +273,9 @@ which will append the diagnostic lines to the end of your test file. Assuming
you already have a __DATA__ line in your test file, that should be enough to
ensure that the test passes the next time.
+Also note that L<Pod::Spell> skips words believed to be code, such as words
+in verbatim blocks and code labeled with CE<lt>>.
+
=head2 set_spell_cmd($command)
If the F<spell> program has a different name or is not in your path, you can
@@ -267,6 +283,14 @@ specify an alternative with C<set_spell_cmd>. Any command that takes text
from standard input and prints a list of misspelled words, one per line, to
standard output will do. For example, you can use C<aspell -l>.
+=head1 SEE ALSO
+
+L<Pod::Spell>
+
+=head1 VERSION
+
+0.11
+
=head1 AUTHOR
Ivan Tubert-Brohman C<< <itub at cpan.org> >>
@@ -275,7 +299,7 @@ Heavily based on L<Test::Pod> by Andy Lester and brian d foy.
=head1 COPYRIGHT
-Copyright 2004, Ivan Tubert-Brohman, All Rights Reserved.
+Copyright 2005, Ivan Tubert-Brohman, All Rights Reserved.
You may use, modify, and distribute this package under the
same terms as Perl itself.
diff --git a/t/load.t b/t/load.t
index c8cf2fb..eee7584 100644
--- a/t/load.t
+++ b/t/load.t
@@ -1,5 +1,3 @@
-#!perl -T
-
use Test::More tests=>1;
BEGIN {
diff --git a/t/pod.t b/t/pod.t
index df0c600..437887a 100644
--- a/t/pod.t
+++ b/t/pod.t
@@ -1,4 +1,3 @@
-#!perl -Tw
use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
commit c1054cd6b821c75d29335d6b0e4efba583d8a635
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 11:51:36 2011 -0400
gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b63c3ea
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+*.sw[po]
+.#*
+\#*#
+
+MANIFEST
+MANIFEST.bak
+META.yml
+MYMETA.yml
+Makefile
+Makefile.old
+SIGNATURE
+blib/
+inc/
+pm_to_blib
+
+.cover_db/
+.prove
commit 8f3abd16dcffd973f80b3e249bf3ae24e885d29c
Merge: c1054cd 54af14d
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 11:51:45 2011 -0400
Merge remote branch 'gitpan/master'
commit c6a246551f00df970fc71c8fada4d931334d189b
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 11:53:03 2011 -0400
Stop versioning MANIFEST and META.yml
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644
index dbfd90b..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,8 +0,0 @@
-Changes
-lib/Test/Spelling.pm
-Makefile.PL
-MANIFEST This list of files
-META.yml
-README
-t/load.t
-t/pod.t
diff --git a/META.yml b/META.yml
deleted file mode 100644
index dead18d..0000000
--- a/META.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: Test-Spelling
-version: 0.11
-version_from: lib/Test/Spelling.pm
-installdirs: site
-requires:
- Carp: 0
- File::Spec: 0
- File::Temp: 0
- Pod::Spell: 1.01
- Test::More: 0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
commit 96355994bc6b80770ddcb4dcf1a0d9347b9cafe8
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 11:56:43 2011 -0400
Switch to Module::Install
I will attempt to maintain 5.6 compat until it irritates me :)
diff --git a/Makefile.PL b/Makefile.PL
index eae33c4..57780e4 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,15 +1,13 @@
-use 5.006;
-use ExtUtils::MakeMaker;
-
-WriteMakefile (
- 'NAME' => 'Test::Spelling',
- 'VERSION_FROM' => 'lib/Test/Spelling.pm',
- 'PREREQ_PM' => {
- 'Pod::Spell' => '1.01',
- 'Test::More' => 0,
- 'File::Spec' => 0,
- 'File::Temp' => 0,
- 'Carp' => 0,
- },
-);
+use inc::Module::Install;
+
+name 'Test-Spelling';
+all_from 'lib/Test/Spelling.pm';
+repository 'http://github.com/bestpractical/test-spelling';
+
+requires 'Pod::Spell' => '1.01';
+
+test_requires 'Test::More' => 0;
+test_requires 'File::Temp' => 0;
+
+WriteAll;
commit 17c31d1443b0c1087cbaeb8e0e41caa8a5dc1abb
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:05:19 2011 -0400
Note our maintainership
diff --git a/Changes b/Changes
index b5a86ca..d05e0fd 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
Revision history for Test-Spelling
+0.12 2011-04-25
+ - Best Practical has taken over maintainership of this module
+
0.11 2005-11-15
- Some documentation fixes.
- Added note about per-file stopwords by Chris Dolan.
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 1524966..947a801 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -291,12 +291,16 @@ L<Pod::Spell>
0.11
-=head1 AUTHOR
+=head1 ORIGINAL AUTHOR
Ivan Tubert-Brohman C<< <itub at cpan.org> >>
Heavily based on L<Test::Pod> by Andy Lester and brian d foy.
+=head1 MAINTAINER
+
+Shawn M Moore C<< <sartak at bestpractical.com>
+
=head1 COPYRIGHT
Copyright 2005, Ivan Tubert-Brohman, All Rights Reserved.
commit 437f5ba2d5aa19505e8aaea3425b0104ad771c4e
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:08:38 2011 -0400
Remove VERSION from POD
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 947a801..e7f1a78 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -287,10 +287,6 @@ standard output will do. For example, you can use C<aspell -l>.
L<Pod::Spell>
-=head1 VERSION
-
-0.11
-
=head1 ORIGINAL AUTHOR
Ivan Tubert-Brohman C<< <itub at cpan.org> >>
commit 7df8aafc177e7b0ae096203739aa7d7a81de5fd3
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:12:57 2011 -0400
Remove call to Test::Builder->exported_to
From the doc:
This method isn't terribly useful since modules which share the
same Test::Builder object might get exported to different packages
and only the last one will be honored.
I can reinstate it if needed but I hope no one's depending upon it!
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index e7f1a78..277ec7a 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -26,7 +26,6 @@ sub import {
*{$caller.'::all_pod_files'} = \&all_pod_files
unless defined &{$caller. '::all_pod_files'};
- $Test->exported_to($caller);
$Test->plan(@_);
}
commit 659e000ddc65dc7e723facf717e8a33636ec5d38
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:18:14 2011 -0400
Remove "helpful" call to Test::Builder->plan
If you want a plan, use Test::More's or all_pod_files_spelling_ok
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 277ec7a..04d8d43 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -26,7 +26,6 @@ sub import {
*{$caller.'::all_pod_files'} = \&all_pod_files
unless defined &{$caller. '::all_pod_files'};
- $Test->plan(@_);
}
commit 65db7b7d4c2bde506a71fe30105dc419db19fa09
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:23:12 2011 -0400
Use Exporter instead of reinventing it
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 04d8d43..90a2de4 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -8,6 +8,15 @@ use Test::Builder;
use File::Spec;
use File::Temp;
use Carp;
+use base 'Exporter';
+
+our @EXPORT = qw(
+ pod_file_spelling_ok
+ all_pod_files_spelling_ok
+ add_stopwords
+ set_spell_cmd
+ all_pod_files
+);
our $VERSION = '0.11';
@@ -15,20 +24,6 @@ my $Test = Test::Builder->new;
my $Spell_cmd = 'spell';
my $Spell_temp = File::Temp->new->filename;
-sub import {
- my $self = shift;
- my $caller = caller;
- no strict 'refs';
- *{$caller.'::pod_file_spelling_ok'} = \&pod_file_spelling_ok;
- *{$caller.'::all_pod_files_spelling_ok'} = \&all_pod_files_spelling_ok;
- *{$caller.'::add_stopwords'} = \&add_stopwords;
- *{$caller.'::set_spell_cmd'} = \&set_spell_cmd;
- *{$caller.'::all_pod_files'} = \&all_pod_files
- unless defined &{$caller. '::all_pod_files'};
-
-}
-
-
my $Pipe_err = 0;
sub pod_file_spelling_ok {
commit 27288c032b81bb0ae1d476141d2b5815ece3d888
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:23:32 2011 -0400
Fix a doc typo I just made :)
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 90a2de4..2ac85b4 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -288,7 +288,7 @@ Heavily based on L<Test::Pod> by Andy Lester and brian d foy.
=head1 MAINTAINER
-Shawn M Moore C<< <sartak at bestpractical.com>
+Shawn M Moore C<< <sartak at bestpractical.com> >>
=head1 COPYRIGHT
commit d25c546c09580524e745e51a1f766ae0c9cc0918
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:25:28 2011 -0400
Remove unused $Pipe_err
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 2ac85b4..dad6e2d 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -24,8 +24,6 @@ my $Test = Test::Builder->new;
my $Spell_cmd = 'spell';
my $Spell_temp = File::Temp->new->filename;
-my $Pipe_err = 0;
-
sub pod_file_spelling_ok {
my $file = shift;
my $name = @_ ? shift : "POD spelling for $file";
commit f42e47ee8a557e4b0fa372eec59562fdc61aee96
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:28:36 2011 -0400
Kill EOL whitespace
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index dad6e2d..d27fbee 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -39,7 +39,7 @@ sub pod_file_spelling_ok {
$checker->parse_from_file($file, $Spell_temp);
# run spell command and fetch output
- open ASPELL, "$Spell_cmd < $Spell_temp|"
+ open ASPELL, "$Spell_cmd < $Spell_temp|"
or croak "Couldn't run spellcheck command '$Spell_cmd'";
my @words = <ASPELL>;
close ASPELL or die;
@@ -167,7 +167,7 @@ because there's no way of predicting if F<spell> will be available or the
word list used will give the same results (what if it's in a different language,
for example?). You can have the test, but don't add it to F<MANIFEST> (or add
it to F<MANIFEST.SKIP> to make sure you don't add it by accident). Anyway,
-your users don't really need to run this test, as it is unlikely that the
+your users don't really need to run this test, as it is unlikely that the
documentation will acquire typos while in transit. :-)
You can add your own stopwords (words that should be ignored by the spell
commit 9897ed8c91201601c7df6d9c0e8e41f8f6a64505
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:37:53 2011 -0400
Use a lexical for the tempfile so it's reliably cleaned up [rt.cpan.org #41586]
diff --git a/Changes b/Changes
index d05e0fd..79116f9 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,8 @@ Revision history for Test-Spelling
0.12 2011-04-25
- Best Practical has taken over maintainership of this module
+ - Clean up temporary files more aggressively [rt.cpan.org #41586]
+ (reported by Tokuhiro Matsuno)
0.11 2005-11-15
- Some documentation fixes.
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index d27fbee..1556c77 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -22,7 +22,6 @@ our $VERSION = '0.11';
my $Test = Test::Builder->new;
my $Spell_cmd = 'spell';
-my $Spell_temp = File::Temp->new->filename;
sub pod_file_spelling_ok {
my $file = shift;
@@ -34,12 +33,14 @@ sub pod_file_spelling_ok {
return;
}
+ my $scratch = File::Temp->new->filename;
+
# save digested POD to temp file
my $checker = Pod::Spell->new;
- $checker->parse_from_file($file, $Spell_temp);
+ $checker->parse_from_file($file, $scratch);
# run spell command and fetch output
- open ASPELL, "$Spell_cmd < $Spell_temp|"
+ open ASPELL, "$Spell_cmd < $scratch|"
or croak "Couldn't run spellcheck command '$Spell_cmd'";
my @words = <ASPELL>;
close ASPELL or die;
commit 45f7e77d4c4072b7ffdc7e591196317a4916b312
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 12:41:20 2011 -0400
Correct the aspell suggestion [rt.cpan.org #28967]
diff --git a/Changes b/Changes
index 79116f9..246004e 100644
--- a/Changes
+++ b/Changes
@@ -4,6 +4,8 @@ Revision history for Test-Spelling
- Best Practical has taken over maintainership of this module
- Clean up temporary files more aggressively [rt.cpan.org #41586]
(reported by Tokuhiro Matsuno)
+ - Correct aspell suggestion from -l to list [rt.cpan.org #28967]
+ (reported by David Hand)
0.11 2005-11-15
- Some documentation fixes.
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 1556c77..8046806 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -273,7 +273,7 @@ in verbatim blocks and code labeled with CE<lt>>.
If the F<spell> program has a different name or is not in your path, you can
specify an alternative with C<set_spell_cmd>. Any command that takes text
from standard input and prints a list of misspelled words, one per line, to
-standard output will do. For example, you can use C<aspell -l>.
+standard output will do. For example, you can use C<aspell list>.
=head1 SEE ALSO
commit 56e7ad3f67e7a33e8dfbd5a0505f0136706340a9
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:04:34 2011 -0400
Support for filtering certain pod files, set_pod_file_filter [rt.cpan.org #63755]
diff --git a/Changes b/Changes
index 246004e..0609f2b 100644
--- a/Changes
+++ b/Changes
@@ -6,6 +6,8 @@ Revision history for Test-Spelling
(reported by Tokuhiro Matsuno)
- Correct aspell suggestion from -l to list [rt.cpan.org #28967]
(reported by David Hand)
+ - Add set_pod_file_filter for skipping translations, etc.
+ [rt.cpan.org #63755] (reported by me :))
0.11 2005-11-15
- Some documentation fixes.
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 8046806..2680c6c 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -16,12 +16,14 @@ our @EXPORT = qw(
add_stopwords
set_spell_cmd
all_pod_files
+ set_pod_file_filter
);
our $VERSION = '0.11';
my $Test = Test::Builder->new;
my $Spell_cmd = 'spell';
+my $file_filter = sub { 1 };
sub pod_file_spelling_ok {
my $file = shift;
@@ -92,7 +94,9 @@ sub all_pod_files {
push @queue, map "$file/$_", @newfiles;
}
if ( -f $file ) {
- push @pod, $file if _is_perl( $file );
+ next unless !_is_perl($file);
+ next unless $file_filter->($file);
+ push @pod, $file;
}
} # while
return @pod;
@@ -135,6 +139,10 @@ sub set_spell_cmd {
$Spell_cmd = shift;
}
+sub set_pod_file_filter {
+ $file_filter = shift;
+}
+
1;
__END__
@@ -232,6 +240,9 @@ A Perl file is:
=back
+Furthermore, files for which the filter set by L</set_pod_file_filter> return
+false are skipped. By default this filter passes everything through.
+
The order of the files returned is machine-dependent. If you want them
sorted, you'll have to sort them yourself.
@@ -275,6 +286,20 @@ specify an alternative with C<set_spell_cmd>. Any command that takes text
from standard input and prints a list of misspelled words, one per line, to
standard output will do. For example, you can use C<aspell list>.
+=head2 set_pod_file_filter($code)
+
+If your project has POD documents written in languages other than English, then
+obviously you don't want to be running a spellchecker on every Perl file.
+C<set_pod_file_filter> lets you filter out files returned from
+L</all_pod_files> (and hence, the documents tested by
+L</all_pod_files_spelling_ok>).
+
+ set_pod_file_filter(sub {
+ my $filename = shift;
+ return 0 if $filename =~ /_ja.pod$/; # skip Japanese translations
+ return 1;
+ });
+
=head1 SEE ALSO
L<Pod::Spell>
commit 2c7615c053a10dbcdcba3cc4e1b41cb2d8f64fa9
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:15:19 2011 -0400
Use a lexical filehandle instead of global for spell cmd
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 2680c6c..54431ee 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -42,10 +42,10 @@ sub pod_file_spelling_ok {
$checker->parse_from_file($file, $scratch);
# run spell command and fetch output
- open ASPELL, "$Spell_cmd < $scratch|"
+ open my $spellcheck_results, "$Spell_cmd < $scratch|"
or croak "Couldn't run spellcheck command '$Spell_cmd'";
- my @words = <ASPELL>;
- close ASPELL or die;
+ my @words = <$spellcheck_results>;
+ close $spellcheck_results or die;
# clean up words, remove stopwords, select unique errors
chomp for @words;
commit 47897feb867f02dbf53aa42cd54cc9db1dc93266
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:22:08 2011 -0400
Factor out an invalid_words_in function
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 54431ee..e0048fd 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -19,21 +19,14 @@ our @EXPORT = qw(
set_pod_file_filter
);
-our $VERSION = '0.11';
+our $VERSION = '0.12';
my $Test = Test::Builder->new;
my $Spell_cmd = 'spell';
my $file_filter = sub { 1 };
-sub pod_file_spelling_ok {
+sub invalid_words_in {
my $file = shift;
- my $name = @_ ? shift : "POD spelling for $file";
-
- if ( !-f $file ) {
- $Test->ok( 0, $name );
- $Test->diag( "$file does not exist" );
- return;
- }
my $scratch = File::Temp->new->filename;
@@ -47,8 +40,23 @@ sub pod_file_spelling_ok {
my @words = <$spellcheck_results>;
close $spellcheck_results or die;
- # clean up words, remove stopwords, select unique errors
chomp for @words;
+ return @words;
+}
+
+sub pod_file_spelling_ok {
+ my $file = shift;
+ my $name = @_ ? shift : "POD spelling for $file";
+
+ if ( !-f $file ) {
+ $Test->ok( 0, $name );
+ $Test->diag( "$file does not exist" );
+ return;
+ }
+
+ my @words = invalid_words_in($file);
+
+ # remove stopwords, select unique errors
@words = grep { !$Pod::Wordlist::Wordlist{$_} } @words;
my %seen;
@seen{@words} = ();
commit 8820b5c18ab7f0803742eac279bdfb3e0931fac9
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:28:29 2011 -0400
Fix a mistaken inversion from a refactor
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index e0048fd..59404e0 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -102,7 +102,7 @@ sub all_pod_files {
push @queue, map "$file/$_", @newfiles;
}
if ( -f $file ) {
- next unless !_is_perl($file);
+ next unless _is_perl($file);
next unless $file_filter->($file);
push @pod, $file;
}
commit 112f0ae3a126e1a562f8330c485003d2077b310c
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:29:58 2011 -0400
Use another lexical filehandle instead of a local *DH
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 59404e0..03059e3 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -91,10 +91,9 @@ sub all_pod_files {
while ( @queue ) {
my $file = shift @queue;
if ( -d $file ) {
- local *DH;
- opendir DH, $file or next;
- my @newfiles = readdir DH;
- closedir DH;
+ opendir my $dirhandle, $file or next;
+ my @newfiles = readdir $dirhandle;
+ closedir $dirhandle;
@newfiles = File::Spec->no_upwards( @newfiles );
@newfiles = grep { $_ ne "CVS" && $_ ne ".svn" } @newfiles;
commit 31fca522eefe2ed94d228de1a1210608aa174e4d
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:31:26 2011 -0400
Tidy
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 03059e3..cd81651 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -1,14 +1,16 @@
package Test::Spelling;
-
use 5.006;
use strict;
use warnings;
+
+use base 'Exporter';
use Pod::Spell;
use Test::Builder;
use File::Spec;
use File::Temp;
use Carp;
-use base 'Exporter';
+
+our $VERSION = '0.12';
our @EXPORT = qw(
pod_file_spelling_ok
@@ -19,8 +21,6 @@ our @EXPORT = qw(
set_pod_file_filter
);
-our $VERSION = '0.12';
-
my $Test = Test::Builder->new;
my $Spell_cmd = 'spell';
my $file_filter = sub { 1 };
@@ -48,9 +48,9 @@ sub pod_file_spelling_ok {
my $file = shift;
my $name = @_ ? shift : "POD spelling for $file";
- if ( !-f $file ) {
- $Test->ok( 0, $name );
- $Test->diag( "$file does not exist" );
+ if (!-f $file) {
+ $Test->ok(0, $name);
+ $Test->diag("$file does not exist");
return;
}
@@ -64,8 +64,8 @@ sub pod_file_spelling_ok {
# emit output
my $ok = !@words;
- $Test->ok( $ok, "$name");
- if ( !$ok ) {
+ $Test->ok($ok, "$name");
+ if (!$ok) {
$Test->diag("Errors:\n" . join '', @words);
}
@@ -75,32 +75,32 @@ sub pod_file_spelling_ok {
sub all_pod_files_spelling_ok {
my @files = all_pod_files(@_);
- $Test->plan( tests => scalar @files );
+ $Test->plan(tests => scalar @files);
my $ok = 1;
- foreach my $file ( @files ) {
- pod_file_spelling_ok( $file, ) or undef $ok;
+ for my $file (@files) {
+ pod_file_spelling_ok($file) or undef $ok;
}
return $ok;
}
sub all_pod_files {
my @queue = @_ ? @_ : _starting_points();
- my @pod = ();
+ my @pod;
- while ( @queue ) {
+ while (@queue) {
my $file = shift @queue;
- if ( -d $file ) {
+ if (-d $file) {
opendir my $dirhandle, $file or next;
my @newfiles = readdir $dirhandle;
closedir $dirhandle;
- @newfiles = File::Spec->no_upwards( @newfiles );
+ @newfiles = File::Spec->no_upwards(@newfiles);
@newfiles = grep { $_ ne "CVS" && $_ ne ".svn" } @newfiles;
push @queue, map "$file/$_", @newfiles;
}
- if ( -f $file ) {
+ if (-f $file) {
next unless _is_perl($file);
next unless $file_filter->($file);
push @pod, $file;
@@ -131,7 +131,6 @@ sub _is_perl {
return;
}
-
sub add_stopwords {
for (@_) {
my $word = $_;
@@ -167,7 +166,7 @@ F<spell> program.
use Test::More;
use Test::Spelling;
plan tests => $num_tests;
- pod_file_spelling_ok( $file, "POD file spelling OK" );
+ pod_file_spelling_ok($file, "POD file spelling OK");
Module authors can include the following in a F<t/pod_spell.t> file and
have C<Test::Spelling> automatically find and check all POD files in a
commit c266e00c76bc1eae5eee9ce44e5fc6f755a063f6
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:35:00 2011 -0400
More substantial cleanup
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index cd81651..203c5f9 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -46,11 +46,11 @@ sub invalid_words_in {
sub pod_file_spelling_ok {
my $file = shift;
- my $name = @_ ? shift : "POD spelling for $file";
+ my $name = shift || "POD spelling for $file";
- if (!-f $file) {
+ if (!-r $file) {
$Test->ok(0, $name);
- $Test->diag("$file does not exist");
+ $Test->diag("$file does not exist or is unreadable");
return;
}
@@ -60,13 +60,13 @@ sub pod_file_spelling_ok {
@words = grep { !$Pod::Wordlist::Wordlist{$_} } @words;
my %seen;
@seen{@words} = ();
- @words = map " $_\n", sort keys %seen;
+ @words = sort keys %seen;
# emit output
- my $ok = !@words;
+ my $ok = @words == 0;
$Test->ok($ok, "$name");
if (!$ok) {
- $Test->diag("Errors:\n" . join '', @words);
+ $Test->diag("Errors:\n" . join '', map { " $_\n" } @words);
}
return $ok;
@@ -90,9 +90,11 @@ sub all_pod_files {
while (@queue) {
my $file = shift @queue;
+
+ # recurse into subdirectories
if (-d $file) {
- opendir my $dirhandle, $file or next;
- my @newfiles = readdir $dirhandle;
+ opendir(my $dirhandle, $file) or next;
+ my @newfiles = readdir($dirhandle);
closedir $dirhandle;
@newfiles = File::Spec->no_upwards(@newfiles);
@@ -100,17 +102,20 @@ sub all_pod_files {
push @queue, map "$file/$_", @newfiles;
}
+
+ # add the file if it meets our criteria
if (-f $file) {
next unless _is_perl($file);
next unless $file_filter->($file);
push @pod, $file;
}
- } # while
+ }
+
return @pod;
}
sub _starting_points {
- return 'blib' if -e 'blib';
+ return 'blib' if -d 'blib';
return 'lib';
}
@@ -121,19 +126,16 @@ sub _is_perl {
return 1 if $file =~ /\.p(l|m|od)$/;
return 1 if $file =~ /\.t$/;
- local *FH;
- open FH, $file or return;
- my $first = <FH>;
- close FH;
+ open my $handle, '<', $file or return;
+ my $first = <$handle>;
return 1 if defined $first && ($first =~ /^#!.*perl/);
- return;
+ return 0;
}
sub add_stopwords {
- for (@_) {
- my $word = $_;
+ for my $word (@_) {
$word =~ s/^#?\s*//;
$word =~ s/\s+$//;
next if $word =~ /\s/ or $word =~ /:/;
commit 39cd8b10de5093bcbb6bca5f37b3cdb5e9816a6c
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:37:36 2011 -0400
Add .plx to pod spell tests (you're welcome Schwern)
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 203c5f9..30b4e5a 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -123,7 +123,7 @@ sub _is_perl {
my $file = shift;
return 1 if $file =~ /\.PL$/;
- return 1 if $file =~ /\.p(l|m|od)$/;
+ return 1 if $file =~ /\.p(l|lx|m|od)$/;
return 1 if $file =~ /\.t$/;
open my $handle, '<', $file or return;
@@ -221,8 +221,8 @@ each function), so you can't have already called C<plan>.
If C<@files> is empty or not passed, the function finds all POD files in
the F<blib> directory if it exists, or the F<lib> directory if not.
-A POD file is one that ends with F<.pod>, F<.pl> and F<.pm>, or any file
-where the first line looks like a shebang line.
+A POD file is one that ends with F<.pod>, F<.pl>, F<.plx> and F<.pm>, or any
+file where the first line looks like a shebang line.
If you're testing a module, just make a F<t/spell.t>:
commit 5cb226be363cfe0858ba58034547b810c775ca83
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 13:38:43 2011 -0400
Better .plx doc
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 30b4e5a..e889935 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -221,7 +221,7 @@ each function), so you can't have already called C<plan>.
If C<@files> is empty or not passed, the function finds all POD files in
the F<blib> directory if it exists, or the F<lib> directory if not.
-A POD file is one that ends with F<.pod>, F<.pl>, F<.plx> and F<.pm>, or any
+A POD file is one that ends with F<.pod>, F<.pl>, F<.plx>, or F<.pm>; or any
file where the first line looks like a shebang line.
If you're testing a module, just make a F<t/spell.t>:
@@ -242,7 +242,7 @@ A Perl file is:
=over 4
-=item * Any file that ends in F<.PL>, F<.pl>, F<.pm>, F<.pod> or F<.t>.
+=item * Any file that ends in F<.PL>, F<.pl>, F<.plx>, F<.pm>, F<.pod> or F<.t>.
=item * Any file that has a first line with a shebang and "perl" on it.
commit 925d143022eb40e1801e059f62086421283db50a
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 14:25:47 2011 -0400
Try various spellcheck commands [rt.cpan.org #56483]
spell, aspell, ispell, hunspell
diff --git a/Changes b/Changes
index 0609f2b..768b0b4 100644
--- a/Changes
+++ b/Changes
@@ -8,6 +8,8 @@ Revision history for Test-Spelling
(reported by David Hand)
- Add set_pod_file_filter for skipping translations, etc.
[rt.cpan.org #63755] (reported by me :))
+ - Try various spellcheck programs [rt.cpan.org #56483] (reported by
+ Lars Dɪá´á´á´á´á´¡, et al)
0.11 2005-11-15
- Some documentation fixes.
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index e889935..da1503e 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -8,7 +8,6 @@ use Pod::Spell;
use Test::Builder;
use File::Spec;
use File::Temp;
-use Carp;
our $VERSION = '0.12';
@@ -21,10 +20,54 @@ our @EXPORT = qw(
set_pod_file_filter
);
-my $Test = Test::Builder->new;
-my $Spell_cmd = 'spell';
+my $Test = Test::Builder->new;
+
+my $SPELLCHECKER;
my $file_filter = sub { 1 };
+sub spellchecker_candidates {
+ # if they've specified a spellchecker, use only that one
+ return $SPELLCHECKER if $SPELLCHECKER;
+
+ return (
+ 'spell', # for back-compat, this is the top candidate ...
+ 'aspell list -l en', # ... but this should become first soon
+ 'ispell -l',
+ 'hunspell',
+ );
+}
+
+sub _get_spellcheck_results {
+ my $scratch = shift;
+
+ my @errors;
+
+ for my $spellchecker (spellchecker_candidates()) {
+ my $spellcheck_handle;
+ if (open $spellcheck_handle, "$spellchecker < $scratch |") {
+ push @errors, "Unable to run '$spellchecker': $!";
+ next;
+ }
+
+ my @words = <$spellcheck_handle>;
+ close $spellcheck_handle or die $!;
+
+ # remember the one we used, so that it's consistent for all the files
+ # this run, and we don't keep retrying the same spellcheckers that will
+ # never work
+ set_spell_cmd($spellchecker)
+ if !$SPELLCHECKER;
+
+ return @words;
+ }
+
+ # no working spellcheckers; report all the errors
+ require Carp;
+ Carp::croak
+ "Unable to find a working spellchecker:\n"
+ . join("\n", map { " $_\n" } @errors)
+}
+
sub invalid_words_in {
my $file = shift;
@@ -34,11 +77,7 @@ sub invalid_words_in {
my $checker = Pod::Spell->new;
$checker->parse_from_file($file, $scratch);
- # run spell command and fetch output
- open my $spellcheck_results, "$Spell_cmd < $scratch|"
- or croak "Couldn't run spellcheck command '$Spell_cmd'";
- my @words = <$spellcheck_results>;
- close $spellcheck_results or die;
+ my @words = _get_spellcheck_results($scratch);
chomp for @words;
return @words;
@@ -144,7 +183,7 @@ sub add_stopwords {
}
sub set_spell_cmd {
- $Spell_cmd = shift;
+ $SPELLCHECKER = shift;
}
sub set_pod_file_filter {
commit ed59bb5f58d1bf988248f249291110617647ea84
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 14:54:42 2011 -0400
Use IPC::Open2 to avoid File::Temp and shell interpolation
opening "$spellchecker < $scratch |" is kind of worrying given that
$spellchecker and $scratch are not escaped or quoted.
And now that we give the document to the spellchecker ourselves, we
can avoid using File::Temp by using an in-memory filehandle
diff --git a/Makefile.PL b/Makefile.PL
index 57780e4..fc61b9c 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -7,7 +7,6 @@ repository 'http://github.com/bestpractical/test-spelling';
requires 'Pod::Spell' => '1.01';
test_requires 'Test::More' => 0;
-test_requires 'File::Temp' => 0;
WriteAll;
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index da1503e..c88ac3c 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -7,7 +7,7 @@ use base 'Exporter';
use Pod::Spell;
use Test::Builder;
use File::Spec;
-use File::Temp;
+use IPC::Open2;
our $VERSION = '0.12';
@@ -38,27 +38,38 @@ sub spellchecker_candidates {
}
sub _get_spellcheck_results {
- my $scratch = shift;
+ my $document = shift;
my @errors;
for my $spellchecker (spellchecker_candidates()) {
- my $spellcheck_handle;
- if (open $spellcheck_handle, "$spellchecker < $scratch |") {
- push @errors, "Unable to run '$spellchecker': $!";
- next;
- }
+ my @words;
+ my $ok = eval {
+ my $pid = open2((my ($spellcheck_results, $child_in)), $spellchecker);
+
+ print $child_in $document;
+
+ # signal to spellchecker that we're done giving it words
+ close $child_in or die $!;
- my @words = <$spellcheck_handle>;
- close $spellcheck_handle or die $!;
+ @words = <$spellcheck_results>;
- # remember the one we used, so that it's consistent for all the files
- # this run, and we don't keep retrying the same spellcheckers that will
- # never work
- set_spell_cmd($spellchecker)
- if !$SPELLCHECKER;
+ # wait for spellchecker to clean up
+ waitpid $pid, 0;
+
+ 1;
+ };
+
+ if ($ok) {
+ # remember the one we used, so that it's consistent for all the files
+ # this run, and we don't keep retrying the same spellcheckers that will
+ # never work
+ set_spell_cmd($spellchecker)
+ if !$SPELLCHECKER;
+ return @words;
+ }
- return @words;
+ push @errors, "Unable to run '$spellchecker': $@";
}
# no working spellcheckers; report all the errors
@@ -71,13 +82,14 @@ sub _get_spellcheck_results {
sub invalid_words_in {
my $file = shift;
- my $scratch = File::Temp->new->filename;
+ my $document = '';
+ open my $handle, '>', \$document;
# save digested POD to temp file
my $checker = Pod::Spell->new;
- $checker->parse_from_file($file, $scratch);
+ $checker->parse_from_file($file, $handle);
- my @words = _get_spellcheck_results($scratch);
+ my @words = _get_spellcheck_results($document);
chomp for @words;
return @words;
commit 44f99a61d52c34e49d07d757df893fae0ec89605
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 15:02:43 2011 -0400
IPC::Open3 deals with exec errors better
open2 on a program that doesn't exist will give you crap in
stderr, but since we're trying alternatives, it's better to capture
and discard it
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index c88ac3c..9849997 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -7,7 +7,7 @@ use base 'Exporter';
use Pod::Spell;
use Test::Builder;
use File::Spec;
-use IPC::Open2;
+use IPC::Open3;
our $VERSION = '0.12';
@@ -45,7 +45,7 @@ sub _get_spellcheck_results {
for my $spellchecker (spellchecker_candidates()) {
my @words;
my $ok = eval {
- my $pid = open2((my ($spellcheck_results, $child_in)), $spellchecker);
+ my $pid = open3((my ($child_in, $spellcheck_results, $child_err)), $spellchecker);
print $child_in $document;
commit 9a30b0c853a5032176b9d4df7a7d8d3f5beb9452
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 15:04:47 2011 -0400
hunspell needs -l just like ispell
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 9849997..28bcd18 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -33,7 +33,7 @@ sub spellchecker_candidates {
'spell', # for back-compat, this is the top candidate ...
'aspell list -l en', # ... but this should become first soon
'ispell -l',
- 'hunspell',
+ 'hunspell -l',
);
}
commit 85da2b6f61f387ea089478932df08fb4e63aa0fa
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 15:20:29 2011 -0400
has_working_spellchecker and skip_all if there is none
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 28bcd18..6a045ca 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -18,6 +18,7 @@ our @EXPORT = qw(
set_spell_cmd
all_pod_files
set_pod_file_filter
+ has_working_spellchecker
);
my $Test = Test::Builder->new;
@@ -37,8 +38,19 @@ sub spellchecker_candidates {
);
}
+sub has_working_spellchecker {
+ my $dryrun_results = _get_spellcheck_results("dry run", 1);
+
+ if (ref $dryrun_results) {
+ return;
+ }
+
+ return $SPELLCHECKER;
+}
+
sub _get_spellcheck_results {
my $document = shift;
+ my $dryrun = shift;
my @errors;
@@ -63,7 +75,8 @@ sub _get_spellcheck_results {
if ($ok) {
# remember the one we used, so that it's consistent for all the files
# this run, and we don't keep retrying the same spellcheckers that will
- # never work
+ # never work. also we need to expose the spellchecker we're using in
+ # has_working_spellchecker
set_spell_cmd($spellchecker)
if !$SPELLCHECKER;
return @words;
@@ -72,6 +85,9 @@ sub _get_spellcheck_results {
push @errors, "Unable to run '$spellchecker': $@";
}
+ # no working spellcheckers during a dry run
+ return \"no spellchecker" if $dryrun;
+
# no working spellcheckers; report all the errors
require Carp;
Carp::croak
@@ -85,7 +101,7 @@ sub invalid_words_in {
my $document = '';
open my $handle, '>', \$document;
- # save digested POD to temp file
+ # save digested POD to the string $document
my $checker = Pod::Spell->new;
$checker->parse_from_file($file, $handle);
@@ -126,6 +142,10 @@ sub pod_file_spelling_ok {
sub all_pod_files_spelling_ok {
my @files = all_pod_files(@_);
+ if (!has_working_spellchecker()) {
+ return $Test->plan(skip_all => "no working spellchecker found");
+ }
+
$Test->plan(tests => scalar @files);
my $ok = 1;
commit 6b513f71f2db3d590cd25ee171da82ac9436cedd
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 16:05:29 2011 -0400
Take a pass at improving the entire documentation
I don't plan to continue supporting "perl t/spell.t 2>> t/spell.t",
since that limits the diagnostic output, as well as the format of
the stopwords DATA sections, pretty rigidly.
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 6a045ca..96b5ecc 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -207,6 +207,9 @@ sub _is_perl {
sub add_stopwords {
for my $word (@_) {
+ # XXX: the processing this performs is to support "perl t/spell.t 2>>
+ # t/spell.t" which is bunk. in the near future the processing here will
+ # become more modern
$word =~ s/^#?\s*//;
$word =~ s/\s+$//;
next if $word =~ /\s/ or $word =~ /:/;
@@ -232,82 +235,102 @@ Test::Spelling - check for spelling errors in POD files
=head1 SYNOPSIS
-C<Test::Spelling> lets you check the spelling of a POD file, and report
-its results in standard C<Test::Simple> fashion. This module requires the
-F<spell> program.
-
use Test::More;
- use Test::Spelling;
- plan tests => $num_tests;
- pod_file_spelling_ok($file, "POD file spelling OK");
-
-Module authors can include the following in a F<t/pod_spell.t> file and
-have C<Test::Spelling> automatically find and check all POD files in a
-module distribution:
+ BEGIN {
+ plan skip_all => "Spelling tests only for authors"
+ unless -d 'inc/.author';
+ }
- use Test::More;
use Test::Spelling;
all_pod_files_spelling_ok();
-Note, however that it is not really recommended to include this test with a
-CPAN distribution, or a package that will run in an uncontrolled environment,
-because there's no way of predicting if F<spell> will be available or the
-word list used will give the same results (what if it's in a different language,
-for example?). You can have the test, but don't add it to F<MANIFEST> (or add
-it to F<MANIFEST.SKIP> to make sure you don't add it by accident). Anyway,
-your users don't really need to run this test, as it is unlikely that the
-documentation will acquire typos while in transit. :-)
+=head1 DESCRIPTION
-You can add your own stopwords (words that should be ignored by the spell
-check):
+C<Test::Spelling> lets you check the spelling of a POD file, and report
+its results in standard C<Test::More> fashion. This module requires a
+spellcheck program such as F<spell>, F<aspell>, F<ispell>, or F<hunspell>.
- add_stopwords(qw(asdf thiswordiscorrect));
+ use Test::Spelling;
+ pod_file_spelling_ok('lib/Foo/Bar.pm', 'POD file spelling OK');
-These stopwords are global for the test. See L<Pod::Spell> for a variety of
-ways to add per-file stopwords to each .pm file.
+Note that it is a bad idea to run spelling tests during an ordinary CPAN
+distribution install, or in a package that will run in an uncontrolled
+environment. There is no way of predicting whether the word list or spellcheck
+program used will give the same results. You B<can> include the test in your
+distribution, but be sure to run it only for authors of the module by guarding
+it in a C<skip_all unless -d 'inc/.author'> clause, or by putting the test in
+your distribution's F<xt/> directory. Anyway, people installing your module
+really do not need to run such tests, as it is unlikely that the documentation
+will acquire typos while in transit. :-)
-=head1 DESCRIPTION
+You can add your own stopwords, which are words that should be ignored by the
+spell check, like so:
-Check POD files for spelling mistakes, using L<Pod::Spell> and F<spell> to do
-the heavy lifting.
+ add_stopwords(qw(asdf thiswordiscorrect));
-=head1 FUNCTIONS
+Adding stopwards in this fashion affects all files checked for the remainder of
+the test script. See L<Pod::Spell> (which this module is built upon) for a
+variety of ways to add per-file stopwords to each .pm file.
-=head2 pod_file_spelling_ok( FILENAME[, TESTNAME ] )
+If you have a lot of stopwords, it's useful to put them in your test file's
+C<DATA> section like so:
-C<pod_file_spelling_ok()> will okay the test if the POD has no spelling errors.
+ use Test::Spelling;
+ add_stopwords(<DATA>);
+ all_pod_files_spelling_ok();
-When it fails, C<pod_file_spelling_ok()> will show any spelling errors as
-diagnostics.
+ __END__
+ folksonomy
+ Jifty
+ Zakirov
-The optional second argument TESTNAME is the name of the test. If it
-is omitted, C<pod_file_spelling_ok()> chooses a default test name "POD spelling
-for FILENAME".
+To maintain backwards compatibility, comment markers and some whitespace are
+ignored. In the near future, the preprocessing we do on the arguments to
+L<add_stopwords> will be changed and documented properly.
+
+=head1 FUNCTIONS
=head2 all_pod_files_spelling_ok( [@files/@directories] )
-Checks all the files in C<@files> for POD spelling. It runs L<all_pod_files()>
-on each file/directory, and calls the C<plan()> function for you (one test for
-each function), so you can't have already called C<plan>.
+Checks all the files for POD spelling. It gathers L<all_pod_files()> on each
+file/directory, and declares a L<Test::More/plan> for you (one test for each
+file), so you must not call C<plan> yourself.
-If C<@files> is empty or not passed, the function finds all POD files in
-the F<blib> directory if it exists, or the F<lib> directory if not.
-A POD file is one that ends with F<.pod>, F<.pl>, F<.plx>, or F<.pm>; or any
-file where the first line looks like a shebang line.
+If C<@files> is empty, the function finds all POD files in the F<blib>
+directory if it exists, or the F<lib> directory if it does not. A POD file is
+one that ends with F<.pod>, F<.pl>, F<.plx>, or F<.pm>; or any file where the
+first line looks like a perl shebang line.
-If you're testing a module, just make a F<t/spell.t>:
+If there is no working spellchecker (determined by
+L</has_working_spellchecker>), this test will issue a "skip all" directive.
+
+If you're testing a distribution, just create a F<t/pod-spell.t>:
use Test::More;
+ plan skip_all => "Spelling tests only for authors" unless -d "inc/.author";
use Test::Spelling;
all_pod_files_spelling_ok();
-Returns true if all pod files are ok, or false if any fail.
+Returns true if every POD file has correct spelling, or false if any of them fail.
+This function will show any spelling errors as diagnostics.
+
+=head2 pod_file_spelling_ok( FILENAME[, TESTNAME ] )
+
+C<pod_file_spelling_ok> will test that the given POD file has no spelling
+errors.
+
+When it fails, C<pod_file_spelling_ok> will show any spelling errors as
+diagnostics.
+
+The optional second argument TESTNAME is the name of the test. If it
+is omitted, C<pod_file_spelling_ok> chooses a default test name "POD spelling
+for FILENAME".
=head2 all_pod_files( [@dirs] )
-Returns a list of all the Perl files in I<$dir> and in directories below.
-If no directories are passed, it defaults to F<blib> if F<blib> exists,
-or else F<lib> if not. Skips any files in CVS or .svn directories.
+Returns a list of all the Perl files in each directory and its subdirectories,
+recursively. If no directories are passed, it defaults to F<blib> if F<blib>
+exists, or else F<lib> if not. Skips any files in F<CVS> or F<.svn> directories.
A Perl file is:
@@ -320,50 +343,34 @@ A Perl file is:
=back
Furthermore, files for which the filter set by L</set_pod_file_filter> return
-false are skipped. By default this filter passes everything through.
+false are skipped. By default, this filter passes everything through.
The order of the files returned is machine-dependent. If you want them
sorted, you'll have to sort them yourself.
=head2 add_stopwords(@words)
-Add words that should be skipped by the spell check. A suggested use is to list
-these words, one per line, in the __DATA__ section of your test file, and just
-call
-
- add_stopwords(<DATA>);
-
-As a convenience, C<add_stopwords> will automatically ignore a comment mark and
-one or more spaces from the beginning of the line, and it will ignore lines
-that say '# Error:' or '# Looks like' or /Failed test/. The reason? Let's say
-you run a test and get this result:
-
- 1..1
- not ok 1 - POD spelling for lib/Test/Spelling.pm
- # Failed test (lib/Test/Spelling.pm at line 70)
- # Errors:
- # stopwords
- # Looks like you failed 1 tests of 1.
-
-Let's say you decide that all the words that were marked as errors are really
-correct. The diagnostic lines are printed to STDERR; that means that, if you
-have a decent shell, you can type something like
-
- perl t/spell.t 2>> t/spell.t
+Add words that should be skipped by the spellcheck. Note that L<Pod::Spell>
+already skips words believed to be code, such as everything in verbatim
+(indented) blocks and code marked up with C<< C<...> >>, as well as some common
+Perl jargon.
-which will append the diagnostic lines to the end of your test file. Assuming
-you already have a __DATA__ line in your test file, that should be enough to
-ensure that the test passes the next time.
+=head2 has_working_spellchecker
-Also note that L<Pod::Spell> skips words believed to be code, such as words
-in verbatim blocks and code labeled with CE<lt>>.
+C<has_working_spellchecker> will return C<undef> if there is no working
+spellchecker, or a true value (the spellchecker command itself) if there is.
+The module performs a dry-run to determine whether any of the spellcheckers it
+can will use work on the current system. You can use this to skip tests if
+there is no spellchecker. Note that L</all_pod_files_spelling_ok> will do this
+for you.
=head2 set_spell_cmd($command)
-If the F<spell> program has a different name or is not in your path, you can
-specify an alternative with C<set_spell_cmd>. Any command that takes text
-from standard input and prints a list of misspelled words, one per line, to
-standard output will do. For example, you can use C<aspell list>.
+If you want to force this module to use a particular spellchecker, then you can
+specify which one with C<set_spell_cmd>. This is useful to ensure a more
+consistent lexicon between developers, or if you have an unusual environment.
+Any command that takes text from standard input and prints a list of misspelled
+words, one per line, to standard output will do.
=head2 set_pod_file_filter($code)
commit 0692fe9319ccd4744fb45e2acc8ebe5d395d33ca
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 16:16:56 2011 -0400
Regenerate README from perldoc -tT
diff --git a/README b/README
index b80a4ae..7bca4c5 100644
--- a/README
+++ b/README
@@ -1,64 +1,162 @@
-Test::Spelling version 0.11
-===========================
+NAME
+ Test::Spelling - check for spelling errors in POD files
+SYNOPSIS
+ use Test::More;
+ BEGIN {
+ plan skip_all => "Spelling tests only for authors"
+ unless -d 'inc/.author';
+ }
+
+ use Test::Spelling;
+ all_pod_files_spelling_ok();
+
+DESCRIPTION
"Test::Spelling" lets you check the spelling of a POD file, and report
- its results in standard "Test::Simple" fashion. This module requires the
- spell program.
+ its results in standard "Test::More" fashion. This module requires a
+ spellcheck program such as spell, aspell, ispell, or hunspell.
+
+ use Test::Spelling;
+ pod_file_spelling_ok('lib/Foo/Bar.pm', 'POD file spelling OK');
+
+ Note that it is a bad idea to run spelling tests during an ordinary CPAN
+ distribution install, or in a package that will run in an uncontrolled
+ environment. There is no way of predicting whether the word list or
+ spellcheck program used will give the same results. You can include the
+ test in your distribution, but be sure to run it only for authors of the
+ module by guarding it in a "skip_all unless -d 'inc/.author'" clause, or
+ by putting the test in your distribution's xt/ directory. Anyway, people
+ installing your module really do not need to run such tests, as it is
+ unlikely that the documentation will acquire typos while in transit. :-)
+
+ You can add your own stopwords, which are words that should be ignored
+ by the spell check, like so:
+
+ add_stopwords(qw(asdf thiswordiscorrect));
+
+ Adding stopwards in this fashion affects all files checked for the
+ remainder of the test script. See Pod::Spell (which this module is built
+ upon) for a variety of ways to add per-file stopwords to each .pm file.
+
+ If you have a lot of stopwords, it's useful to put them in your test
+ file's "DATA" section like so:
- use Test::More;
use Test::Spelling;
- plan tests => $num_tests;
- pod_file_spelling_ok( $file, "POD file spelling OK" );
+ add_stopwords(<DATA>);
+ all_pod_files_spelling_ok();
- Module authors can include the following in a t/pod_spell.t file and
- have "Test::Spelling" automatically find and check all POD files in a
- module distribution:
+ __END__
+ folksonomy
+ Jifty
+ Zakirov
+
+ To maintain backwards compatibility, comment markers and some whitespace
+ are ignored. In the near future, the preprocessing we do on the
+ arguments to add_stopwords will be changed and documented properly.
+
+FUNCTIONS
+ all_pod_files_spelling_ok( [@files/@directories] )
+ Checks all the files for POD spelling. It gathers all_pod_files() on
+ each file/directory, and declares a "plan" in Test::More for you (one
+ test for each file), so you must not call "plan" yourself.
+
+ If @files is empty, the function finds all POD files in the blib
+ directory if it exists, or the lib directory if it does not. A POD file
+ is one that ends with .pod, .pl, .plx, or .pm; or any file where the
+ first line looks like a perl shebang line.
+
+ If there is no working spellchecker (determined by
+ "has_working_spellchecker"), this test will issue a "skip all"
+ directive.
+
+ If you're testing a distribution, just create a t/pod-spell.t:
use Test::More;
+ plan skip_all => "Spelling tests only for authors" unless -d "inc/.author";
use Test::Spelling;
all_pod_files_spelling_ok();
- Note, however that it is not really recommended to include this test
- with a CPAN distribution, or a package that will run in an uncontrolled
- environment, because there's no way of predicting if spell will be
- available or the wordlist used will give the same results (what if it's
- in a different language, for example?).
+ Returns true if every POD file has correct spelling, or false if any of
+ them fail. This function will show any spelling errors as diagnostics.
+
+ pod_file_spelling_ok( FILENAME[, TESTNAME ] )
+ "pod_file_spelling_ok" will test that the given POD file has no spelling
+ errors.
+
+ When it fails, "pod_file_spelling_ok" will show any spelling errors as
+ diagnostics.
+
+ The optional second argument TESTNAME is the name of the test. If it is
+ omitted, "pod_file_spelling_ok" chooses a default test name "POD
+ spelling for FILENAME".
+
+ all_pod_files( [@dirs] )
+ Returns a list of all the Perl files in each directory and its
+ subdirectories, recursively. If no directories are passed, it defaults
+ to blib if blib exists, or else lib if not. Skips any files in CVS or
+ .svn directories.
+
+ A Perl file is:
+
+ * Any file that ends in .PL, .pl, .plx, .pm, .pod or .t.
+
+ * Any file that has a first line with a shebang and "perl" on it.
+
+ Furthermore, files for which the filter set by "set_pod_file_filter"
+ return false are skipped. By default, this filter passes everything
+ through.
- You can add your own stopwords (words that should be ignored by the
- spell check):
+ The order of the files returned is machine-dependent. If you want them
+ sorted, you'll have to sort them yourself.
- add_stopwords(qw(adsf thiswordiscorrect));
+ add_stopwords(@words)
+ Add words that should be skipped by the spellcheck. Note that Pod::Spell
+ already skips words believed to be code, such as everything in verbatim
+ (indented) blocks and code marked up with "...", as well as some common
+ Perl jargon.
- These stopwords are global for the test. See L<Pod::Spell> for a variety of
- ways to add per-file stopwords to each .pm file.
+ has_working_spellchecker
+ "has_working_spellchecker" will return "undef" if there is no working
+ spellchecker, or a true value (the spellchecker command itself) if there
+ is. The module performs a dry-run to determine whether any of the
+ spellcheckers it can will use work on the current system. You can use
+ this to skip tests if there is no spellchecker. Note that
+ "all_pod_files_spelling_ok" will do this for you.
-CHANGES SINCE VERSION 0.10
- - Some documentation fixes.
- - Added note about per-file stopwords by Chris Dolan.
- - Use a temporary file instead of open2() to solve win32 portability
- issues. (Thanks to Chris Laco!)
+ set_spell_cmd($command)
+ If you want to force this module to use a particular spellchecker, then
+ you can specify which one with "set_spell_cmd". This is useful to ensure
+ a more consistent lexicon between developers, or if you have an unusual
+ environment. Any command that takes text from standard input and prints
+ a list of misspelled words, one per line, to standard output will do.
-INSTALLATION
+ set_pod_file_filter($code)
+ If your project has POD documents written in languages other than
+ English, then obviously you don't want to be running a spellchecker on
+ every Perl file. "set_pod_file_filter" lets you filter out files
+ returned from "all_pod_files" (and hence, the documents tested by
+ "all_pod_files_spelling_ok").
- perl Makefile.PL
- make
- make test
- make install
+ set_pod_file_filter(sub {
+ my $filename = shift;
+ return 0 if $filename =~ /_ja.pod$/; # skip Japanese translations
+ return 1;
+ });
+SEE ALSO
+ Pod::Spell
-DEPENDENCIES
- perl-5.6.0+
- Pod::Spell 1.01
- Test::More 0
- Test::Builder::Tester 0
- File::Spec 0
- File::Temp 0
+ORIGINAL AUTHOR
+ Ivan Tubert-Brohman "<itub at cpan.org>"
+ Heavily based on Test::Pod by Andy Lester and brian d foy.
-COPYRIGHT AND LICENSE
+MAINTAINER
+ Shawn M Moore "<sartak at bestpractical.com>"
-Copyright (C) 2005 Ivan Tubert-Brohman <itub at cpan.org>
+COPYRIGHT
+ Copyright 2005, Ivan Tubert-Brohman, All Rights Reserved.
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
+ You may use, modify, and distribute this package under the same terms as
+ Perl itself.
commit 395b100b73310f5cc2234d032eaec6be8a942406
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 16:24:55 2011 -0400
Changes
diff --git a/Changes b/Changes
index 768b0b4..3bb1e92 100644
--- a/Changes
+++ b/Changes
@@ -2,14 +2,24 @@ Revision history for Test-Spelling
0.12 2011-04-25
- Best Practical has taken over maintainership of this module
- - Clean up temporary files more aggressively [rt.cpan.org #41586]
+ - Try various spellcheck programs instead of hardcoding the ancient
+ `spell` [rt.cpan.org #56483] (reported by Lars Dɪá´á´á´á´á´¡, et al)
+ - Remove temporary files more aggressively [rt.cpan.org #41586]
(reported by Tokuhiro Matsuno)
- - Correct aspell suggestion from -l to list [rt.cpan.org #28967]
+ - fixed by not creating them at all :) instead we now use IPC::Open3
+ - Remove suggestion to use broken `aspell -l` [rt.cpan.org #28967]
(reported by David Hand)
- Add set_pod_file_filter for skipping translations, etc.
[rt.cpan.org #63755] (reported by me :))
- - Try various spellcheck programs [rt.cpan.org #56483] (reported by
- Lars Dɪá´á´á´á´á´¡, et al)
+ - Skip tests in all_pod_files_spelling_ok if there is no working
+ spellchecker
+ - Provide a has_working_spellchecker so you can skip your own tests if
+ there's no working spellchecker
+ - Switch to Module::Install
+ - Rewrite and modernize a lot of the documentation
+ - Decruftify code, such as by using Exporter and lexical filehandles
+ - Support .plx files (you're welcome Schwern)
+
0.11 2005-11-15
- Some documentation fixes.
commit 0a6badbffadecb5d75a2f0e53761772d2bae0d2e
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 16:25:13 2011 -0400
$FILE_FILTER is a "global" so uppercase it
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 96b5ecc..c53524e 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -24,7 +24,7 @@ our @EXPORT = qw(
my $Test = Test::Builder->new;
my $SPELLCHECKER;
-my $file_filter = sub { 1 };
+my $FILE_FILTER = sub { 1 };
sub spellchecker_candidates {
# if they've specified a spellchecker, use only that one
@@ -177,7 +177,7 @@ sub all_pod_files {
# add the file if it meets our criteria
if (-f $file) {
next unless _is_perl($file);
- next unless $file_filter->($file);
+ next unless $FILE_FILTER->($file);
push @pod, $file;
}
}
@@ -222,7 +222,7 @@ sub set_spell_cmd {
}
sub set_pod_file_filter {
- $file_filter = shift;
+ $FILE_FILTER = shift;
}
1;
commit fa7192a0764ef25b3160d06760a7da505ebee080
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 16:25:53 2011 -0400
Don't even bother declaring a dep on Test::More
diff --git a/Makefile.PL b/Makefile.PL
index fc61b9c..b431cf7 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -6,7 +6,5 @@ repository 'http://github.com/bestpractical/test-spelling';
requires 'Pod::Spell' => '1.01';
-test_requires 'Test::More' => 0;
-
WriteAll;
commit a8030735832129460f998ac8ae36a9d38c5b07b9
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Apr 25 16:27:55 2011 -0400
$TEST is global too
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index c53524e..2aef21a 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -21,7 +21,7 @@ our @EXPORT = qw(
has_working_spellchecker
);
-my $Test = Test::Builder->new;
+my $TEST = Test::Builder->new;
my $SPELLCHECKER;
my $FILE_FILTER = sub { 1 };
@@ -116,8 +116,8 @@ sub pod_file_spelling_ok {
my $name = shift || "POD spelling for $file";
if (!-r $file) {
- $Test->ok(0, $name);
- $Test->diag("$file does not exist or is unreadable");
+ $TEST->ok(0, $name);
+ $TEST->diag("$file does not exist or is unreadable");
return;
}
@@ -131,9 +131,9 @@ sub pod_file_spelling_ok {
# emit output
my $ok = @words == 0;
- $Test->ok($ok, "$name");
+ $TEST->ok($ok, "$name");
if (!$ok) {
- $Test->diag("Errors:\n" . join '', map { " $_\n" } @words);
+ $TEST->diag("Errors:\n" . join '', map { " $_\n" } @words);
}
return $ok;
@@ -143,10 +143,10 @@ sub all_pod_files_spelling_ok {
my @files = all_pod_files(@_);
if (!has_working_spellchecker()) {
- return $Test->plan(skip_all => "no working spellchecker found");
+ return $TEST->plan(skip_all => "no working spellchecker found");
}
- $Test->plan(tests => scalar @files);
+ $TEST->plan(tests => scalar @files);
my $ok = 1;
for my $file (@files) {
commit 24a74b4886530ab67684c67fb759cf36f8776da2
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Apr 26 12:23:00 2011 -0400
Don't duplicate the example all_pod_files_spelling_ok
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 2aef21a..748d050 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -304,12 +304,8 @@ first line looks like a perl shebang line.
If there is no working spellchecker (determined by
L</has_working_spellchecker>), this test will issue a "skip all" directive.
-If you're testing a distribution, just create a F<t/pod-spell.t>:
-
- use Test::More;
- plan skip_all => "Spelling tests only for authors" unless -d "inc/.author";
- use Test::Spelling;
- all_pod_files_spelling_ok();
+If you're testing a distribution, just create a F<t/pod-spell.t> with the code
+in the L</SYNOPSIS>.
Returns true if every POD file has correct spelling, or false if any of them fail.
This function will show any spelling errors as diagnostics.
commit d95d3378a47e6dead2dcc54ddc255bf9cf01ac58
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Apr 27 13:31:10 2011 -0400
Make alternatives checking more robust by reading the spellchecker's STDERR
diff --git a/Changes b/Changes
index 3bb1e92..542bc1c 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
Revision history for Test-Spelling
+0.13 2011-04-27
+ - Make alternatives checking more robust by reading the spellchecker's
+ STDERR
+
0.12 2011-04-25
- Best Practical has taken over maintainership of this module
- Try various spellcheck programs instead of hardcoding the ancient
@@ -20,7 +24,6 @@ Revision history for Test-Spelling
- Decruftify code, such as by using Exporter and lexical filehandles
- Support .plx files (you're welcome Schwern)
-
0.11 2005-11-15
- Some documentation fixes.
- Added note about per-file stopwords by Chris Dolan.
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 748d050..615dbc2 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -8,6 +8,7 @@ use Pod::Spell;
use Test::Builder;
use File::Spec;
use IPC::Open3;
+use Symbol 'gensym';
our $VERSION = '0.12';
@@ -57,7 +58,13 @@ sub _get_spellcheck_results {
for my $spellchecker (spellchecker_candidates()) {
my @words;
my $ok = eval {
- my $pid = open3((my ($child_in, $spellcheck_results, $child_err)), $spellchecker);
+ # IPC::Open3 says "If CHLD_ERR is false [...] then STDOUT and
+ # STDERR of the child are on the same filehandle (this means that
+ # an autovivified lexical cannot be used for the STDERR
+ # filehandle [...])" - what a crummy API!
+ my $child_error = gensym;
+
+ my $pid = open3(my ($child_in, $spellcheck_results), $child_error, $spellchecker);
print $child_in $document;
@@ -66,6 +73,9 @@ sub _get_spellcheck_results {
@words = <$spellcheck_results>;
+ my $errors = do { local $/; <$child_error> };
+ die "spellchecker had errors: $errors" if length $errors;
+
# wait for spellchecker to clean up
waitpid $pid, 0;
commit 80d948c624540bb405547151f5342070685ad3f5
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Apr 27 13:35:02 2011 -0400
0.13
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 615dbc2..e134633 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -10,7 +10,7 @@ use File::Spec;
use IPC::Open3;
use Symbol 'gensym';
-our $VERSION = '0.12';
+our $VERSION = '0.13';
our @EXPORT = qw(
pod_file_spelling_ok
commit 9224d06b71b309250a5b3d482d154ea494c556c6
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed May 25 18:23:09 2011 -0400
Copy each stopword to avoid modifying readonly values
This avoids "Modification of a read-only value attempted" errors
when you use add_stopwords("constant", "strings", "here")
This, similar to what we were doing, doesn't work:
perl -e 'sub foo { for my $x (@_) { $x =~ s/./X/; print $x } } foo("hello")'
This, what we do as of this commit, does:
perl -e 'sub foo { for (@_) { my $x = $_; $x =~ s/./X/; print $x } } foo("hello")'
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index e134633..0c32f8d 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -216,7 +216,10 @@ sub _is_perl {
}
sub add_stopwords {
- for my $word (@_) {
+ for (@_) {
+ # explicit copy so we don't modify constants as in add_stopwords("SQLite")
+ my $word = $_;
+
# XXX: the processing this performs is to support "perl t/spell.t 2>>
# t/spell.t" which is bunk. in the near future the processing here will
# become more modern
commit 07ea76943c33c8800b9c5aa4cb36f30566aa736f
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri May 27 14:26:08 2011 -0400
Regenerate README
diff --git a/README b/README
index 7bca4c5..6f9f057 100644
--- a/README
+++ b/README
@@ -69,12 +69,8 @@ FUNCTIONS
"has_working_spellchecker"), this test will issue a "skip all"
directive.
- If you're testing a distribution, just create a t/pod-spell.t:
-
- use Test::More;
- plan skip_all => "Spelling tests only for authors" unless -d "inc/.author";
- use Test::Spelling;
- all_pod_files_spelling_ok();
+ If you're testing a distribution, just create a t/pod-spell.t with the
+ code in the "SYNOPSIS".
Returns true if every POD file has correct spelling, or false if any of
them fail. This function will show any spelling errors as diagnostics.
commit 9622f8047bbe2a46e125c083b1e6b46f21c36740
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri May 27 14:25:42 2011 -0400
0.14 and its Changes
diff --git a/Changes b/Changes
index 542bc1c..d7c6ac9 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
Revision history for Test-Spelling
+0.14 2011-05-27
+ - Fix an error when using add_stopwords("constant", "strings")
+ [rt.cpan.org #68471] (reported by Nicholas Bamber)
+
0.13 2011-04-27
- Make alternatives checking more robust by reading the spellchecker's
STDERR
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 0c32f8d..d6f791e 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -10,7 +10,7 @@ use File::Spec;
use IPC::Open3;
use Symbol 'gensym';
-our $VERSION = '0.13';
+our $VERSION = '0.14';
our @EXPORT = qw(
pod_file_spelling_ok
commit 7d8284240be34f3ecbadf3cc611bba7301f552b3
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 16:47:56 2011 -0400
Dist improvements
diff --git a/Makefile.PL b/Makefile.PL
index b431cf7..2efce68 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,10 +1,15 @@
use inc::Module::Install;
+use Module::Install::GithubMeta;
+use Module::Install::ManifestSkip;
+use Module::Install::AutoManifest;
name 'Test-Spelling';
all_from 'lib/Test/Spelling.pm';
-repository 'http://github.com/bestpractical/test-spelling';
+githubmeta;
requires 'Pod::Spell' => '1.01';
+manifest_skip;
+auto_manifest;
WriteAll;
commit 26afcde2604571946a8d638dd0544336be269fad
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 16:48:11 2011 -0400
gitignore
diff --git a/.gitignore b/.gitignore
index b63c3ea..a8f5af7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,5 @@ pm_to_blib
.cover_db/
.prove
+MANIFEST.SKIP
+MYMETA.json
commit 8bf7f39dfe822e1ea4f718d40746c2cd81283a8b
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 16:49:20 2011 -0400
Add a pod-spell.t (haha)
diff --git a/t/pod-spell.t b/t/pod-spell.t
new file mode 100644
index 0000000..3d26efb
--- /dev/null
+++ b/t/pod-spell.t
@@ -0,0 +1,9 @@
+use Test::More;
+BEGIN {
+ plan skip_all => "Spelling tests only for authors"
+ unless -d 'inc/.author';
+}
+
+use Test::Spelling;
+all_pod_files_spelling_ok();
+
commit c3b98dfb924f4a10e5e10fa0ab5aa8091b0a5486
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 16:52:24 2011 -0400
Use the same $filename/$testname pattern
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index d6f791e..b575f0f 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -323,7 +323,7 @@ in the L</SYNOPSIS>.
Returns true if every POD file has correct spelling, or false if any of them fail.
This function will show any spelling errors as diagnostics.
-=head2 pod_file_spelling_ok( FILENAME[, TESTNAME ] )
+=head2 pod_file_spelling_ok( $filename[, $testname ] )
C<pod_file_spelling_ok> will test that the given POD file has no spelling
errors.
commit 123ee0bece7f017f94a2ddb85b6ec4f8170e054a
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 16:53:27 2011 -0400
Use fewer TESTNAME/FILENAMEs
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index b575f0f..9530e3d 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -331,9 +331,9 @@ errors.
When it fails, C<pod_file_spelling_ok> will show any spelling errors as
diagnostics.
-The optional second argument TESTNAME is the name of the test. If it
-is omitted, C<pod_file_spelling_ok> chooses a default test name "POD spelling
-for FILENAME".
+The optional second argument is the name of the test. If it is
+omitted, C<pod_file_spelling_ok> chooses a default test name "POD
+spelling for C<$filename>".
=head2 all_pod_files( [@dirs] )
commit b09524b8dc57762e75238f8fc7becaa0768cd10b
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 16:54:06 2011 -0400
stopwords -> stop wards
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 9530e3d..294fb4c 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -276,16 +276,16 @@ your distribution's F<xt/> directory. Anyway, people installing your module
really do not need to run such tests, as it is unlikely that the documentation
will acquire typos while in transit. :-)
-You can add your own stopwords, which are words that should be ignored by the
+You can add your own stop words, which are words that should be ignored by the
spell check, like so:
add_stopwords(qw(asdf thiswordiscorrect));
Adding stopwards in this fashion affects all files checked for the remainder of
the test script. See L<Pod::Spell> (which this module is built upon) for a
-variety of ways to add per-file stopwords to each .pm file.
+variety of ways to add per-file stop words to each .pm file.
-If you have a lot of stopwords, it's useful to put them in your test file's
+If you have a lot of stop words, it's useful to put them in your test file's
C<DATA> section like so:
use Test::Spelling;
commit b211dd49115264b9565919de231be367d5928e1b
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 16:54:37 2011 -0400
Fix an actual typo caught by the self-test :)
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 294fb4c..ca9e451 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -281,7 +281,7 @@ spell check, like so:
add_stopwords(qw(asdf thiswordiscorrect));
-Adding stopwards in this fashion affects all files checked for the remainder of
+Adding stop words in this fashion affects all files checked for the remainder of
the test script. See L<Pod::Spell> (which this module is built upon) for a
variety of ways to add per-file stop words to each .pm file.
commit 1768d7a5543a04ad237cccb20e2d7a4dcdd56466
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 16:54:45 2011 -0400
Add stop words for this dist
diff --git a/t/pod-spell.t b/t/pod-spell.t
index 3d26efb..3c2bb9e 100644
--- a/t/pod-spell.t
+++ b/t/pod-spell.t
@@ -5,5 +5,16 @@ BEGIN {
}
use Test::Spelling;
+add_stopwords(<DATA>);
all_pod_files_spelling_ok();
+__END__
+Brohman
+CPAN
+Tubert
+brian
+foy
+
+preprocessing
+spellcheck
+subdirectories
commit 6aad3662a9542ea899f6bef355a3e4f60a2578ac
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 17:08:29 2011 -0400
Basic tests
diff --git a/Makefile.PL b/Makefile.PL
index 2efce68..7c56b31 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -8,6 +8,8 @@ all_from 'lib/Test/Spelling.pm';
githubmeta;
requires 'Pod::Spell' => '1.01';
+test_requires 'Test::More' => '0.88';
+test_requires 'Test::Tester';
manifest_skip;
auto_manifest;
diff --git a/t/basic.t b/t/basic.t
new file mode 100644
index 0000000..d812df7
--- /dev/null
+++ b/t/basic.t
@@ -0,0 +1,28 @@
+use Test::Tester;
+use Test::More;
+use Test::Spelling;
+
+BEGIN {
+ if (!has_working_spellchecker()) {
+ plan skip_all => "no working spellchecker found";
+ }
+}
+
+check_test(sub { pod_file_spelling_ok('t/corpus/no-pod.pm', 'no pod has no errors') }, {
+ ok => 1,
+ name => 'no pod has no errors',
+});
+
+check_test(sub { pod_file_spelling_ok('t/corpus/good-pod.pm', 'good pod has no errors') }, {
+ ok => 1,
+ name => 'good pod has no errors',
+});
+
+check_test(sub { pod_file_spelling_ok('t/corpus/bad-pod.pm', 'bad pod has no errors') }, {
+ ok => 0,
+ name => 'bad pod has no errors',
+ diag => "Errors:\n incorectly",
+});
+
+done_testing;
+
diff --git a/t/corpus/bad-pod.pm b/t/corpus/bad-pod.pm
new file mode 100644
index 0000000..f6fdd55
--- /dev/null
+++ b/t/corpus/bad-pod.pm
@@ -0,0 +1,14 @@
+package Bad::Pod;
+use strict;
+use warnings;
+
+sub foo {}
+
+__END__
+
+=head1 NAME
+
+Bad::Pod - incorectly spelled POD
+
+=END
+
diff --git a/t/corpus/good-pod.pm b/t/corpus/good-pod.pm
new file mode 100644
index 0000000..e1e4d10
--- /dev/null
+++ b/t/corpus/good-pod.pm
@@ -0,0 +1,14 @@
+package Good::Pod;
+use strict;
+use warnings;
+
+sub foo {}
+
+__END__
+
+=head1 NAME
+
+Good::Pod - correctly spelled POD
+
+=END
+
diff --git a/t/corpus/no-pod.pm b/t/corpus/no-pod.pm
new file mode 100644
index 0000000..ac9332e
--- /dev/null
+++ b/t/corpus/no-pod.pm
@@ -0,0 +1,8 @@
+package No::Pod;
+use strict;
+use warnings;
+
+sub foo {}
+
+__END__
+
commit 0d5b5e732520240c9ac2b6be76aee3a54ebd51dd
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 17:11:21 2011 -0400
Confirm that adding a stopword works
diff --git a/t/corpus/stopword.pm b/t/corpus/stopword.pm
new file mode 100644
index 0000000..247ab4e
--- /dev/null
+++ b/t/corpus/stopword.pm
@@ -0,0 +1,14 @@
+package Stopword::Pod;
+use strict;
+use warnings;
+
+sub foo {}
+
+__END__
+
+=head1 NAME
+
+Stopword::Pod - correctly spelled POD and a xzaue creator
+
+=END
+
diff --git a/t/stopword.t b/t/stopword.t
new file mode 100644
index 0000000..21dd860
--- /dev/null
+++ b/t/stopword.t
@@ -0,0 +1,26 @@
+use Test::Tester;
+use Test::More;
+use Test::Spelling;
+
+BEGIN {
+ if (!has_working_spellchecker()) {
+ plan skip_all => "no working spellchecker found";
+ }
+}
+
+check_test(sub { pod_file_spelling_ok('t/corpus/stopword.pm', 'stopword pod file') }, {
+ ok => 0,
+ name => 'stopword pod file',
+ diag => "Errors:\n xzaue",
+});
+
+add_stopwords('xzaue');
+
+check_test(sub { pod_file_spelling_ok('t/corpus/stopword.pm', 'stopword pod file') }, {
+ ok => 1,
+ name => 'stopword pod file',
+});
+
+done_testing;
+
+
commit 2b22c86db4dcc7b6f24711a80584f72dcb085178
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 17:13:22 2011 -0400
0.15 and its Changes
diff --git a/Changes b/Changes
index d7c6ac9..773e476 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,10 @@
Revision history for Test-Spelling
+0.15 2011-08-22
+ - Begin adding actual tests
+ (Hilariously, adding the suggested t/pod-spell.t to this
+ dist to test itself found a typo: "stopwards")
+
0.14 2011-05-27
- Fix an error when using add_stopwords("constant", "strings")
[rt.cpan.org #68471] (reported by Nicholas Bamber)
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index ca9e451..f6db720 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -10,7 +10,7 @@ use File::Spec;
use IPC::Open3;
use Symbol 'gensym';
-our $VERSION = '0.14';
+our $VERSION = '0.15';
our @EXPORT = qw(
pod_file_spelling_ok
commit 6e858672e83c7e7385ee61980bbcc7c410b82ffd
Author: Shawn M Moore <sartak at gmail.com>
Date: Mon Aug 22 17:14:07 2011 -0400
gitignore built dists
diff --git a/.gitignore b/.gitignore
index a8f5af7..cde9bad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,5 @@ pm_to_blib
.prove
MANIFEST.SKIP
MYMETA.json
+
+Test-Spelling-*.tar.gz
commit 5bee432b31386332b676b99a5658824231d41e2f
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri Dec 14 15:41:37 2012 -0800
Allow the use of different POD parsers instead of Pod::Spell
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index f6db720..0c83de4 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -20,12 +20,14 @@ our @EXPORT = qw(
all_pod_files
set_pod_file_filter
has_working_spellchecker
+ set_pod_parser
);
my $TEST = Test::Builder->new;
my $SPELLCHECKER;
my $FILE_FILTER = sub { 1 };
+my $POD_PARSER = Pod::Spell->new;
sub spellchecker_candidates {
# if they've specified a spellchecker, use only that one
@@ -112,8 +114,7 @@ sub invalid_words_in {
open my $handle, '>', \$document;
# save digested POD to the string $document
- my $checker = Pod::Spell->new;
- $checker->parse_from_file($file, $handle);
+ $POD_PARSER->parse_from_file($file, $handle);
my @words = _get_spellcheck_results($document);
@@ -238,6 +239,10 @@ sub set_pod_file_filter {
$FILE_FILTER = shift;
}
+sub set_pod_parser {
+ $POD_PARSER = shift;
+}
+
1;
__END__
@@ -395,6 +400,13 @@ L</all_pod_files_spelling_ok>).
return 1;
});
+=head2 set_pod_parser($object)
+
+By default L<Pod::Spell> is used to generate text suitable for spellchecking
+from the input POD. If you want to use a different parser, perhaps a
+customized subclass of L<Pod::Spell>, call C<set_pod_parser> with an object
+that isa L<Pod::Parser>.
+
=head1 SEE ALSO
L<Pod::Spell>
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list