Skip to content

Commit

Permalink
has_working_spellchecker and skip_all if there is none
Browse files Browse the repository at this point in the history
  • Loading branch information
sartak committed Apr 25, 2011
1 parent 9a30b0c commit 85da2b6
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/Test/Spelling.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 85da2b6

Please sign in to comment.