Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Monday September 02, 2002
01:38 AM

Andy Lester rocks my world

[ #7463 ]

Andy is truly Lazy, and if I work hard enough, maybe I can be that Lazy too.

I am in Chicago for a couple years, and have the great fortune to work with Andy Lester on a few things. I first met him because he sent me some patches for Business::ISBN, then some more, and then some more patches. When I moved to Chicago, we got together a couple of times---a continuing dividend from Perl Mongers.

He keeps using my modules, and even tests the ones that he does not use. He showed me a "pod bummer" in some module I wrote, and I fixed that, and since he is also a test fascist, every time he reports a bug I write a test for it. I had not thought to test POD before, and even though Andy told me to wait for Sean Burke's new POD parser, I created Test::Pod based on the old stuff. I was happy with that until Andy sent me a bit of code that automatically found all the ".pm" files in blib using the new File::Find::Rule.


# $Id: pod.t,v 1.1 2002/08/31 22:17:26 comdog Exp $

BEGIN {
        use File::Find::Rule;
        @files = File::Find::Rule->file()->name( '*.pm' )->in( 'blib/lib' );
        }

use Test::Pod tests => scalar @files;

foreach my $file ( @files )
        {
        pod_ok($file);
        }

This code is brilliant! It is so simple, and small, and right that I can only call myself an idiot for not already doing this.Now I have pod.t in any module I work on, and I have found quite a number of missing "=back" commands.

This little tidbit was worth all of the time I spent fixing or improving Business::ISBN and Tie::Cycle for him (and the rest of the world). Sometimes open source really pays off. Andy contributes to CPAN testers, sends me patches to modules he does not even use, and makes me a better coder.

This is not the end though. Andy raises the level of the game. He's got it going on. Once I know this trick, I can easily test each module for compilation errors.


BEGIN {
          use File::Find::Rule;
          @classes = map { my $x = $_;
                  $x =~ s|^blib/lib/||;
                  $x =~ s|/|::|g;
                  $x =~ s|\.pm$||;
                  $x;
                  } File::Find::Rule->file()->name( '*.pm' )->in( 'blib/lib' );
          }

use Test::More tests => scalar @classes;

foreach my $class ( @classes )
          {
          use_ok( $class );
          }

Since each of these solutions discover the modules on their own, I do not have to remember to add new modules to the tests. I do less work and find more bugs. I created a really simple module, Test::Pod, then Andy showed me how to use.

Maybe someone will let him write a book on testing Perl, but until then, take a look in the t/ directory in some of his distributions and remember that the fascists were the ones who made the trains run on time.