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

Add option to include modules non-referenced from tests in the code coverage report #28

Open killy971 opened 10 years ago

killy971 commented 10 years ago

Because of the way hpc works, the coverage data generated only covers the modules which were referenced directly (or transitively?) by the test suites that are run.

Because of this, modules which are not referenced because of lack of test are not considered into the total coverage calculation.

This problem can be solved by introducing a new command line option to specify the source folders. Then, hpc-coveralls will automatically include all the source files from the source tree, and the ones that are not included in the tix/mix data will be considered as not covered.

killy971 commented 10 years ago

Implementing this may not be as simple as it seems, as we have to differentiate the lines that are Haskell code and the lines that are not (which would count in the coverage).

It may be a good idea to check how hpc works and see if something can be reused for this purpose.

Another way is to use a Haskell code parser (which one?). It is then a matter of using the same rules as hpc in order to determine which lines should be considered as "coverable" code.

killy971 commented 10 years ago

Haskell code parser libraries: haskell-src-exts, ghc-parser

ghost commented 6 years ago

You can also publish a tip in readme on how to change test suite/application to trick hpc into including all source. See Databrary for an example.