pytest: Collect code coverage in multiple workers too #4451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds code coverage collection to more tests, by enabling it for the tests ran with pytest-xdist (multiple workers in parallel).
The change in
utils/coverage_mapper.py
was needed to fix a situation where a file would end in.py.py
if it already had an extension. It will happen primarily on Windows, but that part isn't ready yet as the time increase was a bit too big, and xdist wasn't working as well as I hoped yet. Also, macOS wasn't changed to include coverage yet since last time I tried, I had some issues with uploading the code coverage, and didn't retry recently with the new release of the codecov uploader. So it isn't ready there too.In order to save up a couple dozen seconds here and there, I also ignored the gui/wxpython subfolders, as no coverage is collected now for it, and there is only one or two tests that could one day have coverage if it worked with gunittest. It will be reconsidered later.
$ ag -g 'gui/.*/test' gui/wxpython/core/testsuite/data/test_toolboxes_menu.xml gui/wxpython/core/testsuite/data/test_toolboxes_menudata_ref.xml gui/wxpython/core/testsuite/data/test_toolboxes_user_toolboxes.xml gui/wxpython/core/testsuite/test_gcmd.py gui/wxpython/core/testsuite/toolboxes.sh gui/wxpython/mapdisp/test_mapdisp.py
The "downside" is that codecov will not "know" that we have files not covered in that subfolder. That's why I made sure to keep the
gui/wxpython/wxgui.py
file and only exclude the subfolders starting from that level. With this, we still have an entry for thegui/
folder that has 0 coverage to remember that this folder exists.