Devel :: Cover data merge cover for Perl scripts and modules

I'm having problems combining data to cover Perl scripts and modules. Running Devel :: Cover individually works fine, but when I try to combine the data, I lose statistics only for the Perl script, and not for the module ..

Let me explain ..

I have a directory tree that looks like this.

Code_Coverage_Test
 |
 |---->lib
 |
 |---->t
 |

Inside the Code_Coverage_Test root directory, I have a Build.pl file that builds tests for a module and a script that run two other scripts that automate some commands for me ..

./Build.pl

#!/usr/bin/perl -w

use strict;
use Module::Build;

my $buildTests = Module::Build->new(
        module_name             => 'testPMCoverage',
        license                 => 'perl',
        dist_abstract           => 'Perl .pm Test Code Coverage',
        dist_author             => 'me@myEmail.com',
        build_requires  => {
           'Test::More' => '0.10',
        },

);

$buildTests->create_build_script();

./startTests.sh

#!/bin/sh

cd t
./doPMtest.sh
./doPLtest.sh

cd ../

perl Build testcover

Inside lib dir, I have files that I am trying to run to cover the code.

Library / testPLCoverage.pl

#!/usr/bin/perl -w

use strict;

print "Ok!";

Library / testPMCoverage.pm

use strict;
use warnings;
package testPMCoverage;

sub hello {
    return "Hello";
}

sub bye {
    return "Bye";
}


1;

t dir .t 2 , .. startTests.sh

/testPMCoverage.t

#!/usr/bin/perl -w


use strict;
use Test::More;

require_ok( 'testPMCoverage' );

my $test = testPMCoverage::hello();
is($test, "Hello", "hello() test");

done_testing();

/doPLtest.sh

#!/bin/sh

#Test 1
cd ../
cd lib
perl -MDevel::Cover=-db,../cover_db testPLCoverage.pl

/doPMtest.sh

#!/bin/bash

cd ../
perl Build.pl
perl Build test

, , , doPLtests.sh script , .

---------------------------- ------ ------ ------ ------ ------ ------ ------
File                           STMT   Bran   Cond    Sub    pod   Time  total
---------------------------- ------ ------ ------ ------ ------ ------ ------
testPLCoverage.pl             100.0    n/a    n/a  100.0    n/a  100.0  100.0
Total                         100.0    n/a    n/a  100.0    n/a  100.0  100.0
---------------------------- ------ ------ ------ ------ ------ ------ ------

, doPMtest.sh script , startTests.sh script testcover, , ...

Reading database path/Code_Coverage_Tests/cover_db
Devel::Cover: Warning: can't open testPLCoverage.pl for MD5 digest: No such file or directory
Devel::Cover: Warning: can't locate structure for statement in testPLCoverage.pl
Devel::Cover: Warning: can't locate structure for subroutine in testPLCoverage.pl
Devel::Cover: Warning: can't locate structure for time in testPLCoverage.pl

.. -

---------------------------- ------ ------ ------ ------ ------ ------ ------
File                           STMT   Bran   Cond    Sub    pod   Time  total
---------------------------- ------ ------ ------ ------ ------ ------ ------
blib/lib/testPMCoverage.pm     87.5    n/a    n/a   75.0    0.0  100.0   71.4
testPLCoverage.pl               n/a    n/a    n/a    n/a    n/a    n/a    n/a
Total                          87.5    n/a    n/a   75.0    0.0  100.0   71.4
---------------------------- ------ ------ ------ ------ ------ ------ ------

Perl Perl script, ?

+4
1

Perl , . , . perl .

Devel:: Cover , , perl. Devel:: Cover, testPLCoverage.pl blib/lib/testPMCoverage.pm.

, , , , , Devel:: Cover .

, , .

, t/doPLtest.sh lib. - :

perl -Mblib -MDevel:: Cover = -db,../cover_db lib/testPLCoverage.pl

( , lib?)

, , Devel:: Cover .

+3

Source: https://habr.com/ru/post/1533965/


All Articles