We've test failures at the BBC do to the following simplified test case:
#!/usr/bin/env perl
use strict;
use warnings;
use Test::Builder 0.75;
use Test::More qw/no_plan/;
BEGIN {
package Foo;
use Test::More;
}
TODO: {
local $TODO = 'foobar';
ok 0, 'testing todo';
}
The problem is in Test::Builder::ok. You now have:
my $todo = $self->todo;
That used to be:
my($pack, $file, $line) = $self->caller;
my $todo = $self->todo($pack);
Because the first argument to &todo is now undefined, the &todo method
breaks:
sub todo {
my($self, $pack) = @_;
$pack = $pack || $self->exported_to || $self->caller($Level);
return 0 unless $pack;
no strict 'refs'; ## no critic
return defined ${$pack.'::TODO'} ? ${$pack.'::TODO'}
: 0;
}
$self->exported_to reports the last package that the functions were
exported to, and in my sample code, this means that package $Foo::TODO
is checked instead of $main::TODO.
This appears to be a similar bug to
http://rt.cpan.org/Ticket/Display.html?id=33574
The simple work around is to ensure that Test::More in your testing code
is always loaded after the other classes, but because load order is
important, if you have tests being run in more than one package at the
same time, TODO tests are now very fragile.
Yes, you can argue that we shouldn't do this, but it does play havoc
with code already out there.
Cheers,
Ovid