Looks like I have it now. I removed Hook::LexWrap, handled the
$Test::Builder::Level myself and did some curious work to preserve the
exact return value behavior of Test::Builder::diag.
Remove Hook::LexWrap and change the 'if fail' test in the import method
to the following:
if ('fail' eq $_[$i]) {
splice @_, $i, 1;
my $ok = \&Test::Builder::ok;
no warnings 'redefine';
*Test::Builder::ok = sub {
local $Test::Builder::Level = $Test::Builder::Level + 1;
$_[0]->{XXX_test_failed} = 0;
my $result = $ok->(@_);
$_[0]->{XXX_test_failed} = ![ $_[0]->summary ]->[-1];
return $result;
};
my $diag = \&Test::Builder::diag;
*Test::Builder::diag = sub {
local $Test::Builder::Level = $Test::Builder::Level + 1;
my @result = $diag->(@_);
if ( $_[0]->{XXX_test_failed} ) {
$_[0]->{XXX_test_failed} = 0;
die "Test failed. Halting.\n";
}
# this strange beast is to capture the exact behavior of
# Test::Builder::diag
return @result ? 0 : ();
};
last;
}
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/