You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Jump to the function exit" in lcov report for branch at top level of module #1874
This rather peculiar test case was delta-minimized from real code (appdirs.py 1.4.1). It is formatting sensitive. In particular, removing the #! line or moving the close parenthesis that's currently on a line by itself to the return bar( line will break it.
#! /usr/bin/env python
def foo():
return bar(
)
if "x" == "y": # line 5
pass
Running coverage run --branch and then coverage lcov on this test case will produce these branch coverage records:
BRDA:5,0,jump to line 6,0
BRDA:5,0,jump to the function exit,1
BRF:2
BRH:1
But line 5 is not in a function. We should instead get
BRDA:5,0,jump to line 6,0
BRDA:5,0,exit the module,1
which is what we do get if the close paren on line 4 is moved to line 3 (modulo #1873).
I presume that the code on lines 1-4 has confused the static analysis engine into thinking line 5 is inside a function, but then the arc description logic can't get a name for that function (because it doesn't exist).
changed the title [-]"Jump to function exit" in lcov report for branch at top level of module[/-][+]"Jump to the function exit" in lcov report for branch at top level of module[/+]on Oct 9, 2024
I've also observed similar issues in unit tests when the last statement in a function is a with block, but only on mac and linux and only in a very small portion of test functions. Windows was fine though. Adding a final pass statement before the function ends solved it, but i guess the something broke with the recent changes.
Hmm, this has been a bug for a long time. In 6.0.0 (Oct '21) through 6.4.1 (June '22), the message was "didn't jump to line 0". In 6.4.2 (July '22), it changed to "didn't jump to the function exit," and it's been that way ever since.
Activity
[-]"Jump to function exit" in lcov report for branch at top level of module[/-][+]"Jump to the function exit" in lcov report for branch at top level of module[/+]toebsen commentedon Oct 10, 2024
I've also observed similar issues in unit tests when the last statement in a function is a
withblock, but only on mac and linux and only in a very small portion of test functions. Windows was fine though. Adding a final pass statement before the function ends solved it, but i guess the something broke with the recent changes.nedbat commentedon Oct 13, 2024
Hmm, this has been a bug for a long time. In 6.0.0 (Oct '21) through 6.4.1 (June '22), the message was "didn't jump to line 0". In 6.4.2 (July '22), it changed to "didn't jump to the function exit," and it's been that way ever since.
wip: add a test for #1874
wip: add a test for #1874
fix: multi-line statements no longer confuse branch target descriptio…
fix: multi-line statements no longer confuse branch target descriptio…
fix: multi-line statements no longer confuse branch target descriptio…
nedbat commentedon Dec 24, 2024
This is fixed in commit c85eaba.
nedbat commentedon Dec 26, 2024
This is now released as part of coverage 7.6.10.