in reply to Re: BAIL_OUT with older Test::More
in thread BAIL_OUT with older Test::More

Yes, thank you!

I'd stumbled across that thread, wasn't sure it would work, but it does (with weird output, though):

Test::Builder->BAILOUT("oh no"); # outputs: # tests_sante_reporting/02-infocentre-sanity.......NOK 1FAILED--Furthe +r testing stopped: oh no # # Looks like you planned 2 tests but only ran 1. Test::Builder->BAILOUT("oh no\n"); # outputs (yes, like this): # # tests_sante_reporting/02-infocentre-sanity.......NOK 1# Looks like + you planned 2 tests but only ran 1. # FAILED--Further testing stopped: oh no Test::Builder->BAILOUT("\noh no\n"); # outputs (yes, also like this): # tests_sante_reporting/02-infocentre-sanity.......NOK 1# Looks like y +ou planned 2 tests but only ran 1. # FAILED--Further testing stopped.

I think I'm going to go with number 1.

Replies are listed 'Best First'.
Re^3: BAIL_OUT with older Test::More
by Khen1950fx (Canon) on Feb 15, 2011 at 17:07 UTC
    I tried it like this, and it works. BAILOUT is doable. I designed it to have failing tests just to see what happens...
    #!/usr/bin/perl use strict; use warnings; use Test::Builder; use Test::More; BEGIN { use_ok( 'Test::Simple ' ); } my $Exit_Code; BEGIN { *CORE::GLOBAL::exit = sub { $Exit_Code = shift; }; } my $output; my $TB = Test::More->builder; $TB->output(\$output); my $Test = Test::Builder->create; $Test->level(0); $Test->plan(tests => 3); plan tests => 1; $Test->is_eq( $output, <<'OUT' ); 1..3 Bail out! Sayonara! OUT if ($Test) { $Test->is_eq( $Exit_Code, 255 ); $Test->ok( $Test->can("BAILOUT"), "Backwards compat" ); } else { BAILOUT(print "Sayonara!\n"); }