On Thu, May 11, 2006 at 11:57:44AM +1000, Kirrily Robert wrote: > I've got a guy at work who wants to take coverage reports and bung > them in a database so he can track historical coverage data. As I > see it, he needs to somehow parse the stuff in cover_db/ but neither > he nor I understand what's in there. Do any modules already exist > for this? I believe the thing that generates the coverage reports > currently is C code or something? So isn't there anything CPANish to > do this?
We discussed this question on IRC, but it was 4am for me and I was not long back from a reasonably long day at work so, although I think the advice I gave was sound, it may be worth expanding on it here. This message was almost finished when my router crashed, and when I got home I forgot to finish it, so apologies for the delay. First, there's no need to delve into C to access the coverage data. The required API is in Devel::Cover::DB. The documentation in there is somewhat sparse, but covers the basics. The easiest thing to do is probably to look at one of the existing reports and copy it. I would suggest the textual report as being the simplest to follow. That is found in Devel::Cover::Report::Text. With respect to the infrastructure required, I would suggest making your code a report and using the "cover" program to call it. If you make your code Devel::Cover::Report::Filldb for example, and put it somewhere where perl can find it, then calling "cover -report filldb" will call your report. For example, here is the report subroutine fro the text report. sub report { my ($pkg, $db, $options) = @_; print_runs($db, $options); for my $file (@{$options->{file}}) { print_file ($db, $file, $options); print_branches ($db, $file, $options) if $options->{show}{branch}; print_conditions ($db, $file, $options) if $options->{show}{condition}; print_subroutines($db, $file, $options) if $options->{show}{subroutine}; } } >From here you should be able to access any information you need. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net