Stas Bekman wrote:
[...]
I just need to figure out why Test::Builder doesn't do proper sub-test counting :9(

Test output counter mismatch [test 32]
ok 13 - tid: 0: pass 1:
Test output counter mismatch [test 33]
ok 14 - tid: 0: pass 2:
Test output counter mismatch [test 34]
ok 15 - tid: 0: pass 1:
...

even though threads.pm was loaded before Test::Builder.

looks like someone was loading Test::Builder before we had a chance to boot threads.pm, fixed by moving threads.pm loading to the very beginning of the startup file.


I've further simplified the buffering by creating a new class:

package Apache::TestToStringRequest;

sub new {
    my($class, $r) = @_;
    die "\$r is required" unless $r;
    Apache::TestToString->start;
    return bless \$r, __PACKAGE__;
}

sub DESTROY {
    my $self = shift;
    $$self->print(Apache::TestToString->finish);
}

So now the test needs to only create the object, and its DESTROY will flush the data (not very intuitive though)

sub handler {
    my $r = shift;

    # this buffers the ok's and will flush them out on sub's end
    my $x = Apache::TestToStringRequest->new($r);

    plan tests => $tests;

    read_test();
    threads->new(\&read_test)->join() for 1..$threads;
    read_test();

    Apache2::Const::OK;
}

should probably use $r->pool->cleanup_register(sub { untie *STDOUT }); instead, in which case no object will be needed. Though it won't work under mp1. What should go with?


-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to