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

ferreira (5993)

ferreira
  (email not shown publicly)
http://www.ferreira.triang.net/

Just another Brazilian Perl hacker.

Journal of ferreira (5993)

Monday December 10, 2007
10:59 AM

BEGIN { use_ok } keeps biting

[ #35077 ]

The fearless Michael Schwern kept his word and brought back the Test-Simple fix for BEGIN { use_ok } bug. (If you don't know what I am saying, read this).

Some CPAN dists remain unfixed and those who upgraded the basic test modules will see an error while testing. Outstanding examples are:

Notice that the fix called for in this distributions is a real test bug. A contrived example is of the form:

use Test::More;

if ( $exp_which_tells_test_should_be_skipped ) {
    plan tests => 1; # this will happen at runtime
} else {
    plan 'skip_all' => 1; # that too
}

BEGIN { use_ok 'File::Temp' } # at compile-time

ok(1);

When Test::Builder had the bug, it swallowed the exception during BEGIN { use_ok } which announced a test before planning. Also, the test count should not include the use_ok to get pass this point. Yes, for some time, we authors have introduced not one, but two bugs in this type of code to make it work. Now it is time to write it down correctly.

use Test::More;

BEGIN {
    if ( $exp_which_tells_test_should_be_skipped )     {
        plan tests => 2;
    } else {
        plan 'skip_all' => 1;
    }
}

BEGIN { use_ok 'File::Temp' } # at compile-time

ok(1);

Bonus point: The fixed version works ok with the old (buggy) and the new Test-Simple.

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