-
Notifications
You must be signed in to change notification settings - Fork 214
Ensure COV_CORE_SRC is an absolute path before exporting to the environment #465
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 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you tried changing In my experiements, I found that subprocess coverage reporting works better when specifying source packages instead of filesystem paths. In my case, this wasn't easy using a "flat" repo structure where the package directory (relative to repo root) and the package name are the same string. A solution is to explicitly use |
I personally haven't had issues using filesystem paths for reporting. I actually prefer it, because it's one less place where I have my package name specified (which can get out of a sync if I rename a project, or copy stuff to a new project with a different name).
For the record, this implementation doesn't work if you are using package names rather than source dirs, because this will mange the package name into an absolute path. The robust fix would be to replicate this IMO, a cleaner fix would be for coveragepy to have an explicit configuration knob for |
This `COV_CORE_SOURCE` environment variable is key for making sure that child processes continue computing code coverage. However, there's no guarantee that child processes start in the same directory as their parent process, which screws up coverage reporting if you're using relative paths for coverage sources. The fix is to make sure we're dealing with absolute paths. This is a little tricky to get right, because sources can include both dirs and packages. This fixes pytest-dev#465
This `COV_CORE_SOURCE` environment variable is key for making sure that child processes continue computing code coverage. However, there's no guarantee that child processes start in the same directory as their parent process, which screws up coverage reporting if you're using relative paths for coverage sources. The fix is to make sure we're dealing with absolute paths. This is a little tricky to get right, because sources can include both dirs and packages. This fixes pytest-dev#465
Summary
When COV_CORE_SRC is a relative directory and a subprocess first changes its working directory
before invoking Python then coverage won't associate the
Expected vs actual result
Get proper coverage reporting, but coverage is not reported properly.
Reproducer
bin/py.test src
bin/python src/something.py
Versions
Output of relevant packages
pip list
,python --version
,pytest --version
etc.Config
Include your
tox.ini
,pytest.ini
,.coveragerc
,setup.cfg
or any relevant configuration.Code
See https://github.com/flyingcircusio/backy/blob/master/src/backy/tests/test_backy.py#L99
I'm currently working around this by explicitly making COV_CORE_SRC absolute before calling the subprocess. I guess this could/should be done in general, too.
The text was updated successfully, but these errors were encountered: