Free pod checking for your modules

petdance on 2003-05-23T03:39:07

pudge is doin' a bunch of new module releases tonight. I'm posting my standard pod.t file for him to include in his releases. # $Id$

use Test::More; use File::Spec; use File::Find; use strict;

eval "use Test::Pod 0.95";

if ($@) { plan skip_all => "Test::Pod v0.95 required for testing POD"; } else { Test::Pod->import; my @files; my $blib = File::Spec->catfile(qw(blib lib)); find( sub {push @files, $File::Find::name if /\.p(l|m|od)$/}, $blib); plan tests => scalar @files; foreach my $file (@files) { pod_file_ok($file); } }


Nice

barbie on 2003-05-23T15:07:14

I had the idea to rewrite my little test script for Pod::Coverage along the same lines now.

#/usr/bin/perl -w use strict;

use Test::More; use File::Find::Rule;

# only for developing, ignore otherwise eval "use Pod::Coverage";

if ($@) { plan skip_all => "Pod::Coverage required for evaluating POD";

} else { Pod::Coverage->import; # find me some modules my @files = File::Find::Rule->file()->name( qr/\.pm$/ )->in('blib/lib'); plan tests => scalar @files; foreach my $file (@files) { # get me the package name $file =~ s=^.*lib/|\.pm$==g; $file =~ s|/|::|g; # go for it checkpod($file); } }

sub checkpod { my $pc = new Pod::Coverage package => $_[0]; is($pc->coverage,1); # if it failed, tell me what we failed on print STDERR "$_[0] qw(".join(" ",$pc->uncovered).")\n" if($pc->coverage

Buggar....

barbie on 2003-05-23T15:24:09

My excuse is that it is Friday!!!!!

The code I meant to correctly post.....
#/usr/bin/perl -w
use strict;

use Test::More;
use File::Find::Rule;

# only for developing, ignore otherwise
eval "use Pod::Coverage";

if ($@) {
    plan skip_all => "Pod::Coverage required for evaluating POD";

} else {
    Pod::Coverage->import;
    # find me some modules
    my @files = File::Find::Rule->file()->name( qr/\.pm$/ )->in('blib/lib');
    plan tests => scalar @files;
    foreach my $file (@files) {
        # get me the package name
        $file =~ s=^.*lib/|\.pm$==g;
        $file =~ s|/|::|g;
        # go for it
        checkpod($file);
    }
}

sub checkpod {
    my $pc = new Pod::Coverage package => $_[0];
    is($pc->coverage,1);
    # if it failed, tell me what we failed on
    print STDERR "$_[0] qw(".join(" ",$pc->uncovered).")\n"    if($pc->coverage < 1);
}

Re:Buggar....

petdance on 2003-05-23T17:36:26

I'm specifically not using File::Find::Rule because I'm finding that many people don't have it, and a lot of my modules (including all of bdfoy's Mac::* stuff) are pulling in too many dependencies already.

But I WAS using F:F:R at one point. It's a fine module.

Re:Buggar....

barbie on 2003-05-25T19:34:07

I tend to only use it while I'm creating modules, then take it out to deploy them. Just a safety precaution on my part to ensure I've written about everything. Afterall it should only be an issue for the developer not the enduser :)

Re:Buggar....

petdance on 2003-05-25T19:47:19

Yes, but it's still nice to have the tests out there and have them run on other machines if the user has the ability to do so...