Scott McWhirter wrote: > This would be easy to do in Test::Builder within &Test::Builder::ok by > making it call $Test->BAIL_OUT(); > > Then at least you would get it across all Test::* modules.
yeah, that's what I was implying in my followup message. the attached patch against 0.70 seems to do what I had in mind. --Geoff
--- lib/Test/Builder.pm 2007-09-07 15:33:04.000000000 -0400 +++ lib/Test/Builder.pm! 2007-09-07 15:32:30.000000000 -0400 @@ -196,6 +196,8 @@ $self->{No_Header} = 0; $self->{No_Ending} = 0; + $self->{Bail_Out_on_Failure} = 0; + $self->_dup_stdhandles unless $^C; return undef; @@ -457,6 +459,10 @@ } } + if (!$test && $self->{Bail_Out_on_Failure}) { + $self->BAIL_OUT('failure detected and bail_out_on_failure() set'); + } + return $test ? 1 : 0; } @@ -1130,9 +1136,17 @@ If set to true, no "1..N" header will be printed. +=item B<bail_out_on_failure> + + $Test->bail_out_on_failure($bail_out); + +Normally, Test::Builder continues right along on when a test fails. +By setting this to true a failure will call BAIL_OUT() and all +activity will be wrapped up as appropriate. + =cut -foreach my $attribute (qw(No_Header No_Ending No_Diag)) { +foreach my $attribute (qw(No_Header No_Ending No_Diag Bail_Out_on_Failure)) { my $method = lc $attribute; my $code = sub {