What is canopy?
A mess, right now. In time, I would like to be able to run canopy as a nose plugin to gather execution information and produce accurate structural coverage metrics.
There already exists a tool that does this, and does it well. It is called coverage.py. coverage.py can report statement and branch coverage. It is likely to be all that you will need from a coverage tool.
coverage.py collects execution from the inside, by setting the cpython interpreter's settrace function. This works well, but depends on the implementation of the cpython interpreter. canopy collects execution information from the outside.
canopy uses the standard library ast module to rewrite relevant code. canopy inserts markers for observing statement execution and wraps expressions in function calls. This approach has a number of useful properties:
- implementation independant: canopy should work for any python implementation with a usable ast module.
- the code structure is known: the ast module provides a pre-built structural model of actual code - no parsing required
- flexibility: execution examination can take any form as long as the resulting code is equivalent
There are also drawbacks to this approach:
- it will be slow: the rewritten code will have many times more function calls than the original, clean, code.
- it will be complex: the rewritten code will do some downright odd things to avoid changing the functionality of the original code.
- prone to error: it is very easy for canopy to make subtle changes in the code during rewiting that will make the rewritten code different than the original code. This is a real problem, but there are strategies for dealing with it.
- the list could go on ...
When will it be ready?
Unfortunately, it may be a while. canopy exists as slightly more than a proof-of-concept right now.
What do I need to run canopy?
- python2.6 (until further notice)
(subject to change)
- more tests (ongoing)
- standalone code instrumentation
- standalone execution information collection
- working statement and branch coverage analysis
- a CI server
- decision coverage
- support python 2.5
- coverage report generation
- support python 3
- a working nose plugin
- flying cars