Skip to content

Commit

Permalink
Respect excluded/noncode lines for aggregated branch coverage. (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacetown committed Apr 18, 2022
1 parent 08f360d commit bdde94f
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 937 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Next Release

Known bugs:

- Aggregated branch coverage does not properly respect excluded/noncode lines.
(:issue:`600`)
- Decision coverage analysis can resurrect excluded coverage. (:issue:`600`)

Breaking changes:
Expand All @@ -28,6 +26,7 @@ Bug fixes and small improvements:
- Use `` sign instead of `>=` in HTML legend. (:issue:`603`)
- Using :option:`--add-tracefile` will now correctly merge branch coverage. (:issue:`600`)
- Fix package-level function coverage statistics in Cobertura XML reports. (:issue:`605`)
- Respect excluded/noncode lines for aggregated branch coverage. (:issue:`611`)

Documentation:

Expand Down
8 changes: 4 additions & 4 deletions gcovr/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,17 @@ def branch_coverage(self) -> CoverageStat:
stat = CoverageStat.new_empty()

for line in self.lines.values():
# FIXME: should only count if line.is_covered or line.is_uncovered
stat += line.branch_coverage()
if line.is_covered or line.is_uncovered:
stat += line.branch_coverage()

return stat

def decision_coverage(self) -> DecisionCoverageStat:
stat = DecisionCoverageStat.new_empty()

for line in self.lines.values():
# FIXME: should only count if line.is_covered or line.is_uncovered
stat += line.decision_coverage()
if line.is_covered or line.is_uncovered:
stat += line.decision_coverage()

return stat

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-04-04 19:40:09</td>
<td>2022-04-16 19:20:10</td>
</tr>
<tr>
<th scope="row">Legend:</th>
Expand Down Expand Up @@ -59,8 +59,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -99,8 +99,8 @@ <h1>GCC Code Coverage Report</h1>
<td class="CoverValue line-coverage coverage-high">22 / 23</td>
<td class="CoverValue function-coverage coverage-high">100.0%</td>
<td class="CoverValue function-coverage coverage-high">6 / 6</td>
<td class="CoverValue branch-coverage coverage-low">43.8%</td>
<td class="CoverValue branch-coverage coverage-low">7 / 16</td>
<td class="CoverValue branch-coverage coverage-low">50.0%</td>
<td class="CoverValue branch-coverage coverage-low">7 / 14</td>
</tr>

</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-03-25 20:20:41</td>
<td>2022-04-16 19:20:10</td>
</tr>
</table>
</div>
Expand All @@ -54,8 +54,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -609,7 +609,7 @@ <h1>GCC Code Coverage Report</h1>
</main>

<footer>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.0)</a>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.1)</a>
</footer>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'>
<coverage line-rate="0.9565217391304348" function-rate="1.0" branch-rate="0.4375" lines-covered="22" lines-valid="23" functions-covered="6" functions-valid="6" branches-covered="7" branches-valid="16" complexity="0.0" timestamp="1638647466" version="gcovr 5.0"><sources><source>.</source></sources><packages><package name="" line-rate="0.9565217391304348" function-rate="1.0" branch-rate="0.5" complexity="0.0"><classes><class name="main_cpp" filename="main.cpp" line-rate="0.9565217391304348" branch-rate="0.5" complexity="0.0"><methods/><lines><line number="3" hits="3" branch="false"/><line number="4" hits="3" branch="true" condition-coverage="100% (2/2)"><conditions><condition number="0" type="jump" coverage="100%"/></conditions></line><line number="5" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="7" hits="2" branch="false"/><line number="16" hits="1" branch="false"/><line number="17" hits="1" branch="false"/><line number="21" hits="1" branch="false"/><line number="22" hits="1" branch="false"/><line number="24" hits="1" branch="false"/><line number="25" hits="1" branch="false"/><line number="28" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="29" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="30" hits="1" branch="false"/><line number="31" hits="1" branch="false"/><line number="33" hits="1" branch="false"/><line number="36" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="37" hits="1" branch="true" condition-coverage="0% (0/2)"><conditions><condition number="0" type="jump" coverage="0%"/></conditions></line><line number="38" hits="0" branch="false"/><line number="41" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="43" hits="1" branch="false"/><line number="44" hits="2" branch="false"/><line number="47" hits="1" branch="false"/><line number="48" hits="1" branch="false"/></lines></class></classes></package></packages></coverage>
<coverage line-rate="0.9565217391304348" function-rate="1.0" branch-rate="0.5" lines-covered="22" lines-valid="23" functions-covered="6" functions-valid="6" branches-covered="7" branches-valid="14" complexity="0.0" timestamp="1650136809" version="gcovr 5.1"><sources><source>.</source></sources><packages><package name="" line-rate="0.9565217391304348" function-rate="1.0" branch-rate="0.5" complexity="0.0"><classes><class name="main_cpp" filename="main.cpp" line-rate="0.9565217391304348" branch-rate="0.5" complexity="0.0"><methods/><lines><line number="3" hits="3" branch="false"/><line number="4" hits="3" branch="true" condition-coverage="100% (2/2)"><conditions><condition number="0" type="jump" coverage="100%"/></conditions></line><line number="5" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="7" hits="2" branch="false"/><line number="16" hits="1" branch="false"/><line number="17" hits="1" branch="false"/><line number="21" hits="1" branch="false"/><line number="22" hits="1" branch="false"/><line number="24" hits="1" branch="false"/><line number="25" hits="1" branch="false"/><line number="28" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="29" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="30" hits="1" branch="false"/><line number="31" hits="1" branch="false"/><line number="33" hits="1" branch="false"/><line number="36" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="37" hits="1" branch="true" condition-coverage="0% (0/2)"><conditions><condition number="0" type="jump" coverage="0%"/></conditions></line><line number="38" hits="0" branch="false"/><line number="41" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="43" hits="1" branch="false"/><line number="44" hits="2" branch="false"/><line number="47" hits="1" branch="false"/><line number="48" hits="1" branch="false"/></lines></class></classes></package></packages></coverage>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-04-04 19:40:08</td>
<td>2022-04-16 19:20:09</td>
</tr>
<tr>
<th scope="row">Legend:</th>
Expand Down Expand Up @@ -59,8 +59,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -99,8 +99,8 @@ <h1>GCC Code Coverage Report</h1>
<td class="CoverValue line-coverage coverage-high">22 / 23</td>
<td class="CoverValue function-coverage coverage-high">100.0%</td>
<td class="CoverValue function-coverage coverage-high">6 / 6</td>
<td class="CoverValue branch-coverage coverage-low">43.8%</td>
<td class="CoverValue branch-coverage coverage-low">7 / 16</td>
<td class="CoverValue branch-coverage coverage-low">50.0%</td>
<td class="CoverValue branch-coverage coverage-low">7 / 14</td>
</tr>

