Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Devel::Cover for myfile.pl with different command-line input arguments

by Mr. Muskrat (Canon)
on Aug 22, 2016 at 22:03 UTC ( #1170196=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1170196]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (1)
As of 2017-12-16 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (449 votes). Check out past polls.

    Notices?