[PATCH 2 of 2] tests: add htmlcov option

Markus Zapke-Gründemann markuszapke at gmx.net
Wed Jan 11 10:16:05 CST 2012


# HG changeset patch
# User Markus Zapke-Gründemann <info at keimlink.de>
# Date 1326292711 -3600
# Node ID 758693feb29284a388f00b3882c8db42b9000de8
# Parent  1d105733e04aaab0960da0b185aa6f3b02173483
tests: add htmlcov option

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -141,6 +141,8 @@ def parseargs():
              " rather than capturing and diff'ing it (disables timeout)")
     parser.add_option("-f", "--first", action="store_true",
         help="exit on the first test failure")
+    parser.add_option("-H", "--htmlcov", action="store_true",
+        help="create an HTML report of the coverage of the files")
     parser.add_option("--inotify", action="store_true",
         help="enable inotify extension when running tests")
     parser.add_option("-i", "--interactive", action="store_true",
@@ -211,7 +213,7 @@ def parseargs():
                          % hgbin)
         options.with_hg = hgbin
 
-    options.anycoverage = options.cover or options.annotate
+    options.anycoverage = options.cover or options.annotate or options.htmlcov
     if options.anycoverage:
         try:
             import coverage
@@ -495,6 +497,9 @@ def outputcoverage(options):
     covrun('-c')
     omit = ','.join(map(os.path.join, [BINDIR, TESTDIR], ['*'] * 2))
     covrun('-i', '-r', '"--omit=%s"' % omit) # report
+    if options.htmlcov:
+        htmldir = os.path.join(TESTDIR, 'htmlcov')
+        covrun('-i', '-b', '"--directory=%s"' % htmldir, '"--omit=%s"' % omit)
     if options.annotate:
         adir = os.path.join(TESTDIR, 'annotated')
         if not os.path.isdir(adir):


More information about the Mercurial-devel mailing list