Slash Boxes
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 ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday February 26, 2008
06:49 AM

Global bug of the day: Test::Builder

[ #35765 ]

Today I upgraded to the latest stable Test::Builder and now we have the following failure:

#!/usr/bin/env perl

use strict;
use warnings;

use Test::Builder 0.75;
use Test::More qw/no_plan/;
    package Foo;
    use Test::More;

    local $TODO = 'foobar';
    ok 0, 'testing todo';

Since my latest posts have been focusing heavily on global effects breaking code, you might be immediately suspicious of the local $TODO and you'd be right.

Test::Builder versions 0.75 and above have an ok() method which has this interesting line:

my $todo = $self->todo;

It used to say this:

my($pack, $file, $line) = $self->caller;

my $todo = $self->todo($pack);

In the todo method, we have this:

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;

In other words, rather than check our actual calling package, we wind up checking the last package that the functions were exported to.

Once again, relying on global data has introduced a bug in our code.

This bug has been reported.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.