Empty code coverage report is generated when test files are referenced as external repository
See original GitHub issueDescription of the bug:
an empty code coverage report is generated when the test files exist in an external respository that has its own WORKSPACE file. following is the structure of my code:
local_repository( name = “sample”, path = “sample”, )
├── BUILD ├── MODULE.bazel ├── sample │ |── BUILD │ │ ├──sample_module │ │ │ ├──test_sample_module.cpp │ │ ├── BUILD │ └── WORKSPACE ├── WORKSPACE
and i am using the following coverage relevant flags: coverage --instrument_test_targets coverage --instrumentation_filter=“[:]” coverage --combined_report=lcov coverage --test_env=VERBOSE_COVERAGE=1 coverage --test_output=all
along with this i have also set the appropriate env variables GCOV_PATH and LLVM_COV
coverage:clang --test_env=COVERAGE_GCOV_PATH=external/toolchain.path/usr/local/bin/llvm-profdata coverage:clang --test_env=LLVM_COV=external/toolchain.path/usr/local/bin/llvm-cov
when i run the following command from the root, i get an empty coverage report:
bazel coverage --config=clang @sample//…
but, I was able to generate a coverage data when I copied the .bazelrc and MODULE.bazel inside the sample repo from the root and ran the following command in the sample repo:
bazel coverage --config=clang //…
the problem that we have is that, we have multiple packages that are external repositories and therefore copying these files everytime into the respective external repositories is not feasible.
I also went through other issues that had similar porblems and most pointed towards the --instrumentation_filter as a potential solution but that also has not worked for me. I have tried instrumenting using the --instrumentation_filter but with no success.
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
steps mentioned in the description of the bug
Which operating system are you running Bazel on?
Ubuntu 18.04.6 LTS
What is the output of bazel info release
?
release 5.1.1
If bazel info release
returns development version
or (@non-git)
, tell us how you built Bazel.
No response
What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD
?
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
Sep 06, 2022 3:04:26 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles INFO: No lcov file found. Sep 06, 2022 3:04:26 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles INFO: No gcov info file found. Sep 06, 2022 3:04:26 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles INFO: No gcov json file found. Sep 06, 2022 3:04:26 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull INFO: No .profdata file found. Sep 06, 2022 3:04:26 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs WARNING: There was no coverage found.
INFO: LCOV coverage report is located at /root/.cache/bazel/_bazel_root/57f55395d11193aa0c12c254de9cef22/execroot/main/bazel-out/_coverage/_coverage_report.dat and execpath is bazel-out/_coverage/_coverage_report.dat INFO: From Coverage report generation: Sep 06, 2022 5:04:27 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles INFO: Found 1 tracefiles. Sep 06, 2022 5:04:27 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially INFO: Parsing file bazel-out/k8-fastbuild/testlogs/external/sample/sample_module/test_sample_module/coverage.dat Sep 06, 2022 5:04:27 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles INFO: No gcov info file found. Sep 06, 2022 5:04:27 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles INFO: No gcov json file found. Sep 06, 2022 5:04:27 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull INFO: No .profdata file found. Sep 06, 2022 5:04:27 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs WARNING: There was no coverage found. Target @sample//sample_module:test_sample_module up-to-date: bazel-bin/external/sample/sample_module/test_sample_module INFO: Elapsed time: 19.998s, Critical Path: 10.16s INFO: 40 processes: 11 internal, 27 processwrapper-sandbox, 2 worker. INFO: Build completed successfully, 40 total actions @sample//sample_module:test_sample_module PASSED in 0.6s
Executed 1 out of 1 test: 1 test passes.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@VinayDodamani seems ot be a duplicate of #16208 ?
We’re rolling https://github.com/bazelbuild/bazel/pull/16637 back since it’s breaking some internal tests 😦 Reopening to keep track of it again.