[IronPython] Code Coverage
Martin.Maly at microsoft.com
Thu Jun 22 08:55:30 PDT 2006
thanks for the feedback. The settrace function is actually one of many things we are hoping to address in the next release. Dino and I discussed options for implementing it and hopefully we can get it fixed for the next release.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Thursday, June 22, 2006 4:13 AM
To: Discussion of IronPython
Subject: [IronPython] Code Coverage
I've been looking at code coverage tools for Python, as we would like to
check the coverage of our unit tests.
Unfortunately all the Python code coverage tools use ``sys.settrace``
which isn't implemented in IronPython. This (I guess) is because Python
stack frames and code objects aren't used in IronPython.
Unfortunately this makes coverage tools impossible (or just very
difficult), unless an alternative mechanism is provided. (They also
tend to use the parser module which is another issue.)
I browsed the IronPython source (is there an API doc ?) but couldn't see
anything useful to get a callback as new source-code lines are entered.
Line information is obviously *somewhere*, as it is presented in
Two alternative ideas.
1) Implement a 'cut down' version of sys.settrace which only implements
what is possible.
For sys.settrace - see
coverage.py is one of the most common tools :
It uses settrace with the following function :
def t(f, x, y):
c[(f.f_code.co_filename, f.f_lineno)] = 1
So it only uses a filename reference from the code object and the
line_no from the frame. Either dummy objects could be constructed, or an
IronPython specific implementation could be made which presents this
2) Alternatively a callback hook on the C# side could be implemented, so
that as IronPython enters a new line we could cache this information -
and generate a report once execution has stopped.
Either of these would be much appreciated.
All the best,
users mailing list
users at lists.ironpython.com
More information about the users