On Sat, Feb 26, 2005 at 06:00:02PM -0500, Tom Moertel wrote:
> How I do do this now is somewhat hackish.  For the duration of a
> property check, I redefine some Test::Builder internals like so:
> 
> sub check_property {
>     no warnings 'redefine';
>     my $property = shift;
>     my $diags = [];
>     local *Test::Builder::ok   = sub { $_[1] ? 1 : 0 };
>     local *Test::Builder::diag = sub { shift; push @$diags, @_; 0 };
>     return ( $diags,
>              Test::LectroTest::TestRunner->new(@_)->run($property) );
> }
> 
> The idea is to sever the part of Test::Builder that reports back to
> the caller (which I want) from the part that reports back to the test
> harness (which I do not want).  It seems to work fine, but mucking
> around with another module's internals carries with it an element of
> risk that I don't like, and I would rather have a cleaner option.

That's pretty much it.  ok() and diag() aren't internals so its ok to
"override" them like that.  What's missing, and why its so nasty, is a way
to write a proper Test::Builder subclass and make everything use it.

Its on the TODO list.

Reply via email to