[Zodb-checkins] CVS: ZODB4 - test.py:1.9

Jeremy Hylton jeremy@zope.com
Wed, 11 Dec 2002 16:46:38 -0500


Update of /cvs-repository/ZODB4
In directory cvs.zope.org:/tmp/cvs-serv1401

Modified Files:
	test.py 
Log Message:
Add experimental -T option.


=== ZODB4/test.py 1.8 => 1.9 ===
--- ZODB4/test.py:1.8	Thu Dec  5 16:34:58 2002
+++ ZODB4/test.py	Wed Dec 11 16:46:37 2002
@@ -59,6 +59,12 @@
 
 -C  use pychecker
 
+-T  use trace module from Python for code coverage
+    XXX This only works if trace.py is explicitly added to PYTHONPATH.
+    The current utility writes coverage files to a directory named
+    coverage that is parallel to build.  It also prints a summary
+    to stdout.
+
 modfilter
 testfilter
     Case-sensitive regexps to limit which tests are run, used in search
@@ -350,12 +356,22 @@
     files = finder.files
     files.sort()
 
+    if TRACE:
+        coverdir = os.path.join(os.getcwd(),"coverage")
     os.chdir("build")
     if GUI:
         gui_runner(files, test_filter)
     elif LOOP:
         while 1:
             runner(files, test_filter, debug)
+    elif TRACE:
+        import trace
+        tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
+                             trace=0, count=1)
+        tracer.runctx("runner(files, test_filter, debug)",
+                      globals=globals(), locals=vars())
+        r = tracer.results()
+        r.write_results(show_missing=True, summary=True, coverdir=coverdir)
     else:
         runner(files, test_filter, debug)
     # XXX Should only report skips when the skipped test matches the filter
@@ -378,6 +394,7 @@
     global VERBOSE
     global LOOP
     global GUI
+    global TRACE
     global debug
     global debugger
     global build
@@ -388,6 +405,7 @@
     VERBOSE = 0
     LOOP = 0
     GUI = 0
+    TRACE = 0
     debug = 0 # Don't collect test results; simply let tests crash
     debugger = 0
     build = 0
@@ -395,7 +413,7 @@
     gcflags = []
 
     try:
-        opts, args = getopt.getopt(argv[1:], 'vdDLbhCumg:G:', ['help'])
+        opts, args = getopt.getopt(argv[1:], 'vdDLbhCumg:G:T', ['help'])
     except getopt.error, msg:
         print msg
         print "Try `python %s -h' for more information." % argv[0]
@@ -430,6 +448,8 @@
                 print "-G argument must be DEBUG_ flag, not", repr(v)
                 sys.exit(1)
             gcflags.append(v)
+        elif k == '-T':
+            TRACE = 1
 
     if gcthresh is not None:
         import gc