in reply to BAIL_OUT with older Test::More

BAIL_OUT() used to be BAILOUT(). The current Test::Builder has BAIL_OUT(), so I think that you could use BAILOUT() instead. According to this thread from Google groups perl.perl6.internals, BAILOUT can be used and remains as an undocumented and deprecated method.

Replies are listed 'Best First'.
Re^2: BAIL_OUT with older Test::More
by Anonymous Monk on Feb 15, 2011 at 17:00 UTC

    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.

      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"); }