in reply to BAIL_OUT with older Test::More

You could download and install a newer version of Test::More which has BAIL_OUT and use that instead. Place the updated module in a directory which you can control, then point to it with lib or PERL5LIB.

Replies are listed 'Best First'.
Re^2: BAIL_OUT with older Test::More
by ELISHEVA (Prior) on Feb 15, 2011 at 14:19 UTC

    Unless your managers/IT department are absolutely opposed to your downloading modules into your own home directory, this node: Yes, even you can use CPAN discusses how you to do what toolic is suggesting.

      Well, I was thinking of this as well, but with the red tape and all I still don't know if I can introduce foreign code like this. It depends on whether the management will OK this or not, and whether the IT people feel paranoid that day...

      In the meantime I'm doing without BAIL_OUT. In the eventuality that I can't use a more modern Test::More at all, what do you suggest?

        Looking at the oldest source code on CPAN (Test-Harness 2.52) it might be as simple as die "Bail out!" when you want to bail.

        The older versions of prove are backed by Test::Harness. prove calls Test::Harness::runtests which does nothing more than stuff each .t file into a strap (see Test::Harness::Straps), execute it, and add the results to its cumulative total.

        Digging down into the source code, I notice that Test::Harness::Straps has a flag $self->{saw_bailout} that is set to 1 if the .t file's output stream (STDERR, I believe) contains a line matching: /^Bail out!\s*(.*)/i. Test::Harness checks for this flag and, if found, calls a bail out handler subroutine which... aborts the testing process.

        If that doesn't work and you are very determined, I'd consider studying the source code of those two modules closely and writing a test runner script of your own that does what you want.

        One trick is to have each .t file check whether a file .BAILOUT exists. If it does, don't run any tests. If you want to BAILOUT, create this file, then die. Use a first (and a last) test file that cleans up the .BAILOUT file.