A small tool to make anonymous subs visible to Devel::Coverage (and possibly similar Modules). Code is based on pjcj/Devel--Cover#51 (comment)
# delete old coverage data (optional)
cover -delete
# Perl scripts
perl -MDevel::Cover=-ignore,^t/,Deanonymize -MDevel::Deanonymize=<inculde_pattern> your_script.pl
# Perl tests
HARNESS_PERL_SWITCHES="-MDevel::Cover=-ignore,^t/,Deanonymize -MDevel::Deanonymize=<include_pattern" prove t/
# generate report
cover -report html
If your tests suddenly fail for some weird reason, you can set DEANONYMIZE_DEBUG
. If this environment variable is set,
we print out the filename for every modified file and write its contents to <filpath/filename>_mod.pl
Per default, Devel::Cover
creates a folder named cover_db
inside the project root. To visualize the result, we have to
generate a report:
cover -report html
The html report (or any other report type) is then stored under cover_db
as well.
See separate subdirectory examples/runit.sh
- Make sure your script (the one under test) always ends with
__END__
,__DATA__
or1;
, otherwise the regex to modify it fails silently - To debug if your script is "deanonymized" use
warn()
instead ofprint()
print is somewhat unreliable in this early stage - Devel::Cover on cpan