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:

    "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;

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

    diag("Testing Test::Most $Test::Most::VERSION, Perl $], $^X");
    my @dependencies = qw(
    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


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 Have Perl; Will Travel. Freelance Perl/Testing/Agile consultant. Photo by Warning: that site is not safe for work. The photographer is a good friend of mine, though, and it's appropriate to credit his work.