</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-03-25 20:20:40</td>
<td>2022-04-16 19:20:09</td>
</tr>
</table>
</div>
Expand All @@ -54,8 +54,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -609,7 +609,7 @@ <h1>GCC Code Coverage Report</h1>
</main>

<footer>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.0)</a>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.1)</a>
</footer>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'>
<coverage line-rate="0.9565217391304348" function-rate="1.0" branch-rate="0.4375" lines-covered="22" lines-valid="23" functions-covered="6" functions-valid="6" branches-covered="7" branches-valid="16" complexity="0.0" timestamp="1638647466" version="gcovr 5.0"><sources><source>.</source></sources><packages><package name="" line-rate="0.9565217391304348" function-rate="1.0" branch-rate="0.5" complexity="0.0"><classes><class name="main_cpp" filename="main.cpp" line-rate="0.9565217391304348" branch-rate="0.5" complexity="0.0"><methods/><lines><line number="3" hits="3" branch="false"/><line number="4" hits="3" branch="true" condition-coverage="100% (2/2)"><conditions><condition number="0" type="jump" coverage="100%"/></conditions></line><line number="5" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="7" hits="2" branch="false"/><line number="16" hits="1" branch="false"/><line number="17" hits="1" branch="false"/><line number="21" hits="1" branch="false"/><line number="22" hits="1" branch="false"/><line number="24" hits="1" branch="false"/><line number="25" hits="1" branch="false"/><line number="28" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="29" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="30" hits="1" branch="false"/><line number="31" hits="1" branch="false"/><line number="33" hits="1" branch="false"/><line number="36" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="37" hits="1" branch="true" condition-coverage="0% (0/2)"><conditions><condition number="0" type="jump" coverage="0%"/></conditions></line><line number="38" hits="0" branch="false"/><line number="41" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="43" hits="1" branch="false"/><line number="44" hits="2" branch="false"/><line number="47" hits="1" branch="false"/><line number="48" hits="1" branch="false"/></lines></class></classes></package></packages></coverage>
<coverage line-rate="0.9565217391304348" function-rate="1.0" branch-rate="0.5" lines-covered="22" lines-valid="23" functions-covered="6" functions-valid="6" branches-covered="7" branches-valid="14" complexity="0.0" timestamp="1650136809" version="gcovr 5.1"><sources><source>.</source></sources><packages><package name="" line-rate="0.9565217391304348" function-rate="1.0" branch-rate="0.5" complexity="0.0"><classes><class name="main_cpp" filename="main.cpp" line-rate="0.9565217391304348" branch-rate="0.5" complexity="0.0"><methods/><lines><line number="3" hits="3" branch="false"/><line number="4" hits="3" branch="true" condition-coverage="100% (2/2)"><conditions><condition number="0" type="jump" coverage="100%"/></conditions></line><line number="5" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="7" hits="2" branch="false"/><line number="16" hits="1" branch="false"/><line number="17" hits="1" branch="false"/><line number="21" hits="1" branch="false"/><line number="22" hits="1" branch="false"/><line number="24" hits="1" branch="false"/><line number="25" hits="1" branch="false"/><line number="28" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="29" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="30" hits="1" branch="false"/><line number="31" hits="1" branch="false"/><line number="33" hits="1" branch="false"/><line number="36" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="37" hits="1" branch="true" condition-coverage="0% (0/2)"><conditions><condition number="0" type="jump" coverage="0%"/></conditions></line><line number="38" hits="0" branch="false"/><line number="41" hits="1" branch="true" condition-coverage="50% (1/2)"><conditions><condition number="0" type="jump" coverage="50%"/></conditions></line><line number="43" hits="1" branch="false"/><line number="44" hits="2" branch="false"/><line number="47" hits="1" branch="false"/><line number="48" hits="1" branch="false"/></lines></class></classes></package></packages></coverage>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-03-25 20:26:33</td>
<td>2022-04-16 19:26:21</td>
</tr>
</table>
</div>
Expand All @@ -54,8 +54,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -609,7 +609,7 @@ <h1>GCC Code Coverage Report</h1>
</main>

