in reply to Re^9: Creating coverage big report
in thread Creating coverage big report

Thank you for making it more clear.
So basically I need to set DEVEL_COVER_DB_FORMAT to JSON right?
I have done it and wrote a small wrapper which runs the tests without setting PERL5OPT (because it did problems).
The wrapper looks like:
use Devel::Cover qw(+ignore /path/to/project/,tests/ -silent 1 -summar +y 0 +select path/to/tool/to/get/cov); my $cmd = "Galic --path ./path/to/project --run --wait"; system($cmd); print("Done"); exit(0);
So I run:
cover -delete ./wrapper cover
After running the last command (cover) I get the following output:
Reading database from /disk/work/playground/cover_db found cover.13 in /disk/work/playground/cover_db/runs/1570436863.1576. +17667 at /usr/pkgs/perl/5.26.1/lib64/site_perl/Devel/Cover/DB.pm line + 217. Devel::Cover: /disk/work/playground/cover_db/runs/1570436863.1576.1766 +7 is an invalid database + ---------------------------------------------------------------------- +------- File + ---------------------------------------------------------------------- +------- Total + ---------------------------------------------------------------------- +------- HTML output written to /disk/work/playground/cover_db/coverage.html done.
And it creates an empty coverage report.
Then I tried to set DEVEL_COVER_DB_FORMAT to Storable and ran the same commands but I get the same error as before (invalid database and empty report). What could be the reason for this behaviour?

Replies are listed 'Best First'.
Re^11: Creating coverage big report
by jcb (Parson) on Oct 07, 2019 at 22:54 UTC

    At this point, I can only speculate that you have different versions of Devel::Cover installed with the different versions of perl and that those different versions of Devel::Cover have incompatible databases. Fixing this will require running independent tests with each perl version and generating separate reports, which is probably a good idea anyway — coverage under one version of perl does not guarantee that the same code will work correctly under other versions, so it should be accounted separately in any case.

      I tried to create a small test and check where the problem is coming from.
      setenv DEVEL_COVER_DB_FORMAT JSON setenv PERL5OPT "-MDevel::Cover=+ignore,/cov/,/data/,-silent,1,-summar +y,0,+select,project/" ./script.pl unsetenv PERL5OPT /usr/pkgs/perl/5.14.1/bin/cover
      The script looks like:
      #!/usr/pkgs/perl/5.14.1/bin/perl use strict; use warnings; my $cmd = "/project/bin/create_d.pl --data abc system($cmd); print("Done"); exit(0);
      I unset PERL5OPT because if not and I run the cover script it fails with:
      /usr/pkgs/perl/5.14.1/bin/cover shouldn't be run with coverage turned +on.
      Anyway, after unsetting PERL5OPT I run the cover script and get:
      Reading database from /play_ground/cov/cover_db found cover.13 in /play_ground/cov/cover_db/runs/1570662588.11726.0385 +0 at /usr/pkgs/perl/5.14.1/lib64/module/r3/x86_64-linux/Devel/Cover/D +B.pm line 203. Devel::Cover: /play_ground/cov/cover_db/runs/1570662588.11726.03850 is + an invalid database found cover.13 in /play_ground/cov/cover_db/runs/1570662590.11725.0717 +0 at /usr/pkgs/perl/5.14.1/lib64/module/r3/x86_64-linux/Devel/Cover/D +B.pm line 203. Devel::Cover: /play_ground/cov/cover_db/runs/1570662590.11725.07170 is + an invalid database ---------------------------------------------------------------------- +------- File ---------------------------------------------------------------------- +------- Total ---------------------------------------------------------------------- +------- HTML output written to /play_ground/cov/cover_db/coverage.html done.
      I use only one version and that is 5.14.1 - both in coverage, script's shabeng and all of the project's scripts. So I does not seems to be a version issue. Any ideas what it also could be?

        You may have some kind of strange filesystem problem — how are your filenames flipping between /play_ground/cov/... and /apollo_dev/apollo_tests/play_ground/cov/...?

        You have broken something or you are tickling a bug in Devel::Cover. The first suggestion I have is to remove all of the options and set PERL5OPT to exactly "-MDevel::Cover". You may be specifying options such that Devel::Cover ends up not actually including anything and producing an invalid database.

        And until you get this sorted out, remember to delete the coverage database after each change, so we do not have an old coverage database hanging around to give us bad data.