The right way is to always start with Makefile.PL/Build.PL, just as the selected answer suggests. However, sometimes you are not the one who started, so ...
I used a fake make file:
% cat Makefile test: prove -Ilib -rt
Also, the following seems to work (without touching ANY files on the disk):
cover -t -make 'prove -Ilib -rt; exit $?'
This only works because of how Perl system / exec handle the argument with metacharacters in it ( ; in this case) and may break in the future if cover decides to quote it more rigirously. Also, it should not work under windows. I wish there was a -prove option on cover .
This object still provides coverage for * .t, as well as CPAN modules in non-standard locations. This behavior can be fixed using the + select / + ignore options (see the Devel :: Cover man page):
cover -t +select ^lib +ignore ^
So the tl command; dr "magic"
cover -t +select ^lib +ignore ^ -make 'prove -Ilib -rt; exit $?'
EDIT didn't work for me - it prints only a short summary:
PERL5OPT="$PERL5OPT -MDevel::Cover" prove -Ilib -rt cover -t +select ^lib +ignore ^
Note that prove -MSomething that prove -MSomething is used by Something to prove itself and not pass it (unlike -I).
Dallaylaen
source share