<footer>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.0)</a>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.1)</a>
</footer>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-03-25 20:26:32</td>
<td>2022-04-16 19:26:21</td>
</tr>
</table>
</div>
Expand All @@ -54,8 +54,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -609,7 +609,7 @@ <h1>GCC Code Coverage Report</h1>
</main>

<footer>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.0)</a>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.1)</a>
</footer>
</body>
</html>
10 changes: 5 additions & 5 deletions gcovr/tests/html-themes/reference/clang-10/coverage.blue.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-04-04 19:40:29</td>
<td>2022-04-16 19:20:22</td>
</tr>
<tr>
<th scope="row">Legend:</th>
Expand Down Expand Up @@ -59,8 +59,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -99,8 +99,8 @@ <h1>GCC Code Coverage Report</h1>
<td class="CoverValue line-coverage coverage-high">21 / 22</td>
<td class="CoverValue function-coverage coverage-high">100.0%</td>
<td class="CoverValue function-coverage coverage-high">6 / 6</td>
<td class="CoverValue branch-coverage coverage-low">43.8%</td>
<td class="CoverValue branch-coverage coverage-low">7 / 16</td>
<td class="CoverValue branch-coverage coverage-low">50.0%</td>
<td class="CoverValue branch-coverage coverage-low">7 / 14</td>
</tr>

</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-03-25 20:21:01</td>
<td>2022-04-16 19:20:22</td>
</tr>
</table>
</div>
Expand All @@ -54,8 +54,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -625,7 +625,7 @@ <h1>GCC Code Coverage Report</h1>
</main>

<footer>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.0)</a>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.1)</a>
</footer>
</body>
</html>
10 changes: 5 additions & 5 deletions gcovr/tests/html-themes/reference/clang-10/coverage.green.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-04-04 19:40:29</td>
<td>2022-04-16 19:20:21</td>
</tr>
<tr>
<th scope="row">Legend:</th>
Expand Down Expand Up @@ -59,8 +59,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -99,8 +99,8 @@ <h1>GCC Code Coverage Report</h1>
<td class="CoverValue line-coverage coverage-high">21 / 22</td>
<td class="CoverValue function-coverage coverage-high">100.0%</td>
<td class="CoverValue function-coverage coverage-high">6 / 6</td>
<td class="CoverValue branch-coverage coverage-low">43.8%</td>
<td class="CoverValue branch-coverage coverage-low">7 / 16</td>
<td class="CoverValue branch-coverage coverage-low">50.0%</td>
<td class="CoverValue branch-coverage coverage-low">7 / 14</td>
</tr>

</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>GCC Code Coverage Report</h1>
</tr>
<tr>
<th scope="row">Date:</th>
<td>2022-03-25 20:21:00</td>
<td>2022-04-16 19:20:21</td>
</tr>
</table>
</div>
Expand All @@ -54,8 +54,8 @@ <h1>GCC Code Coverage Report</h1>
<tr>
<th scope="row">Branches:</th>
<td>7</td>
<td>16</td>
<td class="coverage-low">43.8%</td>
<td>14</td>
<td class="coverage-low">50.0%</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -625,7 +625,7 @@ <h1>GCC Code Coverage Report</h1>
</main>

<footer>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.0)</a>
Generated by: <a href="http://gcovr.com">GCOVR (Version 5.1)</a>
</footer>
</body>
</html>

0 comments on commit bdde94f

Please sign in to comment.