-
-
Notifications
You must be signed in to change notification settings - Fork 22
ahip, hip, async tests and coverage #227
Description
We have an issue with code coverage now that we're starting to test our async backends.
Our source code layout looks like this in git:
/src/ahip/poolmanager.py
/test/async/test_poolmanager.py
/test/util.py
Before running tests, we:
-
install using unasync, which gives two packages:
.nox/test-3-8/lib/python3.8/site-packages/ahip/poolmanager.py .nox/test-3-8/lib/python3.8/site-packages/hip/poolmanager.py
-
run unasync on tests:
/test/async/test_poolmanager.py /test/sync/test_poolmanager.py /test/util.py
-
and run the tests on the installed packages
I guess ideally we'd like to see coverage both on ahip/poolmanager.py and hip/poolmanager.py, but hip/poolmanager.py isn't on git, for reasons explained in #149.
In #149 we mention that mapping sync code back to async code fixes the coverage issue. It's not that simple though, because we want to keep our hard-earned coverage during the transition to async tests.
By configuring pytest-cov with --cov=hip
and --cov=ahip
, an unmodified XML coverage report contains those lines:
<class name="poolmanager.py" filename=".nox/test-3-8/lib/python3.8/site-packages/ahip/poolmanager.py" complexity="0" line-rate="0.732" branch-rate="0">
<class name="poolmanager.py" filename=".nox/test-3-8/lib/python3.8/site-packages/hip/poolmanager.py" complexity="0" line-rate="1" branch-rate="0">
We can't just remove the synchronous version because it's the only one that's fully covered, and we can't just remove the async version because some of the code only runs in ahip, not hip. The more general solution is to merge the two files. I guess it's feasible in noxfile.py where we already parse coverage.xml. The way I'd do it:
- replace
.nox/test-3-8/lib/python3.8/site-packages/
withsrc/
in all filenames attributes, possibly do the same things in packages names - merge
src/hip/...
intosrc/ahip/...
by keeping the covered lines from the sync version, then remove thesrc/hip
coverage info
When we send the coverage file to codecov, we can pretend that only src/ahip
exists, which is good because it's the only thing that codecov can handle.
Thoughts?