perldevel-cover

Devel::Cover HTML output


I am playing around with Devel::Cover to see how well our test suite is actually testing our codebase. I run all of our tests using -MDevel::Cover nothing seems to fail or crash, but the HTML output of the coverage table has entries like these for all of our Modules:

enter image description here

The number of BEGINs listed seems to match the number of use Module::X statements in the source file, but really clutters the HTML output. Is there any way to disable this feature? I don't see any mention of it in the tutorial or the Github issue tracker.


Solution

  • The reason for this is that "use" is "exactly equivalent to"

    BEGIN { require Module; Module->import( LIST ); }
    

    (See perldoc -f use.)

    And then "BEGIN" is basically the same as "sub BEGIN" - you can put the "sub" there if you want to. See perldoc perlmod.

    So what you really do have is a subroutine, and that is what Devel::Cover is reporting.

    Like many parts of Devel::Cover, the details of perl's implementation, or at least the semantics, are leaking through. There is no way to stop this, though I would be amenable to changes in this area.