I have a small setup using of a static library and executable doing unit tests. when running bazel coverage
it creates a coverage.dat
file inside the test log folder of the unit test binary. The result is either lcov file or llvm profdata file. The coverage data generator from Bazel seems to be able to distinguish between Clang and GCC, but there seems to be no way the generate a report.
Is there an way to get some statistics from the coverage generator?
I do bazel coverage
this way:
bazel coverage -s \
--instrument_test_targets \
--experimental_cc_coverage \
--combined_report=lcov \
--coverage_report_generator=@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main \
//...
And then I generate an HTML Output this way.
genhtml /home/user1/.cache/bazel/_bazel_user1/e74a825d0eb0c2db4b6f8afd819b274c/execroot/__main__/bazel-out/k8-fastbuild/testlogs/foo_test/coverage.dat --output-directory coverage
bazel version: 3.7.0
bazelisk coverage -s \
--combined_report=lcov \
--experimental_cc_coverage \
--instrumentation_filter="//Src[/:]" \
--local_test_jobs=1 \
--nocache_test_results
//tests:all
then run cmd:
genhtml bazel-out/_coverage/_coverage_report.dat \
--highlight \
--legend \
--output-directory coverage
the result got as below:
......
Overall coverage rate:
lines......: 68.7% (3076 of 4480 lines)
functions..: 61.5% (638 of 1037 functions)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.