[pypy-svn] r2953 - in pypy/trunk/src/pypy: objspace tool

arigo at codespeak.net arigo at codespeak.net
Thu Feb 12 01:00:26 CET 2004


Author: arigo
Date: Thu Feb 12 01:00:25 2004
New Revision: 2953

Modified:
   pypy/trunk/src/pypy/objspace/trace.py
   pypy/trunk/src/pypy/tool/testit.py
Log:
A few more testit hacks to let some advertised options work:

-P runs the tests in TraceObjSpace, printing traces for failures.
-i starts pdb on the traceback of each error in turn.


Modified: pypy/trunk/src/pypy/objspace/trace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/trace.py	(original)
+++ pypy/trunk/src/pypy/objspace/trace.py	Thu Feb 12 01:00:25 2004
@@ -107,7 +107,12 @@
         return getattr(self.__func, name)
 
 class TraceObjSpace:
-    def __init__(self, space):
+    def __init__(self, space=None):
+        if space is None:
+            # make up a TrivialObjSpace by default
+            # ultimately, remove this hack and fix the -P option of tests
+            from pypy.objspace import trivial
+            space = trivial.TrivialObjSpace()
         self.__space = space
         self.settrace()
 

Modified: pypy/trunk/src/pypy/tool/testit.py
==============================================================================
--- pypy/trunk/src/pypy/tool/testit.py	(original)
+++ pypy/trunk/src/pypy/tool/testit.py	Thu Feb 12 01:00:25 2004
@@ -64,8 +64,16 @@
 
 class MyTextTestResult(unittest._TextTestResult):
     ignored = 0
+    trace_information = ()
+
+    def record_trace(self, test):
+        # XXX hack for TraceObjSpace
+        if hasattr(test.space, 'settrace'):
+            self.trace_information += test.space.getresult(),
+            test.space.settrace()
 
     def addError(self, test, err):
+        self.record_trace(test)
         from pypy.interpreter.baseobjspace import OperationError
         if isinstance(err[1], OperationError) and test.space.full_exceptions:
             if err[1].match(test.space, test.space.w_AssertionError):
@@ -75,6 +83,7 @@
         self.errors[-1] = (test, sys.exc_info())
 
     def addFailure(self, test, err):
+        self.record_trace(test)
         unittest._TextTestResult.addFailure(self, test, err)
         self.failures[-1] = (test, sys.exc_info())
 
@@ -93,12 +102,19 @@
             self.stream.write('i')
 
     def interact(self):
-        efs = self.errors + self.failures
-        from pypy.tool.testitpm import TestPM
-        c = TestPM(efs)
-        c.cmdloop()
+        #efs = self.errors + self.failures
+        #from pypy.tool.testitpm import TestPM
+        #c = TestPM(efs)
+        #c.cmdloop()
+        for test, (exc_type, exc_value, exc_tb) in self.errors:
+            import pdb; pdb.post_mortem(exc_tb)
 
     def printErrors(self):
+        if self.trace_information:
+            from pypy.tool.traceop import print_result
+            for trace in self.trace_information:
+                print_result(trace)
+            sys.stdout.flush()
         if Options.interactive:
             print
             if self.errors or self.failures:


More information about the Pypy-commit mailing list