Skip to content

Conversation

jennifer-richards
Copy link
Member

@jennifer-richards jennifer-richards commented Jul 28, 2025

Upgrades to the current version of coverage 7.9.2. Refactors the code organization to separate the parts that wrangle coverage from the rest of the test_runner. Removes some unused / unneeded bits of code.

A major difference in the new (5.0+) coverage is that its internal data are stored as an sqlite database instead of json. As far as I can see, this is not significant for our purposes. We work with what coverage calls a "report" rather than with its own internal data. This PR refactors the old code with the fairly small set of changes needed to adapt to some reorganization in the coverage project and produces the same JSON coverage data that datatracker has been using in recent years.

Excluding lines / blocks from coverage checking is now done with the # pragma: no cover magic comment. The old method, using a context manager, was nice but is not easily translated into what the modern coverage package makes possible. A context manager to disable template and url coverage is still used, now called disable_coverage(). This needs to be used together with the pragma to turn off all types of coverage checks.

I've added tests to ensure that the new CoverageManager class orchestrates things correctly and, as a safeguard, turns into a no-op if it is somehow called in production mode. I did not add tests for the stats reporting module because errors in it are likely to cause test failures, coverage drops, or other problems that we'll notice through other means. Testing it will require pretty involved mocking that didn't seem worth it.

Comparing the coverage stats generated by this refactor against the 12.43.1 release coverage finds very good but not exact agreement. There are many trivial format changes ("0" and "1" become "0.0" and "1.0"; rounding of floats is different in the 10^-9 decimal place or so), a few real but insignificant changes that I believe have to do with which lines coverage treats as coverable, and some changes to do with minor configuration changes between dev and GHA testing. None of these affects more than a few lines in any file and the overwhelming majority of files have exactly the same coverage stats.

Regarding speed, according to time the full test suite takes a total of 14:53.50 (871 seconds reported by the test runner) on my laptop. The current main branch using py39 and coverage 4.5.4 takes a total of 14:26.69 (855 seconds reported by the test runner). That's a negligible difference.

@jennifer-richards jennifer-richards merged commit 68a2853 into ietf-tools:feat/py312 Aug 4, 2025
2 checks passed
@jennifer-richards jennifer-richards deleted the upgrade-coverage branch August 4, 2025 21:58
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants