Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 080ce06

Browse files
tingileenedbat
authored andcommitted
[lcov] Exclude executed lines respected exclude configs
1 parent afa7559 commit 080ce06

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

coverage/lcovreport.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ def get_lcov(self, fr: FileReporter, analysis: Analysis, outfile: IO[str]) -> No
6262
outfile.write("TN:\n")
6363
outfile.write(f"SF:{fr.relative_filename()}\n")
6464
source_lines = fr.source().splitlines()
65-
65+
sorted_excluded = sorted(analysis.excluded)
6666
for covered in sorted(analysis.executed):
67+
if covered in sorted_excluded:
68+
# Do not report excluded as executed
69+
continue
6770
# Note: Coverage.py currently only supports checking *if* a line
6871
# has been executed, not how many times, so we set this to 1 for
6972
# nice output even if it's technically incorrect.
@@ -82,6 +85,9 @@ def get_lcov(self, fr: FileReporter, analysis: Analysis, outfile: IO[str]) -> No
8285
outfile.write(f"DA:{covered},1,{line_hash(line)}\n")
8386

8487
for missed in sorted(analysis.missing):
88+
if missed in sorted_excluded:
89+
# Do not report excluded as missing
90+
continue
8591
assert source_lines
8692
line = source_lines[missed-1]
8793
outfile.write(f"DA:{missed},0,{line_hash(line)}\n")

0 commit comments

Comments
 (0)