[conduit: 57/138] Crude coverage testing
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit: 57/138] Crude coverage testing
- Date: Thu, 21 May 2009 03:31:43 -0400 (EDT)
commit 36a23ae8c651ff00fe583d3e8c61092297cc2ae9
Author: John Carr <john carr unrouted co uk>
Date: Thu Apr 30 11:38:46 2009 -0700
Crude coverage testing
---
test/soup/soup | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/test/soup/soup b/test/soup/soup
index d7ada66..2233463 100755
--- a/test/soup/soup
+++ b/test/soup/soup
@@ -1,6 +1,8 @@
#! /usr/bin/env python
-import sys, os
+import sys, os, unittest
+from glob import glob
+
testsdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, testsdir)
@@ -12,11 +14,22 @@ from test_datatypes import *
from test_dataprovider import *
from test_synchronization import *
-import unittest
-
-def run_tests(tests, verbose=False):
+def run_tests(tests, verbose=False, do_coverage=False):
runner = unittest.TextTestRunner(verbosity=2 if verbose else 1)
+
+ if do_coverage:
+ import coverage
+ coverage.erase()
+ coverage.start()
+
result = runner.run(unittest.TestSuite(tests))
+
+ if do_coverage:
+ coverage.stop()
+ modules = glob('conduit/*.py')+glob('conduit/*/*.py')+glob('conduit/*/*/*.py')
+ coverage.report(modules, ignore_errors=1, show_missing=0)
+ coverage.erase()
+
sys.exit(not result.wasSuccessful())
def list_tests(tests):
@@ -39,6 +52,8 @@ if __name__ == "__main__":
help="Run tests in a random order")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
help="Output lots of noise as tests are run")
+ parser.add_option("-c", "--coverage", action="store_true", dest="coverage",
+ help="Enable code coverage")
# Add the different execution modes..
parser.add_option("-l", "--list", action="store_const", const="list", dest="mode",
@@ -47,7 +62,7 @@ if __name__ == "__main__":
help="Run the tests")
# Set parse defaults
- parser.set_defaults(mode="execute", randomize=False, verbose=False)
+ parser.set_defaults(mode="execute", randomize=False, verbose=False, coverage=False)
# And parse..
opts, args = parser.parse_args()
@@ -73,7 +88,7 @@ if __name__ == "__main__":
# And run.
if opts.mode == "execute":
- run_tests(tests, verbose=opts.verbose)
+ run_tests(tests, verbose=opts.verbose, do_coverage=opts.coverage)
elif opts.mode == "list":
list_tests(tests)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]