Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup perl to always run code coverage

I'd like to setup my project to always run the scripts through perl's Devel::Cover module. I've tried replacing the perl binary with something like this

#!/bin/sh
exec /usr/local/bin/original-perl -MDevel::Cover $@

with no success. I'd like to avoid modifying the #! for every script on my system (not the end of the world, I'd just like to figure out a more global solution).

Any thoughts on how to turn on Devel::Cover globally?

Edit: Not trying to run this in production, just trying some experiments to figure out how to split up a tightly coupled codebase. Having some automated way to see what source files are needed for a given subsystem (at least as a start) would be helpful

like image 925
skarface Avatar asked Nov 22 '25 05:11

skarface


1 Answers

You can set the environment variable PERL5OPT to always load -MDevel::Cover.

export PERL5OPT="-MDevel::Cover"

See perlrun for an explanation of this.


But as Michael Carman said, why would you do this? It will have significant performance costs and might not be useful if you don't run tests.

like image 122
simbabque Avatar answered Nov 24 '25 21:11

simbabque



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!