question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty code coverage report is generated when test files are referenced as external repository

See original GitHub issue

Description 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:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
celkascommented, Sep 8, 2022

@VinayDodamani seems ot be a duplicate of #16208 ?

0reactions
susinmotioncommented, Nov 14, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No coverage data if testing code from external repositories
Using software and tests in the same repository is no problem, coverage data are produced. Splitting the two makes problems. There is "no ......
Read more >
Empty coverage reports - Support - Codecov
We use circle CI and run our python tests inside a docker container. Coverage reports are generated inside this docker container.
Read more >
maven jacoco: not generating code coverage report
You can try "this POM file for a JAR project runs JUnit tests under code coverage and creates a coverage report".
Read more >
Test coverage visualization - GitLab Docs
Collecting the coverage information is done via GitLab CI/CD's artifacts reports feature. You can specify one or more coverage reports to collect, including ......
Read more >
OpenCover generates an empty report - SonarQube
Using dotnet CLI to run the tests. The tests are running and the file is being created but the coverage file is empty....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found