samedi 24 octobre 2015

Generate coverage report with stack

I want to generate code coverage report using Stack. I run command that amounts to (omitting options passed to test suite via --test-arguments):

$ stack test --coverage

This performs the testing and then outputs the following:

Error: The coverage report for myproject's test-suite "tests" did not consider any code. One possible cause of this is if your test-suite builds the library code (see stack issue #1008). It may also indicate a bug in stack or the hpc program. Please report this issue if you think your coverage report should have meaningful results.

I think it should (this creates empty report). GHC options are identical for all components of my package. There is no need for test suite to rebuild the library. After all, if Cabal can generate the report, Stack should be able to do it given the same Cabal config or am I mistaken?

I've opened an issue on Stack GitHub repo as suggested.


After a while I decided to create good old sandbox and generate the report using Cabal instead (I really need to see the report, you know). It worked previously, but now I get:

$ cabal sandbox init
… <everything OK>
$ cabal update
… <everything OK>
$ cabal install --only-dependencies --enable-tests
… <everything OK>
$ cabal configure --enable-tests --enable-coverage
… <everything OK>
$ cabal build
… <everything OK>
$ cabal test
Running 2 test suites...
Test suite tests: RUNNING...
Test suite tests: PASS
Test suite logged to: dist/test/myproject-0.1.0-tests.log
hpc: can not find HUnit_DDLSMCRs3jyLBDbJPCH01j/Test.HUnit.Lang in ["./.hpc","./dist/hpc/vanilla/mix/myproject-0.1.0","./dist/hpc/vanilla/mix/tests"]

What? I've never seen this, although I generated many reports before. Someone up there just decided that I won't get that report today, it seems.


Do you know how to generate coverage report using Stack? Has anyone succeeded at this?

Aucun commentaire:

Enregistrer un commentaire