-
Notifications
You must be signed in to change notification settings - Fork 290
Description
So I've been playing with setting up gcovr
to measure coverage for Python modules written in pure C (not Cython). I got in working as a PoC in the dev environment, however I've faced challenges integrating it with the CI (aio-libs/multidict#1228). There's a lot of moving pieces and path mapping complexity that I've mostly overcome.
However, it turned out that gcovr
invokes the gcov
program of GCC to analyze the *.gcno
and *.gcda
files.
*.gcno
is produced when invoking gcc
when it's set up to produce tracing-related data (so during the compilation stage) and *.gcda
is written to disk when the C-extension is actually executed (as in when running pytest
that imports the compiled module).
After that, a carefully composed gcovr
command is able to produce HTML, XML and other coverage outputs.
This all works well in a dev env with something like an editable install. However, in CI we have cibuildwheel
jobs that produce manylinux
wheels in containers, and following jobs install and test those wheels. I've able to make it so that *.gcno
ends up in site-packages/
as included package data and my pytest
setup is able to properly transfer that into the CWD and set environment variables that GCOV requires to write *.gcda
into the same folder.
The problem is that the gcovr
invocation in CI it's an error when running gcov
(./_multidict.gcda:version 'B42 ', prefer version 'B43*'
and a return code of 3).
It turns out that I have to use the same toolchain for analyzing coverage as was used to compile C-extensions: https://stackoverflow.com/a/60347862/595220.
So my idea is that I'd extract the appropriate manylinux container value from cibuildwheel and run gcovr
inside it, in the test jobs, after running pytest
. I've validated locally that this would work by running the same container image interactively.
Is it possible to expose this (or even the entire config computed from the file, CLI args and env vars — this would be more generic)? Perhaps a subcommand would be useful, showing what container is selected based on the wheel name? Is the config somehow available from within a cibuildwheel
run? Any other ideas?