Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Odd output from Test::More

by Bloodnok (Vicar)
on Sep 26, 2007 at 17:19 UTC ( #641197=perlquestion: print w/ replies, xml ) Need Help??
Bloodnok has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

When running dmake test (using Strawberry perl on Windoze) I'm getting a lot of errors I've not previously encountered - all being of the form ...

Confused test output: Test <n> answered after test <n> Confused test output: Test <n+1> answered after test <n+1> . .
My question is now, I suspect, somewhat self-evident - can anyone tell me what on earth is going on ... or at least point me in the direction of a resolution.
All of my other modules pass muster via dmake test no probs.
It strikes me that Test::More may not be quite as self-contained as it might be since I obviously need to have some idea of what's going on 'under the hood'.

TIA ,

Comment on Odd output from Test::More
Download Code
Re: Odd output from Test::More
by Sidhekin (Priest) on Sep 26, 2007 at 17:30 UTC

    Threading or (pseudo-)forking? (It kinda looks like you have two threads running the tests simultaneously.) Or just confused test numbers?

    Either way, you are getting the same test numbers twice in the test stream:

    ... ok n ok n ok n+1 ok n+1 ...

    I ran into this a lot when writing tests that fork. Mostly I resolved it by manually increasing the test count and waiting for the children to terminate:

    # in the parent, while a child is running $n tests: my $Test = Test::More->builder; $Test->current_test( $Test->current_test + $n ); wait;

    Could we perchance see the .t code that produces these complaints?

    Update: As andreas1234567's code demonstrates, the error message does not mean what I thought it meant (and still think it says). An "ok 2" followed by an "ok 1" will produce "test 2 answered after test 2". (And an "ok 1" followed by another "ok 1" are quietly accepted as two different tests. Bah.)

    Oh well, it's still a case of test numbers coming in the wrong order. (And meanwhile, a new harness is on its way ...)

    print "Just another Perl ${\(trickster and hacker)},"
    The Sidhekin proves Sidhe did it!

Re: Odd output from Test::More
by andreas1234567 (Vicar) on Sep 26, 2007 at 20:39 UTC
    Sidhekin is definitely onto something. Begin looking for fork:
    $ cat 641197.t use strict; use warnings; use Test::More qw(no_plan); my $pid = fork; ($pid) ? print "ok 1\n" : print "ok 2\n"; __END__ $ prove 641197.t 641197....ok 1/0Confused test output: test 2 answered after test 2 # No tests run! 641197....dubious Test returned status 255 (wstat 65280, 0xff00) FAILED--1 test script could be run, alas--no output ever seen $
    --
    Andreas
      TFT Andreas,

      However, there are no explicit calls to fork() in my test script ... nor the code under test ?!

      The really odd thing is that until yesterday, the module wasn't working and I wasn't seeing the errors - however, since I managed to get the module to work, the errors manifested themselves ... the principle change being the adoption of the Hash::Merge module in favour of a homegrown attempt - AFAICT, the Hash::Merge module only employs recursion i.e. I don't believe it to be using fork().

        Yes, a recursive function can also produce similar results:
        $ cat 641197-2.t use strict; use warnings; use Test::More qw(no_plan); sub f { my $i = shift; print "ok $i\n"; return $i < 2 ? 1 : f($i-1) + f($i-2); } f(3); __END__ $ prove 641197-2.t 641197-2....# No tests run! 641197-2....ok 1/0Confused test output: test 2 answered after test 3 Test output counter mismatch [test 4] Test output counter mismatch [test 5] 641197-2....dubious Test returned status 255 (wstat 65280, 0xff00) FAILED--1 test script could be run, alas--no output ever seen
        --
        Andreas

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://641197]
Approved by Sidhekin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2014-09-22 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (208 votes), past polls