Saturday 22 May 2010 — This is over 14 years old. Be careful.
Someone asked me recently whether coverage.py works on Jython. I had never tried it before, so I took a look.
Coverage.py works in two steps: first, execute the code and record line numbers executed. Then analyze the code to identify parts that could have been executed but weren’t. It turns out Jython provides the tool needed for the first (sys.settrace), but not the tools needed for the second (code.co_consts, and other internal representations of compiled code).
I was able to measure a Jython execution by running “coverage run” under Jython 2.5.1 to do the first step. Then I ran “coverage html” under CPython to complete the second step and get a report.
But I don’t know if the line numbers will match up perfectly if the two steps are run under different interpreters. I’m looking for someone with a real Jython code base who’d like to try this technique and tell me what they find. Take the tip of the bitbucket repository, install it into your Jython and CPython installations, and run the two commands under the two different interpreters.
Drop me a line if you try this out, I’d love to be able to support Jython with coverage.py.
Comments
I shall have to give that a try.
I've said it before, but I'll say it again: thanks for your work on coverage. It's a marvelous tool that's really helped me identify problem areas in the software I work on.
Add a comment: