On Fri, Jul 06, 2012 at 07:21:21AM -0700, Ovid wrote: > Hi all, > > This is Devel::Cover 0.88 and perl version 5.12.2 > > > I have been searching like mad for the answer and can't figure it out. > > I have been tasked with cleaning up some legacy code which is poorly written, > but has an astonishingly large number of tests. Some of these tests run code > in files like this: > > fcgi/*.fcgi > > I would very much like to include those in my coverage reports. In fact, I'd > love to ensure that I can include *everything* (regardless of extension) in > lib/, fcgi/, and utils/ and *nothing* in any other directories. > > This is one of my many attempts: > > HARNESS_PERL_SWITCHES=-MDevel::Cover=+inc,fcgi,+inc,lib,+inc,util prove -rl t > > > FAIL! > > I've also tried created simple Build.PL or Makefile.PL scripts and keep > getting "No tests defined" when I run things like 'cover -test' or './Build > testcover'.
Ouch. Sorry this is causing problems. This whole interface to choosing files for coverage analysis is perhaps my least favourite part of Devel:Cover, and especially so as it is exposed to users. In fact, it's the primary reason that I haven't jumped to a 1.00 release. Trouble is, I've not really come up with anything better. In answer to your specific query, ideally Devel::Cover should "just work" and do what you want out of the box. "cover -test" should do just what you want it to. You seem to be using Module::Build. Does "./Build test" work? If so, "cover -test" should work too. But we can also do it manually. "cover -delete" first to get rid of any old coverage database hanging around. Then "HARNESS_PERL_SWITCHES=-MDevel::Cover ./Build test". That should run all the tests with coverage enabled. Finally "cover" to generate the report. This should provide coverage for all files except those in perl's default @INC. You can see what Devel::Cover thinks those files are with "perldoc -m Devel::Cover::Inc". You can add to that list by using +inc, as you have in your example. Unfortunately, this is exactly what you don't want to do in this case. If you have somehow got extra directories in Devel::Cover::Inc, you can either manually edit that file, or override it. (The entries there are from @INC when you built Devel::Cover, so might have entries from $PERL5LIB or $PERLLIB, or any other way that might have changed @INC.) To override those entries, you can add +select,RE to collect coverage data for any file matching RE. So "HARNESS_PERL_SWITCHES=-MDevel::Cover=+select,fcgi,+select,util" for example might help. But those will probably catch too many files so you might need to be a little more specific. > I see lots of people asking questions like this in various places on the Web. > A cookbook of examples would be lovely :) Yes, that would be great. I'm not sure I'm the best person to do that, but I'll add it to my TODO list in the event that no one else wants to work on it. I'd be happy to fill in the recipes too if someone else wants to state the problems. There seems to be something a little unusual with your setup, but it doesn't seem to be that unusual. I'd love to know what it is and I'd be happy to help you work out what's going on and come up with a (hopefully generic) solution either here or in private if necessary. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net