[dancer-users] How do you measure code coverage?
David Cantrell
david at cantrell.org.uk
Fri Jan 31 14:00:01 GMT 2014
On Fri, Jan 31, 2014 at 10:15:17AM +0400, ???????? ???????????????????? wrote:
> Devel::Cover does not create any metrics for such code:
>
> any ['get', 'post'] => '/login' => sub {
> ...
> }
>
> So my question is how do you measure coverage of code that is tested?
This is a known bug/mis-feature in Devel::Cover:
https://github.com/pjcj/Devel--Cover/issues/51
In our Dancer app at work I have some spectacularly evil code that works
around it. In a module that our coverage checking script loads before
anything else, it stuffs a sub-ref into @INC. That sub-ref intercepts
any attempt to load the files in which our Dancer routes are defined,
and wraps them in:
package TheModuleWhoseBrainsWeAreCorrupting;
sub main {
# our victim's body goes here
}main();
Yes, it's effectively a source filter. Yes, it uses regexes to parse
perl. Yes, that's why I'm not showing you the code. It's evil, and if
you're going to do horrible things like that you should write it
yourself so that you understand what's going on.
--
David Cantrell | top google result for "topless karaoke murders"
On the bright side, if sendmail is tied up routing spam and pointless
uknot posts, it's not waving its arse around saying "root me!"
-- Peter Corlett, in uknot
More information about the dancer-users
mailing list