codecov-haskell: support for Haskell.

[ bsd3, control, library, program ] [ Propose Tags ]

This utility converts and sends Haskell projects hpc code coverage to


Below is the simplest example of .travis.yml configuration to use with Travis CI:

language: haskell
ghc: 7.8
  - cabal configure --enable-tests --enable-library-coverage && cabal build && cabal test
  - cabal install codecov-haskell
  - codecov-haskell [options] [test-suite-names]

Further information can be found in the README.

[Skip to Readme]
Versions [faq] 0.1.0, 0.2.0, 0.3.0,, 0.5.0
Change log
Dependencies aeson, async (>=2.0), base (==4.*), bytestring (>=0.10), cmdargs (>=0.10), containers (>=0.5), curl (>=1.3.8), hpc (>=0.6), process, regex-posix, safe (>=0.3), split [details]
License BSD-3-Clause
Copyright (c) 2014 Guillaume Nargeot
Author Guillaume Nargeot
Maintainer Guillaume Nargeot <>
Category Control
Home page
Bug tracker
Source repo head: git clone
Uploaded by killy971 at Sun Oct 5 06:28:42 UTC 2014
Distributions NixOS:0.5.0
Executables run-cabal-test, codecov-haskell
Downloads 2049 total (131 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]




Maintainer's Corner

For package maintainers and hackage trustees

Readme for codecov-haskell-0.1.0

[back to package description]

codecov-haskell Build Status Gitter chat BSD3 License v0.1.0 on Hackage

codecov-haskell converts and sends Haskell projects hpc code coverage to

At the moment, only Travis CI has been tested, but codecov-haskell should be compatible with other CI services in the near future.

codecov-haskell is still under development and any contributions are welcome!


Travis CI

Below is the simplest example of configuration for your project .travis.yml:

  - cabal configure --enable-tests --enable-library-coverage && cabal build && cabal test
  - cabal install codecov-haskell
  - codecov-haskell [options] [test-suite-names]

If your build fails during the test phase with an error message starting by "hpc:", just replace the cabal test command by run-cabal-test, as in the following example:

  - cabal install codecov-haskell
  - cabal configure --enable-tests --enable-library-coverage && cabal build
  - run-cabal-test [options] [cabal-test-options]
  - codecov-haskell [options] [test-suite-names]

This will prevent the build to fail because of hpc related reasons, which are usually not fatal and should not affect the coverage data. Details are available in the next section.

You may also experience some issues related to your project dependencies, which can be solved by using the --avoid-reinstalls/--force-reinstalls flags.</br> Another way to solve problems related dependencies is to install codecov-haskell in a sandbox, as in the example below:

  - cabal sandbox init && cabal install codecov-haskell
  - .cabal-sandbox/bin/codecov-haskell [options] [test-suite-names]

The run-cabal-test command

Under certain conditions related to the project structure and the version of hpc, cabal test may output an error message and exit with the error code 1, which would result in a build failure.<br/>

To prevent this from happening, codecov-haskell provides the run-cabal-test command which runs cabal test and returns with 0 if the following regular expression never matches any line of the output:

/^Test suite .*: FAIL$/

Below are some of the conditions under which you will likely need to use run-cabal-test:

  • when using GHC 7.6 (hpc 0.6 known issue)
  • when using GHC 7.8 with multiple test suites covering the same module(s)


The --cabal-name option can be used to specify a custom executable name instead of the default cabal when calling cabal test.<br/> Below is an example which can be useful for projects with a Travis configuration based on multi-ghc-travis:

run-cabal-test --cabal-name=cabal-1.18

The codecov-haskell command

This command parses the hpc generated output, converts its to Codecov json format and finally sends it to over http.<br/> Multiple test suites can be specified, in which case the coverage report will be made of the merged coverage data generated by the specified test suites.<br/> For example, if your test suite are named test1 and test2, use the command as follows:

codecov-haskell test1 test2



The --exclude-dir option allows to exclude source files located under a given directory from the coverage report.<br/> You can exclude source files located under the test/ directory by using this option as in the following example:

codecov-haskell --exclude-dir=test [test-suite-names]

You can specify multiple excluded folders by using the following example syntax:

codecov-haskell --exclude-dir=test1 --exclude-dir=test2 [test-suite-names]


This boolean option prevents codecov-haskell from sending the coverage report to This option can be used together with --display-report for testing purpose.<br/> For example, you can try various combinations of the other options and confirm the difference in the resulting report outputs.


This boolean option prints the raw json response received after posting the coverage report to


Total coverage

Because of the way hpc works, coverage data is only generated for modules that are referenced directly or indirectly by the test suites. As a result, the total package coverage computed by Codecov may be higher than what it really is. An option will be added soon in order to allow specifying source folders to include in the total coverage computation.

Expression level coverage

Even though hpc supports expression level coverage, this version of codecov-haskell does not support it yet, but this feature will be implemented soon. Meanwhile, the hpc coverage information is converted into a line based report, in which a line can be: fully covered (green), partially covered (yellow) and not covered (red).


codecov-haskell is still under development and any contributions are welcome!

Please share your comments and suggestions on codecov-haskell Gitter channel!


BSD3 (tl;dr)