Open perlpunk opened 1 year ago
Is this a limitation of Devel::Cover or a bug?
It's actually a feature :)
But perhaps it's a slightly too aggressive feature. The reason for doing this is because traditionally authors would put their modules in the lib
directory. Then, as part of the build process the modules would get copied to blib
. But for many modules the tests would sometimes use the modules in lib
and sometimes in blib
. So Devel::Cover took the stance that if you have identical files it doesn't matter which you use and the coverage of the files is merged. There's a prefer_lib
option to report against lib
in this case. Otherwise the order is sort of random, as you have discovered.
This behaviour is somewhat built-in. It could be changed, of course, perhaps to only consider files with the same name, or to be turned off, but that would take a little effort and, since you have a simple workaround, perhaps that would be a low priority.
When there are to files with the following content:
and my test looks like this:
then only one of them gets coverage:
Is this a limitation of Devel::Cover or a bug?
Background: Of course it's not a very common thing to have two perl files with the same content under different locations. In our case we were able to simply make the modules distinct. So we have two perl files that are not part of the app we are testing, but rather our app can load modules, and we want to make sure that our test modules under the
t/data/tests
directory are covered as well.It took us a while to find out why only ever one of the two modules would appear in the coverage report, so I thought I'll create this issue to see if it would be possible to fix it.
Reproducer repo: https://github.com/perlpunk/devel-cover-bug Run
make cover