Devel--Cover icon indicating copy to clipboard operation
Devel--Cover copied to clipboard

Better mod_perl and options documentation

Open KevinField opened this issue 11 years ago • 10 comments

I can't seem to get started with Devel-Cover under mod_perl 2.0.4 and perl 5.10.1. I even switched from win32 to CentOS 6.5 (64-bit) with Devel-Cover in mind :)

So, just following exactly what the docs in Devel::Cover 1.0.8 say, I put 'use Devel::Cover' in the <Perl> section of my httpd.conf (this functions as my startup script.) When I start httpd, I get some command-line output:


Starting httpd: Devel::Cover 1.08: Collecting coverage data for branch, condition, statement, subroutine and time. Pod coverage is unavailable. Please install Pod::Coverage from CPAN. Collecting under mod_perl/2.0.4 Selecting packages matching: Ignoring packages matching: /Devel/Cover[./] Ignoring packages in: /usr/lib64/perl5 /usr/lib64/perl5/vendor_perl /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/share/perl5 /usr/share/perl5/vendor_perl Devel::Cover: Writing coverage database to /pathtomyapp/config/cover_db/runs/1390485929.5668.48243


File stmt bran cond sub time total


...ite/lib/MyModule/ErrorLogging.pm 71.6 0.0 0.0 88.9 100.0 66.7 Total 71.6 0.0 0.0 88.9 100.0 66.7



I then make use of my app via web browser, shut down the web server, and run cover (after chmodding its output directory so I can write to it.) Even though the cover db file (as I can see if I cat it) has references to my ErrorLogging.pm module and to httpd.conf, the html output doesn't even include that, instead listing no files whatsoever.

  1. How do I get the cover db to cover the rest of my code that should have been covered via web hits?
  2. How do I get cover to include all files that it did actually cover in its HTML output?

If we could answer these two questions I think it'd be helpful to include them in the documentation. To me it is not clear what format to use to pass options when using mod_perl (especially when mod_perl leaves an empty %ENV) and whether to select all files I should be passing that info to Devel::Cover or to 'cover' on the command line or both.

For example, if I put

$ENV{DEVEL_COVER_OPTIONS} = '-dir,/home/srv/cover/,-db,/home/srv/cover/cover_db';

...just before 'use Devel::Cover', it doesn't change where it stores the cover db, like I would expect it to.

KevinField avatar Jan 23 '14 14:01 KevinField

Ran into the same issue, ended up adding to the apache config something like

PerlSwitches -MDevel::Cover=-silent,1,-db,/home/username/cover_db

But I never got to the bottom of what was going on.

jpsalvesen avatar Jun 17 '15 12:06 jpsalvesen

OK, this works, in the sense that it does redirect the output elsewhere.

However, it still only includes ErrorLogging.pm and does not seem to add anything else as I browse around, even after I stop the httpd service.

KevinField avatar Jul 24 '15 19:07 KevinField

(Tested with Devel-Cover 1.20, Perl 5.10.1 on CentOS 6.5 64-bit, with mod_perl 2.0.4.)

KevinField avatar Jul 24 '15 19:07 KevinField

Oh, and I guess the fact that it includes ErrorLogging.pm in the HTML output is also an improvement. :) But not quite enough to actually check my app...

KevinField avatar Jul 24 '15 19:07 KevinField

What triggers it to dump the file immediately, I wonder?

KevinField avatar Jul 24 '15 19:07 KevinField

I tried each of these option groups and the result did not change:

StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 50 MaxClients 50 MaxRequestsPerChild 4000

StartServers 1 MinSpareServers 1 MaxSpareServers 1 ServerLimit 1 MaxClients 1 MaxRequestsPerChild 4000

KevinField avatar Jul 24 '15 19:07 KevinField

Also with

  MaxClients 1
  MaxRequestsPerChild 0

...as suggested for NYTProf.

KevinField avatar Jul 24 '15 19:07 KevinField

I tried starting the server with -X, and using PerlSwitches plain outside of a <Perl> block and near the start (before LoadModule mod_perl even) of my conf. It does something interesting: the first output is normal, showing ErrorLogging, dumping the cover_db and exiting. But it is followed by I'm assuming the first child process, which then stays running, not showing ErrorLogging or dumping the cover_db.

At this point things seemed promising, so I do some tests here, but whether I Ctrl+C the running process, or open a new terminal and "sudo service httpd stop", I get the same result: "Segmentation fault" and no dump. Maybe there's a way to trigger a dump before server shutdown?

KevinField avatar Jul 25 '15 09:07 KevinField

In fact, there is, of course...so I made a script containing just this:

use Devel::Cover;
Devel::Cover::report();

...and called it via http, and it did in fact write cover_db. Then I shut down (which segfaulted again), and...no, just ErrorLogging in there still.

However, I did notice that the write statement points to something that did not get output:

Devel::Cover: Writing coverage database to /home/srv/cover/cover_db/runs/1437817755.39607.36239

There is no such dir under 'runs', unlike the one that the parent output, which got created just fine.

KevinField avatar Jul 25 '15 09:07 KevinField

Success! The problem was, I suppose since I start the httpd server with sudo, that the cover_db and runs dirs get created as root:root. When I chmod 777'd those dirs (even while running) and had it output before shutdown, it did just fine, with all my modules! (It still segfaulted on shutdown, but I can live with that for now.)

KevinField avatar Jul 25 '15 09:07 KevinField