Using Bazel to generate coverage report

后端 未结 2 603
温柔的废话
温柔的废话 2020-12-17 02:38

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

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


        
2条回答
  •  春和景丽
    2020-12-17 03:04

    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.

提交回复
热议问题