golang 项目中的 Bazel 覆盖总是空的

问题描述 投票:0回答:0

我在 macOS M2 上使用

bazel 6.1.1
go version go1.20.2 darwin/amd64
.

我在这里关注 Bazel 覆盖文档:https://bazel.build/configure/coverage.

我在这里使用这个示例存储库来查看 golang 项目的覆盖率报告:https://github.com/HappyCerberus/bazel-golang-minimal-example(博客文章here)。

$ bazel coverage --combined_report=lcov //... --nocache_test_results
WARNING: Running Bazel server needs to be killed, because the startup options are different.
Starting local Bazel server and connecting to it...
INFO: Using default value for --instrumentation_filter: "^//".
INFO: Override the above default with --instrumentation_filter
INFO: Analyzed 3 targets (70 packages loaded, 7951 targets configured).
INFO: Found 2 targets and 1 test target...
INFO: LCOV coverage report is located at /private/var/tmp/_bazel_ilop/485731b719b452a8b57e8b381b13b359/execroot/__main__/bazel-out/_coverage/_coverage_report.dat
 and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: Elapsed time: 5.826s, Critical Path: 0.45s
INFO: 2 processes: 1 internal, 1 darwin-sandbox.
INFO: Build completed successfully, 2 total actions
//:greeter_test                                                          PASSED in 0.1s
  /private/var/tmp/_bazel_ilop/485731b719b452a8b57e8b381b13b359/execroot/__main__/bazel-out/darwin_arm64-fastbuild/testlogs/greeter_test/coverage.dat

Executed 1 out of 1 test: 1 test passes.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.

然后我检查

$(bazel info output_path)/_coverage/_coverage_report.dat
文件,但它总是空的。我做错了什么?

我记得读过 Bazel 关于损坏的基线覆盖文件的限制,这是同一个问题吗?

其他人用不同的设置报告了类似的问题,但同样的问题:

go code-coverage bazel
© www.soinside.com 2019 - 2024. All rights reserved.