-
-
Notifications
You must be signed in to change notification settings - Fork 464
Description
Describe the bug
coverage lcov can generate BRDA: records with line number zero. Current versions of lcov's genhtml reject such lines:
genhtml: ERROR: line 0 of .../sourcefile.py has branchcov but no linecov data
To Reproduce
The bad BRDA records are coming from here: https://github.com/nedbat/coveragepy/blob/5467e1f0c9e16ef5456ecccb56993b15c34b7a3e/coverage/lcovreport.py#L108-L112
I do not understand how to hit this case. The commentary, and the description of what negative numbers mean in arc records (https://coverage.readthedocs.io/en/7.6.1/api_coveragedata.html#coverage.CoverageData.arc) make it sound like unexecuted conditional return statements could cause the problem. Running coverage run --branch test.py on this file
def f(x):
if x < 0:
return
print("got here")
f(0)
f(1)
produces a .coverage database whose arc table does contain negative numbers, but running coverage lcov on that database produces
BRDA:3,0,0,-
BRDA:4,0,1,1
BRF:2
BRH:1
which does not use line zero and looks correct to me (well, modulo the fact that a human would say there isn't a branch on line 4? but that's a separate issue).
Looking at the database for the real program that produced the actual bad lcov-format report that prompted this issue, I see lots more cases of negative numbers in the arc table, but the associated positive numbers are too large to be actual line numbers in the associated file, which means I don't actually understand what the records in the arc table mean, so I'm stuck.
Expected behavior
coverage lcov should generate a .lcov file that genhtml does not reject.