http://qs1969.pair.com?node_id=1170196


in reply to Devel::Cover for myfile.pl with different command-line input arguments

You could go the route you described and call your script from another script (bash/batch/perl/whatever) that loops through the different parameters but also passes a unique value for the coverage db (based on the arguments, pid, or whatever).

The invocation of Devel::Cover would be slightly different: perl -MDevel::Cover=-db,cover_db-<unique value> my_file.pl -arg1 <arg1_value> -arg2 <arg2_value>.

When all of the calls to your script are done, you'd simply call the cover script passing a wildcard for the coverage database like cover -report=html cover_db-*

Replies are listed 'Best First'.
Re^2: Devel::Cover for myfile.pl with different command-line input arguments
by tito80 (Novice) on Aug 23, 2016 at 00:06 UTC
    Mr. Muskrat, thanks. This definitely helped.

    But I am not very sure on the coverage by Devel::Cover itself. I have legacy code. For e.g., we use a certain Perl custom-developed package which is basically a wrapper around Perl GetOpt. When I pass an option arg1 = "abc" 1st time, and then arg1="xyz" the 2nd time, and I have code like: if ($run eq "abc") {do_this} else {do_that}.

    I expected devel_cover to show me the if-loop covered 1st time. Else-loop uncovered. While vice versa in the 2nd run.

    It did not. I hope I am not missing anything.

      If you test coverage with the first condition and then generate a report it should show the if was covered. If you test coverage with the second condition and then generate a report it should show that the else was covered. If you test coverage of both conditions and then generate the report (as I described in my previous reply) then it should show both the if and the else have been covered.

        Thanks. This helped.