I've been using Test::Most at work for it's handy-dandy defer_plan
option, but noticed an interesting situation.  This code:

    use Test::Most qw/ defer_plan /;

    pass();

    END {
        pass();
    }

    all_done( 2 );

Produces this output:

    defer_plan....
    ok 1
    1..2
    ok 2 - no warnings
    All 2 subtests passed

...which is a TAP failure: "Parse errors: Plan (1..2) must be at the
beginning or end of the TAP output"

It seems that because the last test runs after the all_done(), the TAP
that gets generated isn't valid.  Fair enough.  I can change that to:

    END {
        pass();
        all_done( 2 );
    }

...and everything's just fine.  The problem really comes when the test
being run in the END block is in another module (such as Test::NoWarnings).

In that case, the way to generate well-formed TAP seems to be to put the
END block above the use statement, which either means an end statement
at the top in the section of the code with the use statements, or to put
the use statement lower than the END block.

Neither of those look great.  Is there another, probably more obvious
solution that I'm missing?

Josh

Reply via email to