I definitely like the idea of avoiding the need to call the function at the end. I might not understand the intricacies of how END blocks work, but I don't understand how this would work.

Specifically something like this:

use Test::Terminated;

my $is_ok = oops_exit_called();
ok($is_ok);

## terminated_ok();


So accidentally, some of the tests were not executed. With the two END block idea, wouldn't they both execute still in this case?

- Dan


A. Pagaltzis wrote:
* Daniel Risse <[EMAIL PROTECTED]> [2006-08-08 05:10]:
So something like this:

use Test::Simple 'no_plan';
use Test::Terminated;

# insert tests here

# signal we made it to the end okay
terminated_ok();

It occurs to me that you don’t even need that.

Just do something like the following:

    package Test::Terminated;

    our $ok = 0;

    END { die_screaming() if $ok != 1 }

    sub import {
        # ...
        eval qq{
            package $caller_pkg;
            END { ++$Test::Terminated::ok }
        };
    }

You just have to make sure that the END blocks get seen by perl
in the right order to make them run in the proper LIFO order.

That way, simply loading Test::Terminated ensures that the test
has to finish properly, ie. a sufficiently advanced interface, in
TheDamian parlance.

This needs some work to ensure it will play properly with tests
that bail or with skipping the entire file and the like, of
course.

The only problem I can see with this implementation would be if something could prevent the END block from executing.

Regards,

Reply via email to