• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

killy971/codecov-haskell: codecov.io support for haskell code coverage with hpc

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

killy971/codecov-haskell

开源软件地址(OpenSource Url):

https://github.com/killy971/codecov-haskell

开源编程语言(OpenSource Language):

Haskell 100.0%

开源软件介绍(OpenSource Introduction):

codecov-haskell Build Status Gitter chat BSD3 License Version on Hackage

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

At the moment, Travis CI, Circle CI and Jenkins CI have 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!

Usage

Travis CI

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

language: haskell
ghc: 7.8
script:
  - cabal configure --enable-tests --enable-library-coverage && cabal build && cabal test
after_script:
  - 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:

before_install:
  - cabal install codecov-haskell
script:
  - cabal configure --enable-tests --enable-library-coverage && cabal build
  - run-cabal-test [options] [cabal-test-options]
after_script:
  - 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.
Another way to solve problems related dependencies is to install codecov-haskell in a sandbox, as in the example below:

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

Circle CI

In your test section of your circle.yml add the following:

test:
  pre:
    - cabal install codecov-haskell
    - cabal configure --enable-tests --enable-library-coverage
    - cabal build
  override:
    - cabal test
  post:
    - 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:

test:
  pre:
    - cabal install codecov-haskell
    - cabal configure --enable-tests --enable-library-coverage
    - cabal build
  override:
    - run-cabal-test
  post:
    - codecov-haskell [options] [test-suite-names]

Jenkins CI

In your build script add the following commands:

cabal install codecov-haskell
cabal configure --enable-tests --enable-library-coverage && cabal build && cabal test
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]

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.

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)

Options

The --cabal-name option can be used to specify a custom executable name instead of the default cabal when calling cabal test.
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.20

The codecov-haskell command

This command parses the hpc generated output, converts its to Codecov json format and finally sends it to codecov.io over http.
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.
For example, if your test suite are named test1 and test2, use the command as follows:

codecov-haskell test1 test2

Options

--exclude-dir

The --exclude-dir option allows to exclude source files located under a given directory from the coverage report.
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]

--display-report

This boolean option prints the raw json coverage report to be sent to codecov.io.

--dont-send

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

--print-response

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

Limitations

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).

Contributing

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

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

License

BSD3 (tl;dr)

Notes




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap