I have a unique requirement of handling code coverage of my Perl scripts.
I have written a few Perl scripts which in turn uses a few Perl modules. My requirement is to use run these Perl scripts with different options they support and assess the code coverage of both Perl scripts and Perl modules.
So I am using Devel::Cover
, Module::Build
and Test::More
from CPAN. It's all woring fine if I call functions inside Perl modules directly inside test script. But it's not working if I call the scripts directly (In this case I am not getting generated with code coverage of Perl modules and scripts both).
Here is my example test script using Test::More:
use strict;
use warnings;
use Test::More;
BEGIN { plan tests => 1 }
ok(sub {
my @args = ("ex4200fw","-query-fw","-i","192.168.168.1");
#print "# Executing @args \n";
`@args`;
my $rc = $? >> 8;
#print "# Return code: $rc \n";
$rc == 1
}->(),"Query Juniper EX4200 FW, incorrect IP address.\n");
Here ex4200fw
(is in path) is the Perl script written by me which in turn calls dependent module updates.pm
.
- Do we have any tools to suite to this requirement?
- Running Perl scripts and getting code coverage of both scripts and its dependent modules?
- Can we accomplish the same using above CPAN modules?
Any sample script is much useful for me.