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

The /usr/pkgs/perl/... in that message is the location in Perl code where the error was found and has nothing to do with code being tested for coverage. That error is complaining that a file expected to be in JSON instead had a Storable header. First, make sure to delete all of the Devel::Cover databases, and try again. If you get the same error again, one of your perl installations does not have JSON; either figure out which and install it there, or set DEVEL_COVER_DB_FORMAT to Storable, delete all of your Devel::Cover databases, and try again.

Storable has been a core module longer than JSON has been in the Perl core, so you might have an older perl installation that has Storable but not JSON. Note that the troublesome installation is not the one producing the error — the error occurs when attempting to read a Storable file as JSON. Something else wrote the file in Storable format.

Replies are listed 'Best First'.
Re^10: Creating coverage big report
by ovedpo15 (Pilgrim) on Oct 07, 2019 at 08:53 UTC
    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?

      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?