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

After changing the format, you will have to delete the old database.

And no, the coverage module is being loaded by setting PERL5OPT so you will need to either filter those from the report (as explained in the manpage for cover) or just ignore them.

Replies are listed 'Best First'.
Re^8: Creating coverage big report
by ovedpo15 (Pilgrim) on Oct 06, 2019 at 11:04 UTC
    Thanks again for the help. I'm still having the following error:
    malformed JSON string, neither array, object, number, string or atom, +at character offset 0 (before "pst0\x{5}\x{6}\x{3}\x{0}...") at /usr/ +pkgs/perl/5.14.1/lib64/module/Devel/Cover/DB/IO/JSON.pm line 33
    So I'm trying to use the ignore option:
    setenv DEVEL_COVER_OPTIONS '+ignore,/usr/pkgs/perl/,tests/' setenv DEVEL_COVER_DB_FORMAT JSON
    Using this flag, I'm trying to ignore all paths /usr/pkgs/perl/* but the error is still remains. How can I remove this error?

      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.

        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?