Missing documentation for C++ branch coverage

Description

I am testing Codecov with a C++ project, and looking for help configuring branch coverage support.

The default codecov.yml includes this config:

parsers:
  gcov:
    branch_detection:
      conditional: yes
      loop: yes
      method: no
      macro: no

However I can’t find the documentation for this section of the config. I’m building gcov coverage but don’t see to be getting branch coverage.

Repository

Hi @alexjurkiewicz

[s]Looking at the reference, It looks like I didn’t either: codecov.yml Reference

Edit: I’ve updated the docs slightly, it’s pretty confusing logic internally, so not sure how much better I can make them. Still thinking.

Generating branch coverage is going to be a function of the gcov reporter though, that part of the config tells us how to read it.

While I dig into those settings, can you share a commit SHA so I can pull the raw report and see if it contains branch coverage at the time of upload?

1 Like

Thanks for the update. I can’t see your updated docs, are they live yet?

I’ve managed to solved my issue. The coverage I was generating didn’t include branch coverage. I just assumed it did.

Here’s a report with branch coverage enabled:

The secret is to explicitly generate branch coverage. Here’s the magic option for lcov:

lcov --capture --rc lcov_branch_coverage=1 [...]

(If you use gcov, it should be possible to use the -b option to generate branch data – but I didn’t test if Codecov parses branch data in gcov format.)

So some feedback:

  1. None of the C++ examples show branch coverage enabled, eg gcov with -b. That would be a good hint for future spelunkers.
  2. It’s not clear in Codecov’s UI what sort of data was contained in your uploaded report. If Codecov had some UI which said “we accepted your report, which had line coverage YES branch coverage NO”.

I still have one issue, which is that Codecov doesn’t highlight which branches were taken (or not) in the UI. The line is marked as “partially covered” and it’s left to the reader to determine which branches need coverage. It’s possible to derive this information from gcov/lcov, for example gcovr tool can do it locally (see the second screenshot in this section of its docs). That’s my feature request :blush:

The docs didn’t change much, it’s the codecov.yml Reference section.

This is great feedback, and I’ve shared it with our product team. I’m glad you got it sorted!