[Zope-Checkins] CVS: Zope3 - test.py:1.1.2.13

Barry Warsaw barry@wooz.org
Thu, 6 Jun 2002 12:26:14 -0400


Update of /cvs-repository/Zope3
In directory cvs.zope.org:/tmp/cvs-serv13823

Modified Files:
      Tag: Zope-3x-branch
	test.py 
Log Message:
Add a -g option to control the gc threshold, and also recognize --help
as a synonym for -h.


=== Zope3/test.py 1.1.2.12 => 1.1.2.13 ===
     memory leakage.
 
+-g  threshold
+    Set the garbage collector generation0 threshold.  This can be used to
+    stress memory and gc correctness.  Some crashes are only reproducible when
+    the threshold is set to 1 (agressive garbage collection).  Do "-g 0" to
+    disable garbage collection altogether.
+
 modfilter
 testfilter
     Case-sensitive regexps to limit which tests are run, used in search
@@ -251,9 +257,11 @@
     LOOP = 0
     debug = 0 # Don't collect test results; simply let tests crash
     build = 0
+    gcthresh = None
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], 'vdLbhC')
+        opts, args = getopt.getopt(sys.argv[1:], 'vdLbhCg:',
+                                   ['help'])
     except getopt.error, msg:
         print msg
         print "Try `python %s -h' for more information." % sys.argv[0]
@@ -261,18 +269,25 @@
 
     for k, v in opts:
         if k == '-v':
-            VERBOSE = VERBOSE + 1
+            VERBOSE += 1
         elif k == '-d':
             debug = 1
         elif k == '-L':
             LOOP = 1
         elif k == '-b':
             build = 1
-        elif k == '-h':
+        elif k in ('-h', '--help'):
             print __doc__
             sys.exit(0)
         elif k == '-C':
             import pychecker.checker
+        elif k == '-g':
+            gcthresh = int(v)
+
+    if gcthresh is not None:
+        import gc
+        gc.set_threshold(gcthresh)
+        print 'gc threshold:', gc.get_threshold()
 
     if build:
         cmd = sys.executable + " stupid_build.py"