+
Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

ahip, hip, async tests and coverage #227

@pquentin

Description

@pquentin

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/ with src/ in all filenames attributes, possibly do the same things in packages names
  • merge src/hip/... into src/ahip/... by keeping the covered lines from the sync version, then remove the src/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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载