Skip excluded functions in LCOV function totals - #2206
Merged
Conversation
nedbat
reviewed
Jun 23, 2026
|
|
||
| outfile.write(f"FNF:{len(functions)}\n") | ||
| outfile.write(f"FNH:{functions_hit}\n") | ||
| if functions_found: |
Member
There was a problem hiding this comment.
Are you sure we should omit these lines if no functions are found/hit? Wouldn't it be better to output FNF:0 ?
Contributor
Author
There was a problem hiding this comment.
I believe you are correct, I also added a regression test to assert this behaviour.
nedbat
force-pushed
the
fix-lcov-excluded-functions
branch
from
June 27, 2026 16:20
4a80c04 to
d4e185a
Compare
Member
|
This is now released as part of coverage 7.15.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2205.
Summary
FNFfrom emitted functions rather than all discovered function regions.@abstractmethodthat raisesNotImplementedError.Details
Line records already respect report exclusions. Function records were still generated from all discovered function code regions, so a fully excluded abstract method could appear as
FNDA:0and reduce downstream LCOV function coverage even when the text report shows 100% line coverage.This narrows each function region before emission and skips regions with
n_statements == 0, matching the line-reporting behavior for fully excluded code.Tests
.venv/bin/python -m pytest tests/test_lcov.py::LcovTest::test_excluded_functions -q -n 0.venv/bin/python -m pytest tests/test_lcov.py -q -n 0