Each Answer to this Q is separated by one/two green lines.
coverage run --parallel-mode --source=mysource --omit=*/stuff/idont/need.py ./mysource/tests/run_all_tests.py coverage combine coveralls --verbose
This works quite nicely with the exception of multiprocessing. Code executed by worker pools or child processes is not tracked.
Is there a possibility to also track multiprocessing code? Any particular option I am missing? Maybe adding wrappers to the multiprocessing library to start coverage every time a new process is spawned?
I (and jonrsharpe, also 🙂 found a monkey-patch for multiprocessing.
However, this does not work for me, my Tracis-CI build is killed almost right after the start. I checked the problem on my local machine and apparently adding the patch to multiprocessing busts my memory. Tests that take much less than 1GB of memory need more than 16GB with this fix.
The monkey-patch does work after a small modification: Removing
config_file parsing (
config_file=os.environ['COVERAGE_PROCESS_START']) did the trick. This solved the issue of the bloated memory. Accordingly, the corresponding line simply becomes:
cov = coverage(data_suffix=True)
Coverage 4.0 includes a command-line option
--concurrency=multiprocessing to deal with this. You must use
coverage combine afterward. For instance, if your tests are in
regression_tests.py, then you would simply do this at the command line:
coverage run --concurrency=multiprocessing regression_tests.py coverage combine
I’ve had spent some time trying to make sure coverage works with
multiprocessing.Pool, but it never worked.
I have finally made a fix that makes it work – would be happy if someone directed me if I am doing something wrong.