Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Results printing multiple times when testcase with fork using Test::more module

by shmem (Chancellor)
on May 20, 2009 at 14:12 UTC ( [id://765232]=note: print w/replies, xml ) Need Help??


in reply to Results printing multiple times when testcase with fork using Test::more module

Since you fork, you spawn another process from the current process and thus have two results. Why do you fork if you want just one run of the test?

If you want the child to terminate before the evaluation of the last ok() test, your sub should look like:

sub for{ my $pid = fork; if($pid == 0 ){ diag "$$: 0\n"; exit; }else{ diag "$$: 1\n"; waitpid($pid,0); } 1; }

Replies are listed 'Best First'.
Re^2: Results printing multiple times when testcase with fork using Test::more module
by thiagu_mvt (Sexton) on May 21, 2009 at 10:51 UTC
    This is just an example. My actual program calls an API function which is doing the forking through 'open3'. So not my intention or in control.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://765232]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2025-05-16 17:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.