Using Bazel to generate coverage report

匿名 (未验证) 提交于 2019-12-03 00:59:01

问题:

I am using genhtml command to generate html coverage report from Bazel generated coverage.dat file:

genhtml bazel-testlogs/path/to/TestTarget/coverage.dat --output-directory coverage 

The problem with using genhtml is that I have to provide the paths to the coverage.dat files (which are generated in bazel-testlogs/..) Is it possible to fetch those coverage.dat files as an output from another rule?

I would like to not have to call genthml command directly, but have Bazel handle everything.

回答1:

I was not able to find a way to get coverage.dat files as an output of a bazel rule. However, I was able to wrap all the locations of all the .dat files as srcs to a filegroup in WORKSPACE directory:

filegroup(     name = "coverage_files",     srcs = glob(["bazel-out/**/coverage.dat"]), ) 

and then use that filegroup in a custom .bzl rule that wraps the genthml command to generate html coverage report. So now I only have to call

bazel coverage //path/... --instrumentation_filter=/path[/:] 

command to generate the coverage.dat files, generate html report and zip it up. Thus, bazel handles everything.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!