Tracking Down Bug Reports

I often find that test reports I get from smokers are not terribly useful for failures. Sometimes it's obvious. Other times it's not. One thing which helps a bit is this bit in your t/load.t test:

diag(
    "Testing My::Module $My::Module::VERSION, Perl $], $^X"
);

In the CPAN testers reports, you can click on a test report and instantly see the module version, Perl version and path to the current Perl (arguably not as useful).

I like to go a step further and include information about all modules I claim to require. For my t/00-load.t for Test::Most, I have the following:

use Test::More tests => 9;

BEGIN {
    local $^W;
    use_ok('Test::Most')
      or BAIL_OUT("Cannot load Test::Most");
    use_ok('Test::Most::Exception')
      or BAIL_OUT("Cannot load Test::Most::Exception");

    diag("Testing Test::Most $Test::Most::VERSION, Perl $], $^X");
    my @dependencies = qw(
      Exception::Class
      Test::Deep
      Test::Differences
      Test::Exception
      Test::Harness
      Test::More
      Test::Warn
    );
    foreach my $module (@dependencies) {
        use_ok $module or BAIL_OUT("Cannot load $module");
        my $version = $module->VERSION;
        diag("    $module version is $version");
    }
}

Now on my test reports, I see output like this:

# Testing Test::Most 0.21, Perl 5.008009, /home/chris/pit/rel/perl-5.8.9/bin/perl
#     Exception::Class version is 1.29
#     Test::Deep version is 0.106
#     Test::Differences version is 0.5
#     Test::Exception version is 0.29
#     Test::Harness version is 3.21
#     Test::Simple version is 0.94
#     Test::Warn version is 0.21

If I want to replicate a bug, this is a huge benefit

3 Comments

I thought that the tester reports had the list of all required modules and their loaded version numbers listed at the bottom of the tester reports under "PREREQUISITES". Are there cases you have seen where this information is incorrect or not present?

Please don't! I'd greatly prefer people to use an idiom that's more compliant with what we have already in place. Important second level dependencies should be added to the prerequisites declaration right away. If they later turn out to be no second level dependencies any more, so be it and you can change the declaration later. For other interesting or optional modules I suggest adding them if they are already installed, like:

for my $interestingmodule (qw(   Archive::Tar   Archive::Zip   Compress::Bzip2   Compress::Zlib   Data::Dumper)){    eval "require $interestingmodule";    if (!$@) {     $prereqpm->{$interestingmodule} ||= 0;    } } And later

 WriteMakefile( ... PREREQPM => $prereqpm, ...); If you're doing it that way you report their version not only to yourself but also to other readers of cpan testers reports (e.g. analysis) in the standard way that was invented right for this purpose. I have often missed such gratuitous declarations in testers reports.

Leave a comment

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/