Devel--Cover
Devel--Cover copied to clipboard
Cover with fork
Hi,
I'm using the Cover module to monitor test coverage of a application module written in perl.
The tests are running inside the application itself. The application forks a process just before a test is started. Therefor i start the inital perl process via the -MDevel:Cover switch.
From a process view this option is propagated to the child subprocesses.
But it looks like, that the subprocesses are not generating cover data.
Should this module work with forked subprocesses?
Hi @sidey79, Have you managed to solve this issue? I'm facing the same problem.
No, i haven`t found a solution :(
Funnily, I'm having the opposite problem. Devel::Cover happily persists across fork() calls and causes massive slowdowns once an exec() is done in the child process. See https://stackoverflow.com/questions/59623927/how-do-i-disable-develcover-for-forked-child-processes
I wonder why Devel::Cover doesn't survive the fork() in your case.
I think it survives in my case also, but there seems to be correct no results witten to the database
What you can do is to call Devel::Cover::report()
explicitly before terminating each spawned process if running with coverage analysis. This is what we do in one of the projects I participate in:
https://github.com/os-autoinst/openQA/blob/c4c7e4dad37c6e20ada91772c939917383834e56/t/25-cache-service.t#L74 comparable to:
my $process = process sub {
# some spawned process running code and eventually terminating …
Devel::Cover::report() if Devel::Cover->can('report');
};
@sidey79 You say both "a process" and "subprocesses": are you trying to collect coverage data from multiple processes in parallel?
Using App::Prove or App:ForkProve I set --jobs 1
or I get lots of deep recursion warnings and no coverage data out of tests run with Devel::Cover. It will combine data from multiple forked processes, just not simultaneously.