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

Track coverage information #437

Open
sandhose opened this issue Mar 21, 2024 · 3 comments
Open

Track coverage information #437

sandhose opened this issue Mar 21, 2024 · 3 comments

Comments

@sandhose
Copy link

In my project, I've been trying to make sure my templates rendering won't crash at runtime by generating a bunch of sample contexts and render my templates with them in my tests.

One thing I would really be interested in having would be coverage informations for them. I would like to know how much my sample contexts cover all possible branches in my templates.
Thankfully, minijinja being really nicely designed, it seems to already track source spans in the instructions, so it feels like it should mainly be a matter of emitting the spans during instruction evaluation, similar to what is done for the fuel tracker.

I'd be happy to prototype something if you think this feature makes sense. This could be done either by doing coverage tracking within minijinja, or by exposing more internals (looks like exposing a way to read Template.instructions should be enough?) and adding a hook/callback when instructions get evaluated.

@mitsuhiko
Copy link
Owner

How would you want to export coverage reports? I'm not entirely opposed to it, but this sounds like a niche feature unless there is some really good tooling that this could plug into.

@sandhose
Copy link
Author

My end goal would be to send that coverage to codecov. I haven't really looked up what the best output format would be

It is indeed probably a niche feature, so maybe a good way for me to able to achieve this would be to expose enough internals (under the unstable_machinery feature?) and hooks so that I can write coverage tooling as an external crate? If you're alright with this approach, I'll try to hack that together, see exactly what's missing

@mitsuhiko
Copy link
Owner

Yeah, unstable_machinery might be a good starting point.

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