linux-test-project / lcov

LCOV
GNU General Public License v2.0
867 stars 235 forks source link

lcov version 2.0-1 does not report branch coverage #235

Closed pavelsaman closed 10 months ago

pavelsaman commented 10 months ago

I have an example lcov file:

lcov.tar.gz

Then I try to show coverages including the branch coverage:

$ lcov --version
lcov: LCOV version 2.0-1
pavel@home: ~/testing/total-coverage $ lcov --list lcov.info --rc branch_coverage=1
            |Lines       |Functions  |Branches    
Filename    |Rate     Num|Rate    Num|Rate     Num
==================================================
[apps/api/src/]
a.ts        |24.0%    104| 971%    17|    -      0
b.ts        |56.5%     23|1760%     5|    -      0
c.ts        |27.8%     36|1029%     7|    -      0
==================================================
      Total:|29.4%    163|1121%    29|    -      0
$ lcov-1.16/bin/lcov --version
lcov: LCOV version 1.16
pavel@home: ~/testing/total-coverage $ lcov-1.16/bin/lcov --list lcov.info --rc lcov_branch_coverage=1
Reading tracefile lcov.info
            |Lines       |Functions  |Branches    
Filename    |Rate     Num|Rate    Num|Rate     Num
==================================================
[apps/api/src/]
a.ts        |67.5%    154|68.0%    25|59.4%    165
b.ts        |31.9%     72|38.5%    13|28.4%     88
c.ts        |85.7%     42|70.0%    10|59.7%     72
==================================================
      Total:|60.8%    268|60.4%    48|51.1%    325

I also tried using lcov_branch_coverage=1 with version 2 but it only says this option is deprecated and it does not report branch coverage either:

$ lcov --list lcov.info --rc lcov_branch_coverage=1
lcov: WARNING: RC option 'lcov_branch_coverage' is deprecated.  Consider using 'branch_coverage. instead.  (Backward-compatible support will be removed in the future
            |Lines       |Functions  |Branches    
Filename    |Rate     Num|Rate    Num|Rate     Num
==================================================
[apps/api/src/]
a.ts        |24.0%    104| 971%    17|    -      0
b.ts        |56.5%     23|1760%     5|    -      0
c.ts        |27.8%     36|1029%     7|    -      0
==================================================
      Total:|29.4%    163|1121%    29|    -      0

In both /etc/lcovrc and ~/.lcovrc I have:

branch_coverage = 1

Also notice how the line and function coverage differ. But it's the same lcov file, just a different version of lcov. Should the coverage stats be the same? If not, why are they different when the input data is the same? I don't see any differences in output between versions 1.15 and 1.16.

henry2cox commented 10 months ago

The bug is in the 'list' routine. Data itself and the other generated reports (say,HTML) appear to be correct. I will push a fix after some other tests complete.

henry2cox commented 10 months ago

should be fixed in ded2e949a54be2381ec20b3a509db767ba7f3eb3

Is that turns out to work for you - please go ahead and close this issue. Thanks Henry

pavelsaman commented 10 months ago

LGTM, the output is now the same is in version 1.16:

$ bin/lcov --version
lcov: LCOV version 2.0-48-gded2e94
pavel@home: ~/Desktop/lcov $ bin/lcov --rc branch_coverage=1 --list lcov.info 
            |Lines       |Functions  |Branches    
Filename    |Rate     Num|Rate    Num|Rate     Num
==================================================
[apps/api/src/]
a.ts        |67.5%    154|68.0%    25|59.4%    165
b.ts        |31.9%     72|38.5%    13|28.4%     88
c.ts        |85.7%     42|70.0%    10|59.7%     72
==================================================
      Total:|60.8%    268|60.4%    48|51.1%    325

Thank you for fast resolution.