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

Jeremy Hylton jeremy@zope.com
Fri, 26 Oct 2001 13:14:02 -0400


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

Modified Files:
	test.py 
Log Message:
Add optional check_mem() call for -L option.

Fix bug in either case that caused test suite to exit when test module
without test_suite() attribute was found.


=== StandaloneZODB/test.py 1.8 => 1.9 ===
     return string.join(dirs[2:], '.')
 
+if sys.platform == "linux2":
+    _pid = os.getpid()
+    
+    def check_mem():
+        vm = {}
+        order = []
+        f = open("/proc/%d/status" % _pid)
+        for line in f.readlines():
+            if line[:2] == 'Vm':
+                field, val = string.split(line, ':', 2)
+                val = string.strip(val)
+                vm[field] = val
+                order.append((field, max(len(field), len(val))))
+        f.close()
+        for field, size in order:
+            fmt = "%%%ds " % size
+            print fmt % field,
+        print
+        for field, size in order:
+            fmt = "%%%ds " % size
+            print fmt % vm[field],
+        print
+else:
+    # not sure what to do on any other platform
+    def check_mem():
+        pass
+
 def main(filter=None):
     setup_path()
     files = find_tests(filter)
@@ -109,7 +136,7 @@
             try:
                 suite = mod.test_suite()
             except AttributeError:
-                return
+                continue
             suites.append((modname, len(suite._tests), suite))
         if suites:
             runner = unittest.TextTestRunner(verbosity=VERBOSE)
@@ -117,6 +144,7 @@
                 for modname, size, suite in suites:
                     runner.run(suite)
                 gc.collect()
+                check_mem()
     else:
         runner = unittest.TextTestRunner(verbosity=VERBOSE)
         for file in files:
@@ -128,7 +156,7 @@
             try:
                 suite = mod.test_suite()
             except AttributeError:
-                return
+                continue
             print modname, len(suite._tests)
             runner.run(suite)