4

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.

Hunter McMillen
  • 59,865
  • 24
  • 119
  • 170
  • The version that we have installed is `1.0.8` which is the latest release according to the README. – Hunter McMillen Dec 20 '13 at 14:11
  • I think you mean `1.08`, which is the latest on CPAN. How do you run it? Do you use `cover`? Show relevant code/commands. – toolic Dec 20 '13 at 15:03
  • Yes sorry, that is what I meant. I run our entire test suite with prove then call cover: `PERL5OPT=-MDevel::Cover prove -r -s lib/ && cover` – Hunter McMillen Dec 20 '13 at 15:23

1 Answers1

3

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.

Robert
  • 7,394
  • 40
  • 45
  • 64
pjcj
  • 421
  • 2
  • 3