pjcj / devel--cover Goto Github PK
View Code? Open in Web Editor NEWCode coverage metrics for Perl
Home Page: http://www.pjcj.net/perl.html
Code coverage metrics for Perl
Home Page: http://www.pjcj.net/perl.html
For example, if you generate a coverage report for CPU::Emulator::Z80 (there's a t/coverage.sh script; see [email protected]:DrHyde/perl-modules-CPU-Emulator-Z80.git) and look at cover_db/blib-lib-CPU-Emulator-Z80-pm.html, it doesn't say anything at all for lines like this:
10: $VERSION = '1.0';
...
32: my @REGISTERS8 = qw(A B C D E F R W Z I);
although they obviously got compiled - and in this case I know that they got executed too.
From looking at various other examples, eg http://lists.preshweb.co.uk/pipermail/dancer-users/2011-October/001990.html, it appears that the general rule is that code gets reported on if it is within a named subroutine. Anonymous subs' code appear in reports if the anonysub is defined within a named subroutine (see eg CPU::Emulator::Z80 line 209) but not if it is defined outside any named sub (see eg line 7 in TestApp/lib/TestApp.pm as generated by Michael Dorman in his email to dancer-users).
How can I mark all statements in a subroutine as uncoverable (other than putting an "uncoverable statement" comment before each one)?
t/e2e/amoose_basic.t ........ 1/1 # Test 1 got:
+----+-------------------------------------------+----+-------------------------------------------+
| Elt|Got | Elt|Expected |
+----+-------------------------------------------+----+-------------------------------------------+
| 0|'DB.pmline 882.\n' | 0|'DB.pmline 882.\n' |
| | * 1|'DB.pmline 882.\n' *
| 1|'Reading database from \n' | 2|'Reading database from \n' |
| 2|'\n' | 3|'\n' |
| 3|'\n' | 4|'\n' |
+----+-------------------------------------------+----+-------------------------------------------+
| 43|'Subroutine Count Location \n' | 44|'Subroutine Count Location \n' |
| 44|'- ----- --------------------\n' | 45|'- ----- --------------------\n' |
| 45|'BEGIN 1 tests/moose_basic:14\n' | 46|'BEGIN 1 tests/moose_basic:14\n' |
* 46|'\n' * | |
| 47|'\n' | 47|'\n' |
+----+-------------------------------------------+----+-------------------------------------------+
(/home/mhorsfall/Downloads/Devel-Cover-0.80/blib/lib/Devel/Cover/Test.pm at line 334)
# Expected: No differences (output)
# /home/mhorsfall/Downloads/Devel-Cover-0.80/blib/lib/Devel/Cover/Test.pm line 334 is: $ENV{DEVEL_COVER_NO_COVERAGE} ? ok 1 : eq_or_diff(\@at, \@ac, "output");
t/e2e/amoose_basic.t ........ Failed 1/1 subtests
I want to use cover -test
in Travis CI to post coverage to coveralls, but it seems cover -test
always exits with 0 (success) even when the test fails. Should it exit with the actual exit code from make test
etc.?
Hello,
Simple test case:
cat <<EOF > xor.pl
eval '((1 xor 0) and print "MATCH\n")';
EOF
perl -MDevel::Cover xor.pl
Devel::Cover 0.99: Collecting coverage data for branch, condition, pod, statement, subroutine and time.
Selecting packages matching:
Ignoring packages matching:
/Devel/Cover[./]
Ignoring packages in:
/usr/local/lib/perl5/5.12.4/BSDPAN
/usr/local/lib/perl5/site_perl/5.12.4/mach
/usr/local/lib/perl5/site_perl/5.12.4
/usr/local/lib/perl5/5.12.4/mach
/usr/local/lib/perl5/5.12.4
Segmentation fault
Tested on:
Best regards,
Max.
I'm experience issue with Moo and Devel::Cover. Actually any attribute of Moo which is a Moo object failed to be detected by cover.
Here an example :
https://github.com/geistteufel/Devel-Cover-Failure-Moo-Minimal-Test
The test is simple, I have a simple module TestCover. This module contain a test_branch method and an attribute "sto" which is a Sto Moo object.
Sto contain "yes" and "no" attribute which return "yes" and "no". I have 2 methods "say_yes" and "say_no" which just call the attribute.
Well, my test just call test_branch, and because of the test I have write, the "croak" method in "test_branch" should be pass. So we should see the false result in cover.
We got this :
31 0 T(Red) F(Red) unless $self->sto->yes eq 'YES' and $self->sto->no eq 'NO'
So I can't have attribute which is a Moo object, otherwize cover failed.
For the purpose of working on Devel::CoverX::Archive (https://github.com/jkeenan/Devel--CoverX--Archive), I need to be able to:
App::ArchiveDevelCover avoided these problems by scraping the HTML output of 'cover'. It would be better to get this information directly from the Devel::Cover DB, as that would eliminate a dependency on a particular output format.
In my first attempt to verify the existence of a Devel::Cover DB, I checked for the existence of a 'cover.NN' file, a 'digests' file, and 'runs' and 'structure' directories underneath the cover_db/ directory. This is unsatisfactory as well, as it depends on particular implementation details of Devel::Cover which are subject to change in the future.
It would be better to have a function -- probably a Devel::Cover::DB method call -- that would give a yes or no answer as to whether a valid Devel::Cover DB exists in a given directory.
One complication: I have come to realize that the structure underneath cover_db/ changes from the point where you have run tests with coverage requested to the point after you have run 'cover'. So perhaps we need to identify two states rather than one:
a. You have run tests with coverage requested.
b. You have both run tests with coverage requested and called 'cover' to generate output data.
From the point of view on Devel::CoverX::Archive, the "runtime" we need is the time at which 'cover' was most recently run, i.e., it should designate the time of (b) rather than (a). That's because I envision the user running a command-line tool called 'archive_coverage' after running 'cover'.
Thank you very much.
Jim Keenan
There's an issue with passing multiple RE to +select for example.
If I invoke like this:
perl -MDevel::Cover="+select,/my/path/A.pm,/my/other/path/B.pm" test.pl
everything works as expected.
But if I put a space between list members:
perl -MDevel::Cover="+select,/my/path/A.pm, /my/other/path/B.pm" test.pl
the second pass though mentioned in "Selecting packages matching: ..." but actually will be omitted from a coverage.
I had occasion to blow away my Perl 5.18.0 installation and install 5.18.1 today on my Linode. Thereafter I went to reinstall the holy trinity: Devel::Cover, DateTime and Moose. The latter two tested and installed successfully. However, Devel::Cover 1.06 had massive test failures -- so large that I won't paste them all here but will send a gzipped file to pjcj. But to give a flavor:
``
cpan[3]> test Devel::Cover
Running test for module 'Devel::Cover'
Running make for P/PJ/PJCJ/Devel-Cover-1.06.tar.gz
Has already been unwrapped into directory /home/jimk/.cpan/build/Devel-Cover-1.06-mGw0tZ
Has already been made
Running make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t//.t
t/e2e/aaccessor.t ........... 1/1 # Test 1 got:
+----+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+
| Elt|Got |Expected |
+----+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+
| 0|'Reading database from \n' |'Reading database from \n' |
| 1|'\n' |'\n' |
| 2|'\n' |'\n' |
t/e2e/aaccessor.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aalias.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aalias1.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/abigint.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/abranch_return_sub.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/abug_and.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/acond_and.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/acond_branch.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/acond_chained.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/acond_or.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/acond_xor.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/acop.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/adefault_param.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/adeparse.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/adestroy.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/adynamic_subs.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aeval1.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aeval2.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aeval3.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aeval_nested.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aexec.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aexec_die.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/afork.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aif.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/ainc_sub.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/amodule1.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/amodule2.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/amodule_ignore.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/amodule_import.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/amodule_relative.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/amoose_basic.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/amoose_cond.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/amoose_constraint.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aoverload_bool.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aoverloaded.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/apadrange.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aredefine_sub.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/arequire.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/askip.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/asort.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/aspecial_blocks.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/astatement.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/at0.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/at1.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/at2.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/ataint.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/atrivial.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/auncoverable.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/axor_constant_fold.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/change.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/eval_sub.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/eval_use.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
t/e2e/md5.t (Wstat: 0 Tests: 1 Failed: 1)
Failed test: 1
Files=64, Tests=78, 28 wallclock secs ( 0.16 usr 0.07 sys + 24.07 cusr 2.07 csys = 26.37 CPU)
Result: FAIL
Failed 53/64 test programs. 53/78 subtests failed.
make: *** [test_dynamic] Error 255
PJCJ/Devel-Cover-1.06.tar.gz
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports PJCJ/Devel-Cover-1.06.tar.gz
Failed during this command:
PJCJ/Devel-Cover-1.06.tar.gz : make_test NO
I realize you have the following disclaimer in the 'make' output:
Devel::Cover 1.06 has not been tested with perl 5.018001.
Testing will take place against expected output from perl 5.018000.
You may well find failing tests.
``
... but still!
Thank you very much.
Jim Keenan
``
It would be nice to have links from subroutine/branch etc coverage reports to lead back to the main file:
for example from
http://www.cpancover.com/cpancover/AnyEvent-HTTP-2.14/blib-lib-AnyEvent-HTTP-pm--subroutine.html
add a link from the number 449 to point to
http://www.cpancover.com/cpancover/AnyEvent-HTTP-2.14/blib-lib-AnyEvent-HTTP-pm.html#449
or maybe to 448 where the sub starts.
See https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-Cover or, if you are logged in to RT, https://rt.cpan.org/Dist/Display.html?Name=Devel-Cover
# Test 1 got:
+----+--------------------------------------------------------------------+--------------------------------------------------------------------+
| Elt|Got |Expected |
+----+--------------------------------------------------------------------+--------------------------------------------------------------------+
| 54|'\n' |'\n' |
| 55|'line err % true false branch\n' |'line err % true false branch\n' |
| 56|'- --- ------ ------ ------ ------\n' |'- --- ------ ------ ------ ------\n' |
* 57|'17 100 1 1 if (not defined $n or $n < 0)\n' |'17 100 2 1 if (not defined $n or $n < 0)\n' *
| 58|'\n' |'\n' |
| 59|'\n' |'\n' |
| 60|'Conditions\n' |'Conditions\n' |
+----+--------------------------------------------------------------------+--------------------------------------------------------------------+
(/Users/ether/.cpanm/work/1387481624.65857/Devel-Cover-1.08/blib/lib/Devel/Cover/Test.pm at line 342)
# Expected: No differences (output)
# /Users/ether/.cpanm/work/1387481624.65857/Devel-Cover-1.08/blib/lib/Devel/Cover/Test.pm line 342 is: $self->{no_coverage} ? Test::ok 1 : eq_or_diff(\@at, \@ac, "output");
t/e2e/abranch_return_sub.t ..
Failed 1/1 subtests
On this CPAN distribution,
https://metacpan.org/module/Image::PNG
I tried Devel::Cover and it hung up:
File 'const-c.inc' Lines executed:0.00% of 2 No branches No calls const-c.inc:creating 'const-c.inc.gcov'
Here is what "top" looks like:
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND 29379 ben 1 118 0 4180K 1956K RUN 1 0:39 97.75% gcov
My test suite is so bad that some modules in my project aren't just badly covered, they're not touched at all. And so they don't show up in reports from Devel::Cover. I'd like to have them show up.
Something like this would be nice:
$ cover -select_dir lib
to force it to report on every .pm file under the lib/ directory.
There doesn't seem to be any documentation of what goes after the -coverage option to cover.
Experimenting I found that I could write
cover -coverage pod
to get just the pod tests. However, I couldn't see what option was needed to not get the pod tests but just the other tests.
Is there some technical limitation that prevents gcov2perl from converting more than two branches? My naive reaction is, Perl has given/when, D::C must support more than two branches. But I appreciate is might not be that easy.
I thought that it would be possible to merge multiple cover_db over the same set of files and get a report that gives the combined coverage of all of the files, but this doesn't seem to be the case. I think it is because the structure is not merged in, only the runs. So, when I try to run cover with multiple dbs (e.g. cover -outputdir cover_merged cover_db1 cover_db2
, I get warnings like:
Devel::Cover: Warning: can't locate structure for statement in /path/to/file.pm
Devel::Cover: Warning: can't locate structure for subroutine in /path/to/file.pm
etc.
The report shows only the coverage from cover_db1, without the coverage from cover_db2 added in as I would expect.
Am I missing something?
In this module released to CPAN,
the files are generated from templates and there are some #line directives in the output Perl code.
When I run cover -test, I get output
cover: running make test "OPTIMIZE=-O0 -fprofile-arcs -ftest-coverage" "OTHERLDFLAGS=-fprofile-arcs -ftest-coverage" PERL_DL_NONLAZY=1 /home/ben/software/install/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/bad-addresses.t ............. Devel::Cover: Warning: can't open DB.pm.tmpl for MD5 digest: No such file or directory Devel::Cover: Warning: can't open Process.pm.tmpl for MD5 digest: No such file or directory t/bad-addresses.t ............. ok t/Geo-Postcodes-JP-DB.t ....... Devel::Cover: Warning: can't open DB.pm.tmpl for MD5 digest: No such file or directory Devel::Cover: Warning: can't open Process.pm.tmpl for MD5 digest: No such file or directory t/Geo-Postcodes-JP-DB.t ....... ok t/Geo-Postcodes-JP-Process.t .. Devel::Cover: Warning: can't open Process.pm.tmpl for MD5 digest: No such file or directory t/Geo-Postcodes-JP-Process.t .. ok t/Geo-Postcodes-JP-Update.t ... Devel::Cover: Warning: can't open Update.pm.tmpl for MD5 digest: No such file or directory t/Geo-Postcodes-JP-Update.t ... ok t/Geo-Postcodes-JP.t .......... Devel::Cover: Warning: can't open DB.pm.tmpl for MD5 digest: No such file or directory Devel::Cover: Warning: can't open Process.pm.tmpl for MD5 digest: No such file or directory t/Geo-Postcodes-JP.t .......... ok t/multiline.t ................. Devel::Cover: Warning: can't open Process.pm.tmpl for MD5 digest: No such file or directory Devel::Cover: Warning: can't open DB.pm.tmpl for MD5 digest: No such file or directory t/multiline.t ................. ok All tests successful. Files=6, Tests=25, 5 wallclock secs ( 0.04 usr 0.05 sys + 4.09 cusr 0.41 csys = 4.59 CPU) Result: PASS Reading database from /usr/home/ben/projects/Geo-Postcodes-JP/cover_db ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ blib/lib/Geo/Postcodes/JP.pm 52.9 n/a n/a 60.0 100.0 15.8 58.3 ...ib/Geo/Postcodes/JP/DB.pm 100.0 n/a n/a 100.0 n/a 32.5 100.0 ...o/Postcodes/JP/Process.pm 100.0 n/a n/a 100.0 n/a 36.4 100.0 ...eo/Postcodes/JP/Update.pm 100.0 n/a n/a 100.0 n/a 15.2 100.0 Total 78.9 n/a n/a 83.3 100.0 100.0 80.8 ---------------------------- ------ ------ ------ ------ ------ ------ ------ HTML output written to /usr/local/www/data/ljm/coverage.html done.
I understand that the problem arose because it couldn't find the input files, but if the module fails to find the input files, wouldn't it be better to just apply the tests to the output files, rather than giving up?
This is an example script:
use strict;
use warnings;
use Devel::Cover;
eval "eval q[ sub config { {} } ]";
my $works = config() || {}; # will get 50% cond coverage
my $fails = config()->{mail} || {}; # will get 0% cond coverage
exit;
#!/usr/bin/env perl
use strict;
use warnings;
use 5.016;
warn sub {
my ($n) = @_;
return 1 if $n < 2;
return $n * __SUB__->($n - 1);
}->(15);
$ perl test.pl
1307674368000 at test.pl line 10.
$ perl -MDevel::Cover test.pl
Devel::Cover 1.08: Collecting coverage data for branch, condition, pod, statement, subroutine and time.
Selecting packages matching:
Ignoring packages matching:
/Devel/Cover[./]
Ignoring packages in:
Closure prototype called at test.pl line 9.
I see a lot of warnings like
Subroutine main::to_json redefined at (eval 2673)[t/00_required_modules.t:54] line 2.
Prototype mismatch: sub main::to_json (
As well as JSON related test failures when running test coverage on a large project. Tests all pass if Devel::cover isn't used.
Consider t2.pl:
#!/usr/bin/perl
use strict;
use warnings;
{
package Cat;
use overload (
'bool' => 'meh',
);
sub meh { 1 }
}
my $string = "hi";
my $x = bless \$string, "Cat";
my $fn = eval 'require $x';
And then:
mhorsfall@dory:~$ ~/perls/blead-ca58718049/bin/perl -d:cst -MDevel::Cover t2.pl
Devel::Cover 1.08: Collecting coverage data for branch, condition, pod, statement, subroutine and time.
Selecting packages matching:
Ignoring packages matching:
/Devel/Cover[./]
Ignoring packages in:
Deep recursion on subroutine "Cat::meh" at (eval 60)[t2.pl:19] line 1.
Segmentation fault (Address not mapped to object [0x7fff2dab5f0f])
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_Gv_AMupdate+0x14) [0x43fdb4]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_amagic_call+0x19a)[0x4406ba]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_sv_2bool_flags+0x6f)[0x4a670f]
/home/mhorsfall/perls/blead-ca58718049/lib/site_perl/5.19.9/x86_64-linux/auto/Devel/Cover/Cover.so(+0x3ad2)[0x7fc191d42ad2]
/home/mhorsfall/perls/blead-ca58718049/lib/site_perl/5.19.9/x86_64-linux/auto/Devel/Cover/Cover.so(+0x5893)[0x7fc191d44893]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_runops_standard+0x13) [0x49db53]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_amagic_call+0x42 [0x440949]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_sv_2bool_flags+0x6f)[0x4a670f]
/home/mhorsfall/perls/blead-ca58718049/lib/site_perl/5.19.9/x86_64-linux/auto/Devel/Cover/Cover.so(+0x3ad2)[0x7fc191d42ad2]
/home/mhorsfall/perls/blead-ca58718049/lib/site_perl/5.19.9/x86_64-linux/auto/Devel/Cover/Cover.so(+0x5893)[0x7fc191d44893]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_runops_standard+0x13)[0x49db53]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_amagic_call+0x429)[0x440949]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_sv_2bool_flags+0x6f)[0x4a670f]
/home/mhorsfall/perls/blead-ca58718049/lib/site_perl/5.19.9/x86_64-linux/auto/Devel/Cover/Cover.so(+0x3ad2)[0x7fc191d42ad2]
/home/mhorsfall/perls/blead-ca58718049/lib/site_perl/5.19.9/x86_64-linux/auto/Devel/Cover/Cover.so(+0x5893)[0x7fc191d44893]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_runops_standard+0x13)[0x49db53]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_amagic_call+0x429)[0x440949]
/home/mhorsfall/perls/blead-ca58718049/bin/perl(Perl_sv_2bool_flags+0x6f)[0x4a670f]
Segmentation fault (core dumped)
Sprout suggests:
When you call 'require $foo', Devel::Cover copies the value of $foo
and remembers it (MY_CXT.module, which is assigned to via sv_setsv in
store_module).
For each statement (each nextstate op), it calls its
check_if_collecting function that does SvTRUE(MY_CXT.module), among
other things, which triggers overloading in this case, which runs
nextstate ops.
I think if Devel::Cover were to use SvOK(MY_CXT.module) instead of
SvTRUE, and elsewhere sv_setsv(MY_CXT.module,NULL) instead of
sv_setpv(MY_CXT.module,"") (etc.), that would fix it.
I tried this, but it still caused recursion inside of:
char *m = SvPV(MY_CXT.module, mlen);
I'll attach a different approach that appears to work.
This is a continuation of RT 49916. I'll be providing a patch with unit tests later this week to show the problem.
So I've been bugging you with exec and Devel::Cover.
First I found out that right before exec(), END hooks are running Devel::Cover::report(), which is throwing errors (it could have been any error, but the point is that some where deep in report(), a die () gets called ), which means perl exits with that error BEFORE exec() gets a chance to do its magic.
Now for a simple case here (https://gist.github.com/1200059), I've traced it down up to the point where just allowing report() to get called once allows the exec() to get executed. The real solution would have to be in the XS layer, where call_report() gets called:
However, my real problem is that I'm trying to work with Test::mysqld, and I still can't make it work.... still digging there.
Hello.
I assume #69 is about Devel::Cover own testsuite.
And I start getting failures when running my own test suite under Devel::Cover.
my code looks like
my $harness = TAP::Harness->new({
formatter_class => 'TAP::Formatter::Console',
($ENV{MT_COVER}) ? (switches => $ENV{MT_COVER}) : (exec => [$Config{'perlpath'}]),
merge => 1,
color => 1,
jobs => 8,
});
...
die unless $harness->runtests(@first, @others)->get_status eq 'PASS';
and MT_COVER is -MDevel::Cover=-db,/tmp/cover_db
errors are:
Can't read /tmp/cover_db/digests with JSON: garbage after JSON object, at character offset 8223 (before "/MtAws/ParentWorker....") at /usr/local/lib/perl/5.14.2/Devel/Cover/DB/IO/JSON.pm line 43.
BEGIN failed--compilation aborted at /home/prj/mt/src/t/unit/metadata.t line 23.
Devel::Cover: Oops, it looks like something went wrong writing the coverage.
It's possible that more bad things may happen but we'll try to
carry on anyway as if nothing happened. At a minimum you'll
probably find that you are missing coverage. If you're
interested, the problem was:
Can't call method "write" on an undefined value at /usr/local/lib/perl/5.14.2/Devel/Cover.pm line 847.
(in different files)
perl 5.14.2 Ubuntu, Devel::Cover 1.08
I did not see such errors before (for same testsuite), it started after I installed new OS with perl 5.14 and recent Devel::Cover version.
Coverage database directories are created with 0700 permissions. There used to be a comment about "# Nasty hack to keep 5.6.1 happy." Take a look at the permissions in detail and the changes which have taken place.
There are several errors in the 'write_csv()' function within 'bin/cpancover'.
Certain fields in the header row are misspelled.
The second field in each data row appears to be superfluous.
Most importantly, the data rows lack the 3 columns one would expect for each of 'subroutine' and 'total'. So the data rows are a net of 5 columns shorter than the header row.
I will provide a patch.
cpanm Catalyst::Devel Starman
catalyst.pl MyApp
cd MyApp
perl -i -lpe's/sub index/sub stop :Local { exit }; # hard linefeed here
sub index/' lib/MyApp/Controller/Root.pm
starman -Ilib -MDevel::Cover=-select,MyApp myapp.psgi
curl http://localhost:5000
curl http://localhost:5000/stop
^C
cover
---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
lib/MyApp.pm 100.0 n/a n/a 100.0 n/a 20.6 100.0
lib/MyApp/Controller/Root.pm 88.5 n/a n/a 90.9 75.0 72.3 87.8
myapp.psgi 100.0 n/a n/a 100.0 n/a 0.4 100.0
Total 92.5 n/a n/a 95.0 75.0 100.0 92.2
---------------------------- ------ ------ ------ ------ ------ ------ ------
---------------------------- ------ ------ ------ ------ ------ ------ ------ ------
File stmt bran path cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------ ------
Total n/a n/a n/a n/a n/a n/a n/a n/a
---------------------------- ------ ------ ------ ------ ------ ------ ------ ------
Note: the stand-alone server (HTTP::Server::PSGI) works.
perl -MDevel::Cover=-select,MyApp script/myapp_server.pl
Hopefully this is the correct place to submit this issue, apologies in advance if its not!
I'm working on a bunch of old perl code, trying to use Devel::Cover to write to and keep a single 'cover_db' so that I can see overall code coverage of a bunch of semi related scripts. While I've been doing this, I've noticed on several occasions some messages like:
Devel::Cover: Can't open test3.pl for MD5 digest: No such file or directory
These aren't too bad, but in some instances, they've affected text diff tests which is less than ideal (I know, don't use diffs in tests, long story, not changing, I won't start a rant on that here).
To remove these warnings, I started off by hacking them out, but that's obviously not ideal, as in most instances its a very worth while error to know about.
On my larger code base, these errors are most annoying when they come out about files that aren't related to what's being run. For example, you're running a test1.pl, and warnings show up about test3.pl, or modules that aren't used directly or indirectly.
These get shown because when the Structure module reads its cache, it finds a digest to process, but in some circumstances it's got 'test.pl' and that's not in the working folder, so it reports a warning.
The two solutions that came immediately to mind were:
1> don't bother pre-parsing the Structure database, do lazy loading.
2> Instrument the Structure.pm with enough information to find the file it's attempting to load in the event that 'file' doesn't resolve.
(linux example - but i'm sure someone in windows could show the same issue in a slightly different way)
cd $ATA_BASE
rm -rf ${HOME}/cover_db
export PERL5OPT=-MDevel::Cover=-db,${HOME}/cover_db
cat >/tmp/test.pl <<EOF
#!/usr/bin/env perl
print "Hello World!\n";
EOF
chmod +x /tmp/test.pl
cd /tmp
perl test.pl
cd
perl /tmp/test.pl
I use Devel::Cover via PERL5OPT as its the most effective way to be looking at coverage of pre-existing code, and having a single database just makes life easier.
I opted for the path of least resistance in my fix: (based on v.0.98 change to Structure.pm)
19a20
> use Cwd "abs_path";
206a208
>ย ย ย ย $self->{abs_file} = abs_path($file);
285a288
>ย ย ย ย ย ย ย ย $self->{f}{$file}{abs_file} = abs_path($file);
344c347
<ย ย ย ย my $dย ย ย ย ย ย ย = $self->digest($s->{file});
---
>ย ย ย ย my $d = (-f $s->{file} ? $self->digest($s->{file}) : $self->digest($s->{abs_file})) ;
It seems to be much happier once this is done. Obviously pre-existing digest files will still exhibit the same problem, as they don't have the abs_file attribute, the scenario above will not generate the warning with this change to Structure.pm.
There's been several threads online about this kind of issue, and I think there's been some that basically say it's not a problem, but I believe this might lend weight to it being acknowledged and hopefully fixed (either in this way or another like lazy loading which would have the added benefit of performance improvement).
I can't seem to get started with Devel-Cover under mod_perl 2.0.4 and perl 5.10.1. I even switched from win32 to CentOS 6.5 (64-bit) with Devel-Cover in mind :)
So, just following exactly what the docs in Devel::Cover 1.0.8 say, I put 'use Devel::Cover' in the section of my httpd.conf (this functions as my startup script.) When I start httpd, I get some command-line output:
Starting httpd: Devel::Cover 1.08: Collecting coverage data for branch, condition, statement, subroutine and time.
Pod coverage is unavailable. Please install Pod::Coverage from CPAN.
Collecting under mod_perl/2.0.4
Selecting packages matching:
Ignoring packages matching:
/Devel/Cover[./]
Ignoring packages in:
/usr/lib64/perl5
/usr/lib64/perl5/vendor_perl
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/share/perl5
/usr/share/perl5/vendor_perl
Devel::Cover: Writing coverage database to /pathtomyapp/config/cover_db/runs/1390485929.5668.48243
File stmt bran cond sub time total
...ite/lib/MyModule/ErrorLogging.pm 71.6 0.0 0.0 88.9 100.0 66.7
Total 71.6 0.0 0.0 88.9 100.0 66.7
I then make use of my app via web browser, shut down the web server, and run cover (after chmodding its output directory so I can write to it.) Even though the cover db file (as I can see if I cat it) has references to my ErrorLogging.pm module and to httpd.conf, the html output doesn't even include that, instead listing no files whatsoever.
If we could answer these two questions I think it'd be helpful to include them in the documentation. To me it is not clear what format to use to pass options when using mod_perl (especially when mod_perl leaves an empty %ENV) and whether to select all files I should be passing that info to Devel::Cover or to 'cover' on the command line or both.
For example, if I put
$ENV{DEVEL_COVER_OPTIONS} = '-dir,/home/srv/cover/,-db,/home/srv/cover/cover_db';
...just before 'use Devel::Cover', it doesn't change where it stores the cover db, like I would expect it to.
Using Devel::Cover version 0.89, I get 100% statement coverage but only 75% branch coverage of the following code. How can I get Devel::Cover to ignore the last else
in its branch coverage calculation?
use strict ;
use warnings ;
sub mysub
{
my ($x) = @_ ;
if ($x > 0)
{
print "x is positive\n" ;
}
elsif ($x < 0)
{
print "x is negative\n" ;
}
else
{
# uncoverable statement
die "this should never happen" ;
}
}
mysub(-1) ;
mysub(2) ;
Running cover -test for Moo on windows results in this:
https://gist.github.com/0d575c5a6f5f7a362795
The errors at the end repeat endlessly. Haven't researched yet why this happens, but i thought it'd be a good idea to already note this.
I have a test where a raw Data::Dumper output is expected, but Devel::Cover uses Data::Dumper, and sets global options, which changes the output!
https://github.com/pjcj/Devel--Cover/blob/master/lib/Devel/Cover.pm#L31
Please remove this! :) (and please release a new release ! ;)
In Deve::Cover::DB::Structure::write(), we have the following code:
279 for my $file (sort keys %{$self->{f}})
280 {
281 $self->{f}{$file}{file} = $file;
282 my $digest = $self->{f}{$file}{digest};
283 $digest = $1 if $digest =~ /(.*)/; # ie tainting.
While using Devel::Cover, from time to time I have received this warning:
Use of uninitialized value $digest in pattern match (m//) at /usr/local/lib/perl5/site_perl/5.16.0/darwin-2level/Devel/Cover/DB/Structure.pm line 283.
To avoid this warning, line 282 should be changed to:
my $digest = $self->{f}{$file}{digest} || '';
Thank you very much.
Jim Keenan
When I run "cover -test" on one of my modules, it seems to completely ignore the .cc file. It shows the .pm, .h, .xs & even the system headers (even if I +ignore /usr/include/) , but it never even creates the .gcov file for the .cc
The module I'm trying to check is @ http://search.cpan.org/~sanbeg/Directory-Iterator-XS-1.001000/
I have a project with a number of different modules, and I'd like to get a single coverage report for all of them.
If I specify -db=/some/common/path
for all of them, I get a lot of warnings while executing the tests:
Devel::Cover: Can't open an/already/tested/module for MD5 digest: no such file or directory
Obviously. That relative path was valid on the previous module, not in the current one. It doesn't matter if I invoke prove
with absolute paths. The module under test is always referenced as a relative path, and thus it doesn't merge the databases. When running cover
to get the reports, I only get reports for the last module, if at all.
Thanks.
Running Devel::Cover on a module which contains a line such as
eval 1 unless defined &X;
fails with tainting turned on.
When I run "prove" with Devel::Cover on the demo test script below, I get these warnings:
Filehandle STDOUT reopened as $fh only for input at /Library/Perl/5.12/darwin-thread-multi-2level/Devel/Cover/DB/IO/JSON.pm line 39.
Filehandle STDOUT reopened as $fh only for input at /Library/Perl/5.12/darwin-thread-multi-2level/Devel/Cover/DB/Structure.pm line 218.
I know they are just warnings. But I'm wondering if they indicate a problem in Devel::Cover::DB. Would it be a mistake to put "no warnings 'io';" before the open commands on the Devel::Cover::DB module lines indicated above? Details follow.
Demo test script:
#!/usr/bin/perl
use Pod::Perldoc;
use Test::More tests => 1;
$ARGV[0] = 'perlrun';
ok(!Pod::Perldoc->run());
Environment details:
$ perl -v | grep ^This
This is perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread-multi-2level
$ perl -MDevel::Cover -e 'print $Devel::Cover::VERSION'
1.08
$ prove --version
Name "main::running_under_some_shell" used only once: possible typo at /usr/bin/prove5.12 line 3.
TAP::Harness v3.28 and Perl v5.12.4
$ uname -mrv
12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
Full output of "prove" invocation:
$ HARNESS_PERL_SWITCHES=-MDevel::Cover prove test.t
Name "main::running_under_some_shell" used only once: possible typo at /usr/bin/prove5.12 line 3.
test.t .. 1/1 Filehandle STDOUT reopened as $fh only for input at /Library/Perl/5.12/darwin-thread-multi-2level/Devel/Cover/DB/IO/JSON.pm line 39.
Filehandle STDOUT reopened as $fh only for input at /Library/Perl/5.12/darwin-thread-multi-2level/Devel/Cover/DB/Structure.pm line 218.
test.t .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.07 usr 0.00 sys + 0.47 cusr 0.06 csys = 0.60 CPU)
Result: PASS
Test failed on Perl 5.18.1.
It seems Devel::Cover fail to make cover_db.
After make test, cover_db directories are almost emplty.
$ ls t/e2e/cover_db_*
t/e2e/cover_db_accessor:
t/e2e/cover_db_alias:
t/e2e/cover_db_alias1:
t/e2e/cover_db_bigint:
t/e2e/cover_db_branch_return_sub:
t/e2e/cover_db_bug_and:
t/e2e/cover_db_change:
t/e2e/cover_db_cond_and:
t/e2e/cover_db_cond_branch:
t/e2e/cover_db_cond_chained:
---snip---
In other hand, on Perl 5.18.0.
$ ls t/e2e/cover_db_*
t/e2e/cover_db_accessor:
cover.13 digests runs structure
t/e2e/cover_db_alias:
cover.13 digests runs structure
t/e2e/cover_db_alias1:
cover.13 digests runs structure
t/e2e/cover_db_bigint:
cover.13 digests runs structure
t/e2e/cover_db_branch_return_sub:
cover.13 digests runs structure
t/e2e/cover_db_bug_and:
cover.13 digests runs structure
t/e2e/cover_db_change:
cover.13 digests runs structure
t/e2e/cover_db_cond_and:
cover.13 digests runs structure
t/e2e/cover_db_cond_branch:
cover.13 digests runs structure
t/e2e/cover_db_cond_chained:
cover.13 digests runs structure
t/e2e/cover_db_cond_or:
cover.13 digests runs structure
---snip---
PERL_DL_NONLAZY=1 /Users/watase_yusuke/.plenv/versions/5.18.1/bin/perl5.18.1 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*/*.t
# Test 4 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #4)
# Expected: "- ------ ------ ------ ------ ------\n"
# /Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm line 326 is: $self->{no_coverage} ? Test::ok 1 : Test::ok $t, $c;
# Test 5 got: "File \n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #5)
# Expected: "File stmt bran cond sub total\n"
# Test 6 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #6)
# Expected: "- ------ ------ ------ ------ ------\n"
# Test 7 got: "Total \n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #7)
# Expected: "tests/Accessor_maker.pm 100.0 n/a n/a 100.0 100.0\n"
# Test 8 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #8)
# Expected: "tests/accessor 100.0 100.0 n/a 100.0 100.0\n"
# Test 9 got: "\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #9)
# Expected: "Total 100.0 100.0 n/a 100.0 100.0\n"
# Test 10 got: "\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #10)
# Expected: "- ------ ------ ------ ------ ------\n"
t/e2e/aaccessor.t ...........
Failed 93/96 subtests
# Test 4 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #4)
# Expected: "- ------ ------ ------ ------ ------\n"
# /Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm line 326 is: $self->{no_coverage} ? Test::ok 1 : Test::ok $t, $c;
# Test 5 got: "File \n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #5)
# Expected: "File stmt bran cond sub total\n"
# Test 6 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #6)
# Expected: "- ------ ------ ------ ------ ------\n"
# Test 7 got: "Total \n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #7)
# Expected: "tests/alias 100.0 100.0 n/a 100.0 100.0\n"
# Test 8 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #8)
# Expected: "Total 100.0 100.0 n/a 100.0 100.0\n"
# Test 9 got: "\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #9)
# Expected: "- ------ ------ ------ ------ ------\n"
t/e2e/aalias.t ..............
Failed 59/63 subtests
# Test 4 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #4)
# Expected: "- ------ ------ ------ ------ ------\n"
# /Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm line 326 is: $self->{no_coverage} ? Test::ok 1 : Test::ok $t, $c;
# Test 5 got: "File \n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #5)
# Expected: "File stmt bran cond sub total\n"
# Test 6 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #6)
# Expected: "- ------ ------ ------ ------ ------\n"
# Test 7 got: "Total \n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #7)
# Expected: "tests/Alias1.pm 100.0 100.0 n/a 100.0 100.0\n"
# Test 8 got: "-\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #8)
# Expected: "tests/alias1 100.0 n/a n/a 100.0 100.0\n"
# Test 9 got: "\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #9)
# Expected: "Total 100.0 100.0 n/a 100.0 100.0\n"
# Test 10 got: "\n" (/Users/watase_yusuke/.cpanm/work/1376453294.17004/Devel-Cover-1.06/blib/lib/Devel/Cover/Test.pm at line 326 fail #10)
# Expected: "- ------ ------ ------ ------ ------\n"
---snip---
t/e2e/aaccessor.t (Wstat: 0 Tests: 10 Failed: 7)
Failed tests: 4-10
Parse errors: Bad plan. You planned 96 tests but ran 10.
t/e2e/aalias.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 63 tests but ran 10.
t/e2e/aalias1.t (Wstat: 0 Tests: 10 Failed: 7)
Failed tests: 4-10
Parse errors: Bad plan. You planned 116 tests but ran 10.
t/e2e/abigint.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 62 tests but ran 10.
t/e2e/abranch_return_sub.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 80 tests but ran 10.
t/e2e/abug_and.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 80 tests but ran 10.
t/e2e/acond_and.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 121 tests but ran 10.
t/e2e/acond_branch.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 564 tests but ran 10.
t/e2e/acond_chained.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 81 tests but ran 10.
t/e2e/acond_or.t (Wstat: 0 Tests: 10 Failed: 7)
Failed tests: 4-10
Parse errors: Bad plan. You planned 291 tests but ran 10.
t/e2e/acond_xor.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 74 tests but ran 10.
t/e2e/acop.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 62 tests but ran 10.
t/e2e/adefault_param.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 68 tests but ran 10.
t/e2e/adeparse.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 65 tests but ran 10.
t/e2e/adestroy.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 55 tests but ran 10.
t/e2e/adynamic_subs.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 128 tests but ran 10.
t/e2e/aeval1.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 115 tests but ran 10.
t/e2e/aeval2.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 82 tests but ran 10.
t/e2e/aeval3.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 81 tests but ran 10.
t/e2e/aeval_nested.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 64 tests but ran 10.
t/e2e/aexec.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 36 tests but ran 10.
t/e2e/aexec_die.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 63 tests but ran 10.
t/e2e/afork.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 64 tests but ran 10.
t/e2e/aif.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 93 tests but ran 10.
t/e2e/ainc_sub.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 77 tests but ran 10.
t/e2e/amodule1.t (Wstat: 0 Tests: 10 Failed: 7)
Failed tests: 4-10
Parse errors: Bad plan. You planned 149 tests but ran 10.
t/e2e/amodule2.t (Wstat: 0 Tests: 10 Failed: 7)
Failed tests: 4-10
Parse errors: Bad plan. You planned 149 tests but ran 10.
t/e2e/amodule_ignore.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 80 tests but ran 10.
t/e2e/amodule_import.t (Wstat: 0 Tests: 10 Failed: 7)
Failed tests: 4-10
Parse errors: Bad plan. You planned 74 tests but ran 10.
t/e2e/amodule_relative.t (Wstat: 0 Tests: 10 Failed: 7)
Failed tests: 4-10
Parse errors: Bad plan. You planned 84 tests but ran 10.
t/e2e/aoverload_bool.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 73 tests but ran 10.
t/e2e/aoverloaded.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 67 tests but ran 10.
t/e2e/apadrange.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 33 tests but ran 10.
t/e2e/aredefine_sub.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 59 tests but ran 10.
t/e2e/arequire.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 55 tests but ran 10.
t/e2e/askip.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 60 tests but ran 10.
t/e2e/asort.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 105 tests but ran 10.
t/e2e/aspecial_blocks.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 74 tests but ran 10.
t/e2e/astatement.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 35 tests but ran 10.
t/e2e/at0.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 100 tests but ran 10.
t/e2e/at1.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 56 tests but ran 10.
t/e2e/at2.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 87 tests but ran 10.
t/e2e/ataint.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 57 tests but ran 10.
t/e2e/atrivial.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 32 tests but ran 10.
t/e2e/auncoverable.t (Wstat: 0 Tests: 10 Failed: 9)
Failed tests: 1-2, 4-10
Parse errors: Bad plan. You planned 74 tests but ran 10.
t/e2e/amodule_relative.t (Wstat: 0 Tests: 10 Failed: 7)
Failed tests: 4-10
Parse errors: Bad plan. You planned 84 tests but ran 10.
t/e2e/aoverload_bool.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 73 tests but ran 10.
t/e2e/aoverloaded.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 67 tests but ran 10.
t/e2e/apadrange.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 33 tests but ran 10.
t/e2e/aredefine_sub.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 59 tests but ran 10.
t/e2e/arequire.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 55 tests but ran 10.
t/e2e/askip.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 60 tests but ran 10.
t/e2e/asort.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 105 tests but ran 10.
t/e2e/aspecial_blocks.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 74 tests but ran 10.
t/e2e/astatement.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 35 tests but ran 10.
t/e2e/at0.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 100 tests but ran 10.
t/e2e/at1.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 56 tests but ran 10.
t/e2e/at2.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 87 tests but ran 10.
t/e2e/ataint.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 57 tests but ran 10.
t/e2e/atrivial.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 32 tests but ran 10.
t/e2e/auncoverable.t (Wstat: 0 Tests: 10 Failed: 9)
Failed tests: 1-2, 4-10
Parse errors: Bad plan. You planned 94 tests but ran 10.
t/e2e/axor_constant_fold.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 32 tests but ran 10.
t/e2e/change.t (Wstat: 0 Tests: 10 Failed: 8)
Failed tests: 2, 4-10
Parse errors: Bad plan. You planned 53 tests but ran 10.
t/e2e/eval_sub.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 75 tests but ran 10.
t/e2e/eval_use.t (Wstat: 0 Tests: 10 Failed: 6)
Failed tests: 4-9
Parse errors: Bad plan. You planned 80 tests but ran 10.
t/e2e/md5.t (Wstat: 0 Tests: 10 Failed: 8)
Failed tests: 2, 4-10
Parse errors: Bad plan. You planned 39 tests but ran 10.
Files=64, Tests=591, 20 wallclock secs ( 0.21 usr 0.11 sys + 15.66 cusr 2.01 csys = 17.99 CPU)
Result: FAIL
Failed 50/64 test programs. 314/591 subtests failed.
$ perl -V
Summary of my perl5 (revision 5 version 18 subversion 1) configuration:
Platform:
osname=darwin, osvers=11.4.2, archname=darwin-2level
uname='darwin mpc-1036 11.4.2 darwin kernel version 11.4.2: thu aug 23 16:25:48 pdt 2012; root:xnu-1699.32.7~1release_x86_64 x86_64 i386 macbookpro10,1 darwin '
config_args='-Dprefix=/$HOME/.plenv/versions/5.18.1 -de'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
optimize='-O3',
cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib
libs=-lgdbm -ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL
USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE
USE_LOCALE_COLLATE USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
Built under darwin
Compiled at Aug 13 2013 12:03:37
@INC:
/$HOME/.plenv/versions/5.18.1/lib/perl5/site_perl/5.18.1/darwin-2level
/$HOME/.plenv/versions/5.18.1/lib/perl5/site_perl/5.18.1
/$HOME/.plenv/versions/5.18.1/lib/perl5/5.18.1/darwin-2level
/$HOME/.plenv/versions/5.18.1/lib/perl5/5.18.1
Has zefram's ticket reached at least ACK status?
Devel::Cover is a good thing for my perl project.
But I found in this case at below it has a problem:
CoverTest.pl
package CoverTest;
use Devel::Cover;
use Me;
use Me2;
use base qw(Me);
__PACKAGE__->register({
code => sub {
print 'hello';
print 'world';
},
}
);
Me2.pm
package Me2;
use Devel::Cover;
use Me;
use base qw(Me);
__PACKAGE__->register({
code => sub {
print 'hello';
print 'world';
},
}
);
Me.pm
package Me;
use Data::Dumper;
sub register {
my $self = shift;
my $code_hash = shift;
my $code = $code_hash->{code};
#~ &$code();
}
1;
I hope the subroutine of Me2.pm should be covered by Devel::Cover, but the output shows this file has no subroutine, please see this:
Devel::Cover 0.99: Collecting coverage data for branch, condition, statement, subroutine and time.
Pod coverage is unavailable. Please install Pod::Coverage from CPAN.
Selecting packages matching:
Ignoring packages matching:
/Devel/Cover[./]
Ignoring packages in:
C:/Perl/site/lib
C:/Perl/lib
Devel::Cover: Writing coverage database to F:/perl_test/cover_test/cover_db/runs/1361949544.10028.10148
----------------------------------- ------ ------ ------ ------ ------ ------
File stmt bran cond sub time total
----------------------------------- ------ ------ ------ ------ ------ ------
Me.pm 100.0 n/a n/a 100.0 4.3 100.0
Me2.pm 100.0 n/a n/a 100.0 1.1 100.0
cover_test.pl 83.3 n/a n/a 75.0 94.7 81.3
Total 91.7 n/a n/a 87.5 100.0 90.6
----------------------------------- ------ ------ ------ ------ ------ ------
Please see the line of Me.2pm, it really should not show 100% sub.
I hope I expain this problem clearly, I also try to find why this happened, but nothing found. So I submit the issue here.
As threatened :-) I am formally requesting the ability to test Mojolicious templates. I have learned more about them and might even be able to get either text of the parsed template or the compiled form (as a sub ref) when needed. I am opening this ticket to be a point of communication along this task.
Assume that there exist the following directories -- "modules" in the language of cpancover:
/Users/jimk/tmp/research/List-Compare-0.37
/Users/jimk/tmp/research/Text-CSV-Hashify-0.05
The following code works, i.e., it runs coverage analysis on a list of modules found underneath a common directory and updates the summary files as needed.
$ perl bin/cpancover -d /Users/jimk/tmp/research/ --outputdir=/Users/jimk/tmp/results/
$ cat /Users/jimk/tmp/results/cpan_cover.csv
release,distribution,link,branch_class,branch_details,branch_pc,condition_class,condition_details,condition_pc,pod_class,pod_details,pod_pc,statement_class,statement_details,statement_pc,subroutine_class,subroutine_detials,sbroutine_pc,total_class,total_details,total_pc
,Text-CSV-Hashify-0.05,1,Text-CSV-Hashify-0.05/coverage.html,c0,25 / 48, 52.08,c0,13 / 23, 56.52,c1,6 / 7, 85.71,c1,76 / 100, 76.00
,List-Compare-0.37,1,List-Compare-0.37/coverage.html,c0,295 / 442, 66.74,c0,111 / 186, 59.68,c0,89 / 163, 54.60,c0,1381 / 1913, 72.19
Now, let's assume that we do not supply a directory for the '-d' option and that we supply a path to one of those modules as a command-line argument:
$ perl bin/cpancover --outputdir=/Users/jimk/tmp/results /Users/jimk/tmp/research/Text-CSV-Hashify-0.05/
In this case, I would assume that coverage analysis would be conducted as needed on /Users/jimk/tmp/research/Text-CSV-Hashify-0.05/ and the results written to the directory which is the value of the '--outputdir' option. However, no specific data about the module is written to the results files.
$ cat /Users/jimk/tmp/results/cpan_cover.csv
release,distribution,link,branch_class,branch_details,branch_pc,condition_class,condition_details,condition_pc,pod_class,pod_details,pod_pc,statement_class,statement_details,statement_pc,subroutine_class,subroutine_detials,sbroutine_pc,total_class,total_details,total_pc
As best I can tell, the cause of this problem is located in these lines from subroutine write_html():
for my $module (sort keys %$results)
{
my $dbdir = "$Options->{directory}/$module/cover_db";
next unless -d $dbdir;
chdir "$Options->{directory}/$module";
print "Adding $module from $dbdir\n";
If no value is specified for '-d' on the command-line, $Options->{directory} defaults to the current working directory. If, however, the module being analyzed is not located underneath that directory, then '-d $dbdir' returns false and no data gets written to the results file.
I got a problem about Devel::Cover.
I got a file which type is "*.12" when i finished perl -MDevel::Cover myProgram.
I can't find the right way to open it or get a html.
Can you tell me how can I to do. thank you .
another problem :
if I don't creat the folder blib/lib and copy the file Storable.pm to it. Devel::Cover
will so me the message --
can't find file "blib\lib\Storable.pm" (blib\lib\Storable.pm(auto split into blib\lib\auto\Storable\reterieve.al)):ignored.
Devel::Cover
has a very long and time consuming test suite, so it seriously would benefit to have parallel tests supported.
However, under parallel testing, Devel::Cover
will randomly fail:
https://gist.github.com/kentfredric/6304258
https://gist.github.com/kentfredric/6304267
https://gist.github.com/kentfredric/6304272
https://gist.github.com/kentfredric/6304282
But basically, you need either:
File::Temp
$path . '/' . $$ . $0
To repeat this problem:
HARNESS_OPTIONS=j100:c cpanm -v --prompt --interactive P/PJ/PJCJ/Devel-Cover-1.07.tar.gz
Starting in version 0.91 there's some code that evals
This test passes normally but fails when HARNESS_PERL_SWITCHES is set
to -MDevel::Cover.
The failure message is the following,
90actionRegistrationTest.t .. 1/? new(): failed: load(): couldn't thaw() data using CGI::Session::Serialize::default:thaw(): couldn't thaw. (in cleanup) Undefined subroutine &Devel::Cover::use_file called at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/Safe.pm line 281.
The versions used are the following,
Perl v5.10.0 built for darwin-thread-multi-2level
Module Version
Devel::Cover 1.00
CGI::Session::Serialize::default 4.43
Safe 2.12
Opcode 1.11
The error is raised in CGI::Session::Serialize::default at the line marked here.
sub thaw {
my ($class, $string) = @_;
# To make -T happy
my ($safe_string) = $string =~ m/^(.*)$/s;
my $rv = Safe->new->reval( $safe_string );
if ( $@ ) {
return $class->set_error("thaw(): couldn't thaw. $@"); <==== here
}
__walk($rv);
return $rv;
}
The reval routine in Safe is copied here with line 281 marked.
sub reval {
my ($obj, $expr, $strict) = @_;
my $root = $obj->{Root};
my $evalsub = lexless_anon_sub($root,$strict, $expr);
return Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub); <=== 281
}
I've been trying to get Devel::Cover working with our large-ish mod_perl application and while it generally works, Apache has a tendency to hang (needing a SIGKILL) of segfault when shutting down after test runs. That means we loose coverage data because Devel::Cover never gets around to writing it to disk. Is there a way to force a write before the Perl interpreter shuts down? I've tried calling last_end() and report() but that doesn't seem to work... Any tips would be appreciated...
This code passes when run normally, but fails with PERL5OPT=-MDevel::Cover:
use strict;
use warnings;
use Test::More tests => 1;
use Attribute::Handlers;
my $attributed;
sub Foo :ATTR(CODE) {
my ($package, $symbol, $referent, $attr, $data) = @_;
$attributed = "$referent";
}
my $sub = sub :Foo(bar) {};
is($attributed, "$sub", "coderef with attributes is not re-cloned");```
Devel::Cover: Error getting @inc: Insecure dependency in `` while running with -T switch at .../Devel/Cover.pm line 116.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.