Hello,

I am trying to test a module, but to that end, I must fork two processes,
and the parent and the two kids each perform a series of tests.

The output is such:

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.

1..7
ok - The proxy requests what we expect
ok - Got what we wanted
ok - The proxy requests what we expect
ok - Got what we wanted
ok - Served the correct number of requests
not ok - Got what we wanted
#     Failed test (t/20simple.t at line 87)
ok - The proxy requests what we expect
# Looks like you planned 7 tests but only ran 3.

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?

Or is it considered ok just to have the kids spit "ok" and "not ok" and to
let Test::Harness organise the resulting mess?

Be aware that the test results do not look that good (when no test fails):

Failed 1/5 test scripts, 80.00% okay. 0/29 subtests failed, 100.00% okay.

Not that great.


So I guess I'll have to go the IPC way, after all. Any advice or success
story?

-- 
 Philippe "BooK" Bruhat

 Even the worst guesser is right once in a while.
                                    (Moral from Groo The Wanderer #72 (Epic))


Reply via email to