Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Running devel::cover recursively on directory with .t files

by david2008 (Scribe)
on Jun 02, 2013 at 09:08 UTC ( #1036563=perlquestion: print w/ replies, xml ) Need Help??
david2008 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have a directory with many subdirectories(more than one level) and want to have one devel::cover run on all these files.
I tried to write the program run_tests.pl

use strict; use warnings; use File::Find; use TAP::Harness; my ($base_dir) = @ARGV; my @tests; find(\&wanted, $base_dir); my $harness = TAP::Harness->new(); $harness->runtests(@tests); sub wanted { if($File::Find::name !~ /\.t$/) { return; } push @tests, "$File::Find::name"; }
but when running
perl -MDevel::Cover run_tests.pl testdir
and afterwards
cover -report
I just get the coverage of the run_tests.pl

---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
t/run_tests.pl 100.0 100.0 n/a 100.0 n/a 100.0 100.0
Total 100.0 100.0 n/a 100.0 n/a 100.0 100.0
---------------------------- ------ ------ ------ ------ ------ ------ ------

What could be the solution for the problem?
Thanks,
David

Comment on Running devel::cover recursively on directory with .t files
Download Code
Re: Running devel::cover recursively on directory with .t files
by Corion (Pope) on Jun 02, 2013 at 09:21 UTC

    I guess you'll need to load Devel::Cover for the tests you run and not for the test harness you're using. Test::Harness says that $ENV{HARNESS_PERL_SWITCHES} is the way to go. So either set the $switches variable that Test::Harness alludes to exporting, or set HARNESS_PERL_SWITCHES=-MDevel::Cover before you run the harness.

      Hi,

      I switched to test:harness and set the environment variable and it worked great.

      Thanks, David

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1036563]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-07-03 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls