killy971 / hpc-coveralls

coveralls.io support for haskell code coverage with hpc
http://hackage.haskell.org/package/hpc-coveralls
BSD 3-Clause "New" or "Revised" License
60 stars 20 forks source link

filtering out test code from results #6

Closed nurpax closed 10 years ago

nurpax commented 10 years ago

It'd nice to be able to upload only my library's coverage results without test code results. I'd like to aim for close 100% coverage for my packages but I don't want to spend time on tweaking tests for higher coverage.

Things like uncovered error match cases and unused derived instances are something I'd test for in library code but wouldn't worry about in test code.

HPC itself is pretty poor in this filtering, IMO. A regex --include-only= could be used to specify a module prefix for modules I want in my coverage results. Explicitly listing all modules like in hpc is a PITA.

killy971 commented 10 years ago

I read that normally cabal should exclude test code from the coverage reports, but from my experience it doesn't seem to work (I'll find the link). Still, from my understanding you're using hpc directly to generate the code coverage data? I think that in this case in may be a good idea to add such a flag. It could either be a filter on modules, or a filter on the source files path, or maybe both (one for each). I'm going to see how to implement this in a nice way, once I introduce a proper command line parser (which I'm planning to do soon). Thanks for reporting this!

killy971 commented 10 years ago

I'm thinking of making a change to exclude the files under the test folder from the coverage report first (which I think would be fine for most of the use-cases), maybe release this as v0.1.3, and then implement a more flexible feature with command line arguments to include/exclude based on the source folder or the module name machting some regex.

nurpax commented 10 years ago

This would work for me. Thanks!

killy971 commented 10 years ago

Example to exclude the files under the test/ directory from the coverage report:

hpc-coveralls --exclude-dir=test

Note: for now, only one folder can be excluded (which should cover most of the use cases), but this can be extended later.