2015-10-24 47 views
3

我想使用堆栈生成代码覆盖率报告。我运行命令该 达(通过--test-arguments传递到测试套件省略选项):使用堆栈生成覆盖率报告

$ stack test --coverage 

这执行测试,然后输出以下:

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.

我认为它应该(这创建空报告)。 GHC选项对于我的软件包的所有组件都是相同的 。不需要测试套件来重新构建 库。毕竟,如果Cabal可以生成报告,Stack应该能够在给定相同Cabal配置的情况下执行 还是我误会了?

我已经打开 an issue on堆栈 GitHub回购建议。


过了一会儿,我决定创建好老沙箱和使用产生替代卡瓦尔(我真的需要看到该报告,你懂的)报告 。 它的工作 以前,但现在我得到:

$ 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"] 

什么?我从来没有见过这个,虽然我以前生成了很多报告 。有人在那里只是决定我今天不会得到这个报告,看起来好像是 。


您知道如何使用Stack生成覆盖率报告吗?有没有人 成功了?

+0

您使用的是什么版本的'stack'?最新版本使用'hpc'更好。我使用的是'0.1.6.0',它主要工作。 – Yuras

+2

另请参阅https://github.com/commercialhaskell/stack/issues/1181 – Yuras

+0

@Yuras,'stack --version'→'Version 0.1.6.0,Git revision e22271f5ce9afa2cb5be3bad9cafa392c623f85c(2313 commitits)x86_64'。 – Mark

回答

0

最近上游修改了它。应该为0.1.7.0及更高版本的用户解决。

1

在我的情况下,我仍然得到这个错误。正在运行:

stack clean 
stack test --coverage 

解决了这个问题,据报道为here

相关问题