Michael, 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.
Thanks Martin -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Foord Sent: Thursday, June 22, 2006 4:13 AM To: Discussion of IronPython Subject: [IronPython] Code Coverage Hello all, 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 traceback information. Two alternative ideas. 1) Implement a 'cut down' version of sys.settrace which only implements what is possible. For sys.settrace - see http://docs.python.org/lib/debugger-hooks.html#debugger-hooks coverage.py is one of the most common tools : http://www.nedbatchelder.com/code/modules/coverage.html It uses settrace with the following function : def t(f, x, y): c[(f.f_code.co_filename, f.f_lineno)] = 1 return t 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 information directly. 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, Michael Foord http://www.resolversystems.com http://www.voidspace.org.uk/python/index.shtml _______________________________________________ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com