coveragepy icon indicating copy to clipboard operation
coveragepy copied to clipboard

coverage report data written not collected when using contextlib.chdir with multiprocessing

Open graingert opened this issue 1 year ago • 0 comments

Describe the bug coverage report data written not collected when using contextlib.chdir with multiprocessing, Coverage writes data relative to the cwd, but I think the parent process should compute an absolute path to the coverage data directory and then proceed to use that in subprocesses

To Reproduce How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using? 3.12
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful. 7.6.1
  3. What versions of what packages do you have installed? The output of pip freeze is helpful. just coverage
  4. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix. https://gist.github.com/graingert/71ff2fb371a5538df740bc76eedcbdee
  5. What commands should we run to reproduce the problem? Be specific. Include everything, even git clone, pip install, and so on. Explain like we're five!
git clone [email protected]:71ff2fb371a5538df740bc76eedcbdee.git
python3.12 -m venv .venv
source ./venv/bin/activate
pip install coverage
coverage run demo.py
coverage combine
coverage report -m

Expected behavior should see 100% coverage

Additional context this is also causes problems when I'm collecting coverage, creating a tmp folder for my sut process to write to, then using chdir/multiprocessing and seeing that .coverage file in my tmp folder

graingert avatar Oct 01 '24 11:10 graingert