Skip to content
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

Coverage measurement for Cython code #182

Open
oscarbenjamin opened this issue May 5, 2024 · 4 comments
Open

Coverage measurement for Cython code #182

oscarbenjamin opened this issue May 5, 2024 · 4 comments

Comments

@oscarbenjamin
Copy link

Currently spin test supports --coverage and --gcov arguments for measuring coverage of python or C code respectively. For python-flint the one outstanding item in moving from setuptools to spin/meson is coverage measurement of Cython code.

A meson project needs to have some sort of configuration option for coverage of Cython e.g.:

if get_option('coverage')
   add_project_arguments('-X', 'linetrace=True', language : 'cython')
   add_project_arguments('-DCYTHON_TRACE=1', language : 'c')
endif

In python-flint's case we need this separately from b_coverage=true and spin's --gcov option because we explicitly do not want to measure coverage of C code (which is all Cython-generated).

I'm not sure what the best approach would be for spin to implement spin test --coverage-cython given that there is not a standard meson option for this.

Maybe spin could configure the CYTHON_TRACE and linetrace directly?

Currently it seems that Cython's coverage plugin does not work in a spin build-install directory which I think is because the plugin tries to look for Cython source files adjacent to the C files. Possibly that is something that needs to be fixed in Cython or maybe it is possible for spin to tell coverage where to find the source files.

@oscarbenjamin
Copy link
Author

I've made a repo that demonstrates how to get working Cython coverage with setuptools but also shows what does not work with spin:
https://github.com/oscarbenjamin/cython_coverage_demo

At least some change in Cython's coverage plugin is needed.

Also possibly the way that spin/meson generate the .c files results in them containing the wrong path.

@stefanv
Copy link
Member

stefanv commented May 6, 2024

@oscarbenjamin I'd like to see Cython coverage work. I'm a bit tied up for the next few days, but will take a look after that, if you haven't found a solution by then already.

@oscarbenjamin
Copy link
Author

The primary blocker to Cython code coverage with spin/meson is that changes are needed in Cython's coverage plugin. I opened a related Cython issue cython/cython#6186.

@oscarbenjamin
Copy link
Author

I have described in cython/cython#6186 (comment) how I think we can make coverage work with Cython for a spin/meson-based project.

I think that the proper solution is that spin/meson needs to make something like a json file that tells the coverage plugin where all the files are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants