On Fri, Nov 22, 2002 at 05:29:34PM +0100, Philippe 'BooK' Bruhat wrote:
> 1..7
> ok 1 - The proxy requests what we expect
> ok 1 - Got what we wanted
> ok 2 - The proxy requests what we expect
> ok 2 - Got what we wanted
> ok 1 - Served the correct number of requests
> not ok 3 - Got what we wanted
> #     Failed test (t/20simple.t at line 84)
> ok 3 - The proxy requests what we expect
> # Looks like you planned 7 tests but only ran 3.
> 
> (Before you ask: yeah, I know one of the tests fails, I am also
> investigating this)
> 
> Each instance of the forked Test::Builder thinks it's all alone in the
> world, and starts at 1. Which is perfectly understandable.
> 
> So I tried to add the following lines at the beginning of my test script:
> 
>     my $test = Test::Builder->new;
>     $test->use_numbers( 0 );
> 
> But Test::Builder is still confused and only sees the three tests run by
> the parent process.

To get that to work you'd also shut off the ending checks.

    $test->no_ending(1);

so it won't complain because it thinks you only ran 3 tests.

The alternative is to play with the counter.

    use Test::More tests => 7;

    ...regular tests...

    fork a child
       ...run a test normally...

    back in the parent
        # force the parent to increment the counter for the test run in the child.
       $test->current_test($test->current_test + 1);
       


> Ooh, I think I get it: the parent process' Test::Builder warns about the
> fact that it has not seen all tests (since most of them were run by the
> children). On the other hand, Test::Harness sees everything right, since
> it's looking at the test script output only.
> 
> Hence with make test, I simple have garbled output due to the diagnostics.
> 
> I guess my question is something like is there's a way for the children's
> test output to be taken into account by the main Test::Builder object?
> Must I really use some IPC to report back to the parent process'
> Test::Builder object?

forking and IPC are not my bag, so I don't know what's possible and
what's not.  If you can do something to coordinate the parent and
child objects which works everywhere, send a patch.  But I don't know
if IPC is portable.


-- 
Michael G Schwern   <[EMAIL PROTECTED]>   http://www.pobox.com/~schwern/
Perl Quality Assurance     <[EMAIL PROTECTED]>       Kwalitee Is Job One

Reply via email to