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 ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
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)

Thursday November 27, 2008
08:41 AM

Happy Accidents in Testing

[ #37957 ]

Due to some issues in Test::Builder, Test::Most's "die on failure" option has a curious behavior which was a right pain to work around, but basically means that we don't really die on failure. We can't because we'd lose our diagnostic information. Instead, we die when the next test is run or when the test run is finished. It's generally transparent to the end-user, but that causes a problem:

use Test::Most qw/die no_plan/;

# this triggers the die
ok 0;

# but these arguments are evaluated first
is factorial(2000), $some_big_assed_number;

Basically, we have to continue running until the next test. If there's expensive computation or something which changes the state of our system, the we may have to wait or have the system's state different from the state in which the failure occurred. This is really annoying and problematic. It does, however, add one tiny little benefit:

ok $false
  or explain $some_data;

That "or show $some_data" still triggers due to this bug, thus allowing us extra diagnostic information. It's a tiny saving grace, but a nice one nonetheless (and also lets us easily implement clean up code).

Note that Schwern is fixing the issue in Test::Builder 2.0.

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.