develooper Front page | perl.qa | Postings from January 2008

Re: Dieing on failure and preserving line numbers

Thread Previous
From:
Ovid
Date:
January 12, 2008 06:47
Subject:
Re: Dieing on failure and preserving line numbers
Message ID:
47251.74268.qm@web60811.mail.yahoo.com
--- Paul Johnson <paul@pjcj.net> wrote:

> I don't want it on all the time.  I don't want to change anything in
> my
> code to do it.  I don't (yet) care that it doesn't run my cleanup
> code
> or whatever.  I just want to easily find out what the first error
> was,
> and then have a short edit/test cycle until the bug is fixed.  Then
> I'll
> go back to plain "make test" as usual.
> 
> Anyway, thanks for making this happen.

Schwern's agreed that if a somewhat clean solution can be found, he'll
add it.

Aristotle's suggestion of dieing on the next ok() seems like the
easiest to implement.  The problem is this:

  is 3, 4, 'whee!';
  is factorial(123456), $some_num, '... be patient ...';

If we have 'die on fail' for the first test, the arguments of the
second test will still be evaluated, but we'll die before the test is
executed (what I wouldn't give for lazy evaluation ...).  You'll get
most of what you want, but the "next arguments are evaluated" caveat is
important.

I think the interface should have three ways of being used:

  use Test::More 'no_plan', 'fail';

That means it's always on.

  use Test::More 'no_plan';

  is 3, 4, 'whee!';
  die_on_fail();
  is factorial(123456), $some_num, '... be patient ...';

The first failure won't trigger the die.

  DIE_ON_FAIL=1 prove ...

That let's people have global control (and is easy to bind to keys in
editors).

Cheers,
Ovid

--
Buy the book  - http://www.oreilly.com/catalog/perlhks/
Perl and CGI  - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog     - http://use.perl.org/~Ovid/journal/

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About