Discussion:
Test::Builder2: running coverage fails to display key modules
James E Keenan
2012-08-04 12:54:27 UTC
Permalink
When I run Devel::Cover over the Test::Builder2 test suite
(v1.005000_001-193-g00d4609), I get no coverage reports for
blib/lib/Test/Builder2.pm or blib/lib/Test/More.pm.

See: http://thenceforward.net/test-more/coverage/coverage.html

Any thoughts on why that is happening?

Thank you very much.
Jim Keenan
Paul Johnson
2012-08-04 14:54:52 UTC
Permalink
Post by James E Keenan
When I run Devel::Cover over the Test::Builder2 test suite
(v1.005000_001-193-g00d4609), I get no coverage reports for
blib/lib/Test/Builder2.pm or blib/lib/Test/More.pm.
See: http://thenceforward.net/test-more/coverage/coverage.html
Any thoughts on why that is happening?
I'm not sure. I just ran 00d4609 (which I had as 1.005000_005) through
my development copy of Devel::Cover (which will shortly become a
release) and got somewhat different results. I ran:

$ cover -test -report html_basic

and got these results:

http://pjcj.sytes.net/tmp/test-more/cover_db/coverage.html

which includes both Test/Builder2.pm and Test/More.pm as well as some
other modules, but doesn't include Makefile.PL. How did you generate
your coverage report?
--
Paul Johnson - ***@pjcj.net
http://www.pjcj.net
James E Keenan
2012-08-04 15:16:14 UTC
Permalink
On 8/4/12 10:54 AM, Paul Johnson wrote:
How did you generate
Post by Paul Johnson
your coverage report?
Main part of my shell script:

cd $SOURCEDIR && \
cover -delete $COVERAGEDIR && \
PERL5OPT=-MDevel::Cover=-db,$COVERAGEDIR/ \
perl Makefile.PL && make && make test && \
cover $COVERAGEDIR \
-coverage statement \
-coverage branch \
-coverage condition \
-coverage subroutine \
-ignore_re '^t\/' \
-ignore_re '^\/usr\/local\/bin' \
-ignore_re '^\/tmp' \
chmod 0755 $COVERAGEDIR/
James E Keenan
2012-08-04 15:34:20 UTC
Permalink
Post by Paul Johnson
How did you generate
Post by Paul Johnson
your coverage report?
cd $SOURCEDIR && \
cover -delete $COVERAGEDIR && \
PERL5OPT=-MDevel::Cover=-db,$COVERAGEDIR/ \
perl Makefile.PL && make && make test && \
cover $COVERAGEDIR \
-coverage statement \
-coverage branch \
-coverage condition \
-coverage subroutine \
-ignore_re '^t\/' \
-ignore_re '^\/usr\/local\/bin' \
-ignore_re '^\/tmp' \
chmod 0755 $COVERAGEDIR/
Data point: When I call this command, the first thing I get is a couple
of dozen warnings like this:

Devel::Cover: Warning: can't open ro-accessor for object_id
(.../test-more/blib/lib/TB2/Mouse.pm) for MD5 digest: No such file or
directory

... even though blib/lib/TB2/Mouse.pm clearly exists.

jimk
James E Keenan
2012-08-04 16:19:18 UTC
Permalink
Post by Paul Johnson
How did you generate
Post by Paul Johnson
your coverage report?
cd $SOURCEDIR && \
cover -delete $COVERAGEDIR && \
PERL5OPT=-MDevel::Cover=-db,$COVERAGEDIR/ \
perl Makefile.PL && make && make test && \
cover $COVERAGEDIR \
-coverage statement \
-coverage branch \
-coverage condition \
-coverage subroutine \
-ignore_re '^t\/' \
-ignore_re '^\/usr\/local\/bin' \
-ignore_re '^\/tmp' \
chmod 0755 $COVERAGEDIR/
Data point: When I call this command, the first thing I get is a couple
Devel::Cover: Warning: can't open ro-accessor for object_id
(.../test-more/blib/lib/TB2/Mouse.pm) for MD5 digest: No such file or
directory
... even though blib/lib/TB2/Mouse.pm clearly exists.
And a further data point:

When I call a command as simple as:

cover $COVERAGEDIR -summary

... I fail to get reporting on the three packages mentioned earlier,
though all tests pass. This suggests that for some reason data is not
being recorded in the Devel::Cover DB.
Paul Johnson
2012-08-04 18:31:52 UTC
Permalink
Post by James E Keenan
Post by Paul Johnson
How did you generate
Post by Paul Johnson
your coverage report?
cd $SOURCEDIR && \
cover -delete $COVERAGEDIR && \
PERL5OPT=-MDevel::Cover=-db,$COVERAGEDIR/ \
perl Makefile.PL && make && make test && \
I think the root of the problem lies here. If I'm not mistaken, I think
that $PERL5OPT will only have this value for the call of "perl
Makefile.PL" and not for make and make test.
Post by James E Keenan
Post by Paul Johnson
cover $COVERAGEDIR \
And if PERL5OPT was set here you would get am error message that "cover"
shouldn't be run with coverage turned on.
Post by James E Keenan
Post by Paul Johnson
-coverage statement \
-coverage branch \
-coverage condition \
-coverage subroutine \
-ignore_re '^t\/' \
-ignore_re '^\/usr\/local\/bin' \
-ignore_re '^\/tmp' \
chmod 0755 $COVERAGEDIR/
Might I suggest something like this?

cd $SOURCEDIR && \
cover -delete $COVERAGEDIR && \
perl Makefile.PL && \
HARNESS_PERL_SWITCHES=-MDevel::Cover=-db,$COVERAGEDIR,-coverage,statement,branch,condition,subroutine make test && \
cover $COVERAGEDIR

Or, perhaps better still,

cd $SOURCEDIR && \
perl Makefile.PL && \
DEVEL_COVER_OPTIONS=-db,$COVERAGEDIR,-coverage,statement,branch,condition,subroutine cover -test $COVERAGEDIR
Post by James E Keenan
Data point: When I call this command, the first thing I get is a couple
Devel::Cover: Warning: can't open ro-accessor for object_id
(.../test-more/blib/lib/TB2/Mouse.pm) for MD5 digest: No such file or
directory
... even though blib/lib/TB2/Mouse.pm clearly exists.
Mouse.pm exists, but
"ro-accessor for object_id (.../test-more/blib/lib/TB2/Mouse.pm)" doesn't.
That's the made-up filename that that Mouse has pretended was the
location of that code. Recent versions of Devel::Cover should suppress
that warning.
Post by James E Keenan
cover $COVERAGEDIR -summary
... I fail to get reporting on the three packages mentioned earlier,
though all tests pass. This suggests that for some reason data is
not being recorded in the Devel::Cover DB.
Hopefully I've explained why above. What's confusing me is why you're
getting as much coverage as you are.
--
Paul Johnson - ***@pjcj.net
http://www.pjcj.net
Loading...