bazel icon indicating copy to clipboard operation
bazel copied to clipboard

bazel coverage generating empty coverage.dat on single workspace

Open g-valentino opened this issue 4 years ago • 5 comments

Description of the bug:

WARNING: There was no coverage found.
stat bazel-out/_coverage/_coverage_report.dat
  File: bazel-out/_coverage/_coverage_report.dat
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

bazel clean ; bazel coverage --combined_report=lcov --instrumentation_filter='' --nocache_test_results src/base:expected_test

Which operating system are you running Bazel on?

PRETTY_NAME="Debian GNU/Linux rodete" NAME="Debian GNU/Linux" VERSION_ID="rodete" VERSION="12 (rodete)" VERSION_CODENAME=rodete ID=debian

What is the output of bazel info release?

release 5.3.2

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?

Nope, seem to be other people running into it, but this project has nothing special,so its surprising that the coverage reports are emtpy.

Any other information, logs, or outputs that you want to share?

Testing an C++20 expected impl, so the target is a header file lib, and test is just running through specializations.

Oct 19, 2022 10:09:14 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Oct 19, 2022 10:09:14 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file bazel-out/k8-fastbuild/testlogs/src/base/expected_test/coverage.dat
Oct 19, 2022 10:09:14 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Oct 19, 2022 10:09:14 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Oct 19, 2022 10:09:14 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Oct 19, 2022 10:09:14 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs
WARNING: There was no coverage found.
Target //src/base:expected_test up-to-date:
  bazel-bin/src/base/expected_test

I tried --nocache_test_results, bazel clean -> then retry nothing seems to generate the report.

bazelrc

# Use clang by default
build --repo_env=CC=clang

# C++20
build --cxxopt='-std=c++20' 

# Warnings
build --cxxopt='-Wall'
build --cxxopt='-Werror'
build --cxxopt='-Wextra'
build --cxxopt='-Wextra-semi'
build --cxxopt='-Wconversion'
build --cxxopt='-Wnewline-eof'
build --cxxopt='-Wstrict-prototypes'
build --cxxopt='-Wold-style-cast'
build --cxxopt='-Wno-unused-parameter'
build --cxxopt='-Wnonportable-system-include-path'
build --cxxopt='-Wwrite-strings'
build --cxxopt='-Wimplicit-fallthrough'

# Configuration
build --cxxopt='-fno-exceptions'
build --cxxopt='-fno-rtti'
build --cxxopt='-fomit-frame-pointer'
build --cxxopt='-funwind-tables'

g-valentino avatar Oct 20 '22 05:10 g-valentino

Dupe of https://github.com/bazelbuild/bazel/issues/16208, https://github.com/bazelbuild/bazel/issues/15254

sgowroji avatar Oct 20 '22 07:10 sgowroji

I'm slightly confused by what you mean 'external' repositories. All the code being tested here is under the projects workspace.

bazel coverage -c dbg --nocache_test_results --combined_report=lcov //src/base:expected_test

I dont see any external repository referenced at all, so think the duplicate tag is not correct. Tested the available tools by instrumenting manually, and generating the report manually, and it worked, so my toolchain is doing its job.

g-valentino avatar Oct 21 '22 03:10 g-valentino

There was a mixup of llvm and gcc, nvm.

slack discussion: https://bazelbuild.slack.com/archives/CA31HN1T3/p1666335963259669

g-valentino avatar Oct 21 '22 14:10 g-valentino

Hi, I meet same problem, is there anyone can help here? I could not see the discussion in slack.

simonhgao avatar Sep 06 '23 08:09 simonhgao

For others encountering this issue: check which compiler is being invoked. I had empty coverage reports when using clang-15. Switching to a gcc toolchain made coverage work for me.

driftregion avatar Jan 11 '25 19:01 driftregion