Repository navigation
CI: measure coverage in Python subprocesses via patch = subprocess - #1953
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1953 +/- ##
==========================================
+ Coverage 90.73% 90.83% +0.09%
==========================================
Files 92 92
Lines 14130 14130
==========================================
+ Hits 12821 12835 +14
+ Misses 1309 1295 -14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Tests such as test_helptext and test_shell_completion run `dandi` as a subprocess, so the CLI code they exercise was never recorded. coverage's `patch = subprocess` starts measurement in child Python processes, writing parallel data files that the existing `coverage combine` picks up. Bump the floor to coverage 7.10.6, which carries fixes for this feature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UkDjoCcCmBNuhFkmTyyohk
930685b to
c8d56c3
Compare
|
Hmm this one doesn't seem to do 'as much' as the other, but maybe still catching a new line or two? I leave this one up to you @yarikoptic |
|
yeah, not sure. I wonder if thereare any downsides? |
|
@yarikoptic, the downsides I could find, and what I checked: How it works: coverage ≥ 7.10 installs Actual downsides:
Things I checked that turned out not to be problems:
Gain: +14 lines on the final full-matrix comparison (90.73% → 90.83%). Mostly code that only Generated by Claude Code |
well - that's the goal after all ;)
sounds like a gain then. Lets get it |
Follow-up to #1951, modeled on datalad/datalad#7952.
Some tests run
dandias a subprocess (test_helptext.py,test_shell_completion.py), so the CLI code they exercise was never recorded. coverage.py'spatch = subprocessstarts measurement in child Python processes. Each child writes a parallel data file (parallel = Trueis already set), and thecoverage combinethat #1951 added picks them up.tox.ini: addpatch = subprocessto[coverage:run]pyproject.toml: raise thecoveragefloor from 7.0.0 to 7.10.6.patchfirst appeared in 7.10, and datalad picked 7.10.6 for its fixes to this feature..coverage.*is already in.gitignore.Effect
The gain across the full CI matrix is modest. Once all uploads were in, Codecov showed +14 lines (90.73% → 90.83%) against
master. Most of the code these subprocess tests reach is already covered by in-processCliRunnertests. The main lasting value is that any future test which shells out todandi(or another Python entry point) is counted automatically.In isolation the mechanism is clearly visible. With
coverage run -m pytestontest_helptext.py,cli/tests/test_command.py,cli/tests/test_shell_completion.pyandtest_organize.py, covered lines went from 3781 to 3838 (+57, incli/command.py,utils.py,cli/cmd_shell_completion.pyand_version.py). Results were the same on coverage 7.10.6 and 7.16.2.test_no_heavy_importschecks a Python subprocess's stderr and loaded modules. It still passes, because coverage starting up in the child doesn't import numpy, h5py or pynwb.The downsides are covered in the discussion below: Python subprocesses run slower during tests, and the
test-extra floor is higher.🤖 Generated with Claude Code
https://claude.ai/code/session_01UkDjoCcCmBNuhFkmTyyohk