Permalink
Browse files

added a code coverage report

  • Loading branch information...
1 parent fd28ae0 commit 1d1709da848991d392399f1d8bef90d360d07284 @tarekziade tarekziade committed Apr 13, 2012
Showing with 51 additions and 1 deletion.
  1. +46 −0 docs/coverage_ext.py
  2. +1 −1 docs/source/conf.py
  3. +2 −0 docs/source/index.rst
  4. +2 −0 pip-requirements.txt
View
@@ -0,0 +1,46 @@
+import os
+import coverage
+from nose.core import TestProgram
+import sys
+import StringIO
+
+
+page = """
+Code coverage
+=============
+
+
+::
+
+%s
+
+"""
+
+
+def generate_coverage(app):
+ cov = coverage.coverage()
+ cov.start()
+
+ try:
+ old_arg = sys.argv[:]
+ sys.argv = [sys.executable, 'circus']
+ try:
+ testprogram = TestProgram(module='circus', exit=False)
+ finally:
+ sys.argv[:] = old_arg
+ finally:
+ cov.stop()
+
+ res = StringIO.StringIO()
+
+ target = os.path.join(app.srcdir, 'coverage.rst')
+ cov.save()
+ cov.report(file=res)
+ res.seek(0)
+
+ with open(target, 'w') as f:
+ f.write(page % ''.join([" " + line for line in res.readlines()]))
+
+
+def setup(app):
+ app.connect('builder-inited', generate_coverage)
View
@@ -31,7 +31,7 @@
sys.path.append(os.path.join(CURDIR, '..'))
import circus
-extensions = ['sphinx.ext.autodoc', 'circus_ext']
+extensions = ['sphinx.ext.autodoc', 'circus_ext', 'coverage_ext']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -144,6 +144,8 @@ More documentation
architecture
deployment
examples
+ coverage
+
Contributions and Feedback
--------------------------
@@ -1,2 +1,4 @@
psutil==0.4.1
pyzmq==2.1.11
+coverage
+nose

0 comments on commit 1d1709d

Please sign in to comment.