[Zodb-checkins] CVS: StandaloneZODB - test.py:1.7

Jeremy Hylton jeremy@zope.com
Mon, 22 Oct 2001 20:10:12 -0400


Update of /cvs-repository/StandaloneZODB
In directory cvs.zope.org:/tmp/cvs-serv19451

Modified Files:
	test.py 
Log Message:
Add a -L argument to run the specified tests in an infinite loop.


=== StandaloneZODB/test.py 1.6 => 1.7 ===
 """
 
+import gc
 import os
 import re
 import string
@@ -85,33 +86,55 @@
 
     os.chdir("build")
 
-    alltests = unittest.TestSuite()
-
-    runner = unittest.TextTestRunner(verbosity=VERBOSE)
-    for file in files:
-        assert file[:2] == DOTSLASH
-        assert file[-3:] == '.py'
-        modname = file[2:-3]
-        modname = string.replace(modname, os.sep, '.')
-        mod = package_import(modname)
-        try:
-            suite = mod.test_suite()
-        except AttributeError:
-            continue
-        print modname, len(suite._tests)
-        runner.run(suite)
-
+    if LOOP:
+        suites = []
+        for file in files:
+            assert file[:2] == DOTSLASH
+            assert file[-3:] == '.py'
+            modname = file[2:-3]
+            modname = string.replace(modname, os.sep, '.')
+            print modname
+            mod = package_import(modname)
+            try:
+                suite = mod.test_suite()
+            except AttributeError:
+                return
+            suites.append((modname, len(suite._tests), suite))
+        if suites:
+            runner = unittest.TextTestRunner(verbosity=VERBOSE)
+            while 1:
+                for modname, size, suite in suites:
+                    runner.run(suite)
+                gc.collect()
+    else:
+        runner = unittest.TextTestRunner(verbosity=VERBOSE)
+        for file in files:
+            assert file[:2] == DOTSLASH
+            assert file[-3:] == '.py'
+            modname = file[2:-3]
+            modname = string.replace(modname, os.sep, '.')
+            print modname
+            mod = package_import(modname)
+            try:
+                suite = mod.test_suite()
+            except AttributeError:
+                return
+            print modname, len(suite._tests)
+            runner.run(suite)
 
 if __name__ == "__main__":
     import getopt
 
     filter = '.'
     VERBOSE = 0
+    LOOP = 0
 
-    opts, args = getopt.getopt(sys.argv[1:], 'v')
+    opts, args = getopt.getopt(sys.argv[1:], 'vL')
     for k, v in opts:
         if k == '-v':
             VERBOSE = VERBOSE + 1
+        elif k == '-L':
+            LOOP = 1
     if args:
         filter = args[0]
     try: