Lcov report improvements part 2 by zackw · Pull Request #1851 · nedbat/coveragepy (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation8 Commits16 Checks34 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

zackw

@zackw zackw marked this pull request as draft

September 11, 2024 20:28

This was referenced

Sep 12, 2024

@nedbat

@nedbat

@zackw

Split the bulk of the code in LcovReporter.lcov_file out into two free helper functions, lcov_lines and lcov_arcs. This is easier to read and will make it easier to do future planned changes in a type-safe manner.

No functional changes in this commit.

@zackw

The branch field of a BRDA: record can be an arbitrary textual label. Therefore, instead of emitting meaningless numbers, emit the string “to line ” for ordinary branches (where is the arc destination line, and “to exit” for branches that exit the function. When there is more than one exit arc from a single line, provide the negated arc destination as a disambiguator.

Thanks to Henry Cox (@henry2cox), one of the LCOV maintainers, for clarifying the semantics of BRDA: records for us.

@zackw

Quite straightforward: a function has been executed if any of its region’s lines have been executed.

@zackw

Should fix the test failures with pypy pretending to be python 3.8.

@zackw

There is a bug somewhere, in which if we collect data in --branch mode under PyPy 3.8, regions for top-level functions come out of the analysis engine with empty lines arrays. The previous commit prevented this from crashing the lcov reporter; this commit adjusts the tests of the lcov reporter so that we expect the function records affected by the bug to be missing.

I don’t think it’s worth trying to pin down the cause of the bug, since Python 3.8 is approaching end-of-life for both CPython and PyPy.

@zackw

@zackw

@zackw

@zackw zackw marked this pull request as ready for review

October 2, 2024 15:00

@zackw zackw changed the title[WIP] Lcov report improvements part 2 Lcov report improvements part 2

Oct 2, 2024

@zackw

@zackw

I think this is ready to be reviewed now. Let me know if you want me to clean up the commit history or anything.

@nedbat

BTW, I'm about to drop Python 3.8, so you can simplify the tests by just skipping them on pypy3.8.

@zackw

Testing whether the existing @xfail_pypy38 decorator does the trick now.

@zackw

This replaces the custom fn_coverage_missing_in_pypy_38 logic that was used in earlier commits.

@zackw

The lcov output tests that are affected by bugs in PyPy 3.8, fail with the current version of PyPy 3.8 (7.3.11), unlike the other tests annotated with @xfail_pypy38. Split this decorator into two variants, xfail_older_pypy38 (used for all the tests that were labeled xfail_py38 prior to this patchset) and xfail_all_pypy38 (used for the lcov output tests).

@nedbat

Looks good, thanks so much! I'll merge it.

@nedbat

bgianfo

# this probably means 'line' was never executed at all.
# Cross-check with the line stats.
assert len(executed_arcs[line]) == 0
assert line in analysis.missing

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our coverage workflow is now failing due to this line, when running with version 7.6.3.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide us with a way to reproduce it? Failing that, can you add this line before the assert, and show us the output?

print(f"{line=}, {analysis.missing=}")

(this should have been on the assert line, my bad)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing this same error too, but only in CI so far. I haven't been able to reproduce it locally so I can't put the print() line in either...