pjcj / Devel--Cover

Code coverage metrics for Perl
http://www.pjcj.net/perl.html
93 stars 89 forks source link

Use of chdir when -dir is set can break many tests #247

Closed autarch closed 4 years ago

autarch commented 4 years ago

Under the hood, Devel::Cover will chdir to the -dir given as an option, if one is given.

This breaks any test that assumes that it is being run from the root of a distro, for example by writing something like use lib 't/lib'. Even worse, you cannot fix this by using FindBin and use lib "$Bin/lib", because FindBin blows up when it cannot resolve $0.

You can work around this by passing a fully qualified path to prove, but that's silly.

I think it'd be best if Devel::Cover did not change the working directory of the code it executes. That's a fairly intrusive thing to do, and I think ideally coverage testing should work just like non-coverage testing.

That said, I have no idea how much work changing this might be.