ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:

This is following up on earlier thread Coverage report. -- janitors

Hello dear monks!
I have already asked a question about coverage but I feel like I have failed to explain it (and it was a question about something related but different). I'll do my best this time to succeed.

I'm trying to create a coverage report for my project which is written in Perl.
I came across with Devel::Cover that I can use for achieving that report. I read the documentation but I have not found a way to create a report for my special case.
As I said, the project is written in Perl but the tests using a (non-Perl) tool. This tool is basically a bunch of 'tcsh' flows and each one of them runs some Perl script from the project. For example, my project contains the following two scripts: create_dep.pl and find_maps.pl.
One of the flows could run one of those two scripts (or both of them), analysis the result and tell if the test has failed (The idea of continuous integration).

Anyway, I'm trying to understand how can I create a coverage report based on all of those flows/tests.
I have tried to create a wrapper script (which is written in Perl) that executes this tool (which runs all of the flows) but it does not show the coverage of the project's Perl scripts (only of the wrapper).
The wrapper script looks like:
# Galic is the name of the tool which runs the flows my $cmd = "Galic --path ./path/to/project --run --wait"; system($cmd); print("Done");
Another idea I had is to add perl -MDevel::Cover to each execution of one of the project's Perl scripts and then (somehow) merge into one main report.
For example, instead of find_maps.pl --f ./config it will be perl -MDevel::Cover find_maps.pl --f ./config. But this idea is a bit messy and unclean.
First of all, it will take some time to add this prefix to each execution.
Secondly, I'm not quite sure how can I merge those reports into one main big report.
Thirdly, it will take more step(s) for the merge and the idea, in the end, is to make it automatically.

I also came across with Perl's Makefile (cool new concept to know).
I have experience with 'C/C++' makefiles and I feel like they are similar to Perl's (it is also what was written here in one of the previous threads).
I thought it could be possible to create some makefile which the coverage module could use to track all of the Project's script and get the wanted data from them.

My goal is to make create a big main coverage report which is based on all of the small reports from each flow. Is it possible to achieve it?

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

    Set PERL5OPT in the environment to "-MDevel::Cover" before running the tcsh scripts; this will effectively add "-MDevel::Cover" to every call of perl in your test scripts without changing the scripts. Then simply run cover to generate the report. If all of your tests were run in the same directory, Devel::Cover will have already merged everything into one database. Otherwise, you will need to specify all of the coverage databases (to be merged together in-memory) when running the cover tool, but you can also use cover to write out the merged database if you want more than one report from the merged database.

      Thank you for your fast reply.
      I set PERL5OPT to "-MDevel::Cover" and when I open the GUI of the flow runner tool, I get the follow error:
      Can't read /tests/cover_db/digests with Sereal: Sereal: Error: Bad Ser +eal header: Not a valid Sereal document. at offset 1 of input at srl_ +decoder.c line 580 at /usr/pkgs/perl/5.26.1/lib64/site_perl/linux/Dev +el/Cover/DB/IO/Sereal.pm line 34, <$fh> chunk 1. BEGIN failed--compilation aborted at /usr/common/pkgs/register/1.2/bin +/register line 2.
      The second line of register (perl script) is "use strict;" (strange).
      The tool is also contains Perl scripts so they will also get this env.
      Is it possible to pass the exactly scripts I want to get the report to? Maybe to somehow combine the makefile?
      Also, each flow creates each one run-area so the coverage reports will be in different directories. How can I merge them?

        The error is occurring during the import of Devel::Cover which occurs before actually reading the script. Is your flow runner tool making a different cover_db unrelated to Devel::Cover for its own uses? If not, simply delete (rm -r) "/tests/cover_db" and any similar directories that appear in later errors. If so, try setting DEVEL_COVER_OPTIONS to "-db /PATH/TO/COVERAGE/DB" to specify a path that the flow runner will not be using.

        You can merge multiple databases by simply mentioning all of them on the command line for cover. You can use the -write NEWDB option to write the merged database or simply merge the databases in-memory and immediately produce a report.