britterm has asked for the wisdom of the Perl Monks concerning the following question:
I have a module which forks several times to set up a few workers. I'm using Test::More and Devel::Cover to do unit testing of my code and generate code coverage. I have unit tests that stress the workers, but the coverage report shows that the forked code didn't execute even though it did.
I considered putting the child code into separate functions that can be tested independently of forking, but the code relies on piped handles to communicate with the parent, which AFAIK do not function without forking (can't write/read to a pipe in the same process). I would have to do a significant amount of coding in my unit tests to attempt to work around this, and I'm looking for a more straightforward solution if there is one.
Does anyone know how to configure Devel::Cover to detect coverage in the child process when the program forks? Is this even possible? (perhaps with a different coverage tool?)
Thanks in advance,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Code coverage of forked code
by britterm (Initiate) on May 25, 2016 at 16:21 UTC | |
by mr_mischief (Monsignor) on May 25, 2016 at 19:03 UTC | |
by ovedpo15 (Pilgrim) on Oct 17, 2019 at 11:03 UTC |