[libdist-zilla-plugin-test-podspelling-perl] 01/05: Use fake spell checker to ensure reliable output

Axel Beckert abe at deuxchevaux.org
Mon May 25 10:02:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

abe pushed a commit to annotated tag 2.001004
in repository libdist-zilla-plugin-test-podspelling-perl.

commit 7edd9c348d0929fb6e546926b7fa03aedf9bf853
Author: Randy Stauner <randy at magnificent-tears.com>
Date:   Mon Dec 12 16:13:24 2011 -0700

    Use fake spell checker to ensure reliable output
    
    We're not testing the accuracy of the spell checker,
    we're just testing that something is being run
    for the files in the dist.
    
    Hopefully this will reduce the unidentifiable smoke failures.
    
    GH #3
---
 corpus/foo/dist.ini   |  2 ++
 corpus/nobin/dist.ini |  2 ++
 t/checked.t           | 31 ++++++++++++++++++-------------
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/corpus/foo/dist.ini b/corpus/foo/dist.ini
index dc16b76..5a91d93 100644
--- a/corpus/foo/dist.ini
+++ b/corpus/foo/dist.ini
@@ -5,3 +5,5 @@ version = 1
 
 [GatherDir]
 [Test::PodSpelling]
+; a very liberal spell checker
+spell_cmd = perl -ne "print if /spellingerror/"
diff --git a/corpus/nobin/dist.ini b/corpus/nobin/dist.ini
index dc16b76..5a91d93 100644
--- a/corpus/nobin/dist.ini
+++ b/corpus/nobin/dist.ini
@@ -5,3 +5,5 @@ version = 1
 
 [GatherDir]
 [Test::PodSpelling]
+; a very liberal spell checker
+spell_cmd = perl -ne "print if /spellingerror/"
diff --git a/t/checked.t b/t/checked.t
index 5738ef5..1bdd691 100644
--- a/t/checked.t
+++ b/t/checked.t
@@ -9,22 +9,23 @@ use Dist::Zilla::Tester;
 use Path::Class;
 use Cwd ();
 
-BEGIN {
-	use English;
+# This test uses a custom "spell checker" defined in corpus/*/dist.ini
+# (setting it here didn't work, it seems to get overridden in the do-file)
+# to produce reliable output so that we can ensure that each expected
+# file (beneath bin/ and lib/) is in fact being tested.
+# (We wouldn't want to generate a script that didn't actually check our files).
+# Defining a custom one enables us to get reliable results regardless
+# of which version of which spell checker (or none at all) is available.
 
-	plan skip_all => 'No working spellchecker found'
-		unless has_working_spellchecker;
-
-	plan skip_all => 'This Test has problems on BSD... patches welcome'
-		if $OSNAME =~ m/bsd/i;
-
-	no English;
-}
-
-ok( has_working_spellchecker, 'test has working spellchecker' );
+# This test builds the fake dists (in corpus/) with dzil,
+# then executes the actual test script generated by this module.
+# Test::Tester intercepts the Test::Builder calls to allow us to verify
+# which tests have been run (for example 'spelling ok for lib/Foo.pm').
 
 # lib/ and bin/
+# (bin/foo should be 'not ok' because of a spelling error)
 spell_check_dist( foo   => [file(qw(bin foo)) => {ok => 0}], file(qw(lib Foo.pm)) );
+
 # just lib/
 spell_check_dist( nobin => file(qw(lib Foo.pm)) );
 
@@ -49,16 +50,20 @@ sub spell_check_dist {
       # all_pod_files_spelling_ok sets a plan which causes problems
       local *Test::Tester::Delegate::plan = sub {};
 
-      # run the actual xt file
+      # run the actual xt file generated by this module
       do "${\ file(qw(xt author pod-spell.t)) }";
     },
     [
+      # results we're expecting
       map {
         +{
+          # expected test result ('ok' or 'not ok')
           ok => 1,
+          # file name
           name => 'POD spelling for ' . $_->[0],
           # depth: starts at 1; +1 for do-file; +1 for the all_ func
           depth => 3,
+          # overridden expectations (in args to spell_check_dist)
           %{ $_->[1] },
         },
       }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-plugin-test-podspelling-perl.git



More information about the Pkg-perl-cvs-commits mailing list