Automated module testing systems are becoming more and more common.  In addition to our long-serving CPAN Testers service, Perl authors can have their modules tested by Travis for Linux and Appveyor for Windows.  CPAN Testers tests each distribution uploaded to PAUSE, whereas Travis and Appveyor keep an eye on your GitHub account (or other services) and try testing after each push to the home repo.

Something that I’ve found helps out with diagnosing problems is by having a diagnostic dump of modules in the the first test.  I’ll have a test like t/00-modules.t, like this one from ack:


#!perl -T

use warnings;
use strict;
use Test::More tests => 1;

use App::Ack;   # For the VERSION
use File::Next;
use Test::Harness;
use Getopt::Long;
use Pod::Usage;
use File::Spec;

my @modules = qw(
    File::Next
    File::Spec
    Getopt::Long
    Pod::Usage
    Test::Harness
    Test::More
);

pass( 'All external modules loaded' );

diag( "Testing ack version $App::Ack::VERSION under Perl $], $^X" );
for my $module ( @modules ) {
    no strict 'refs';
    my $ver = ${$module . '::VERSION'};
    diag( "Using $module $ver" );
}

Then, when the user or automated tester runs make test, the first thing out tells me exactly what we’re working with.

[19:15:52] t/00-load.t .................. 1/23 # Testing ack version 2.999_01 under Perl 5.026000, /home/andy/perl5/perlbrew/perls/perl-5.26.0/bin/perl
# Using File::Next 1.16
# Using File::Spec 3.67
# Using Getopt::Long 2.49
# Using Pod::Usage 1.69
# Using Test::Harness 3.38
# Using Test::More 1.302073

This is also very useful for when users have test failures and submit their logs to a bug tracker. It’s especially important in this case to show the Getopt::Long version because ack has had problems in the past with some changes in API in the past.