Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 ( #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? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-08-20 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?