On Tue, Dec 07, 2004 at 09:32:37AM -0800, Ovid wrote:

> Is there is anything in the Test::* hierarchy that allows callbacks to
> be triggered on test failures?  It would be nice to pass a sub that
> automatically dies on warnings, prints stack traces, cleans up temp
> files (or preserves them) or any of a number of things that I'd like to
> be able to handle.
> 
> Someone's surely done this before, I just can't seem to find anything
> that's already implemented.

Test.pm has onfail(), though it doesn't get called immediately for every
test failure.  I mentioned this fairly early into the design of
Test::Simple/More, but I don't think anyone was particularly interested
in it at the time, and I've never had the need to it myself.  Stas was
also mentioning something similar to this on IRC fairly recently IIRC.

Seems to me it would be useful to be able to register a sub to be called
and pass the current state in (ie has the test passed and any other
useful information that might be hanging around such as the test
filename, line, number, name^Wcomment^Wlabel) and to be able to modify
the state, either directly, or by returning a status or dying or
something.  Or do it via OO.  Or whatever.

Doing something similar before the test is run seems useful too.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

Reply via email to