0

Description of the problem / feature request:

I am doing some coverage test on bazel-example project, but I failed to get coverage file:

  • build project with coverage related options

git clone https://github.com/bazelbuild/examples/ bazel_examples

cd bazel_examples/cpp-tutorial/stage1

bazel build -s --copt="-coverage" --linkopt="-lgcov" //main:hello-world

The result shows build command runs successfully, but no coverage files(*.gcno) are generated.

Then I run the binary output, but no runtime coverage files(*.gcda) are generated too.

I am using bazel 3.5.0, gcc 9.4.0, Ubuntu 18.04.5.

Does any one know how to resolve this?

1
  • Check man gcc, the option should be named --coverage, with two minus signs. However, bazel coverage should be your go-to tool, it should do the rest for you. Commented May 29, 2022 at 17:03

1 Answer 1

1

Did you try checking the coverage by running the below command.

    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 \
  //...

You can find the coverage file here

bazel-out/_coverage/_coverage_report.dat

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.