[Lldb-commits] [lldb] r116559 - in /lldb/trunk/test: dotest.py lldbtest.py

Johnny Chen johnny.chen at apple.com
Thu Oct 14 19:28:13 PDT 2010


Author: johnny
Date: Thu Oct 14 21:28:13 2010
New Revision: 116559

URL: http://llvm.org/viewvc/llvm-project?rev=116559&view=rev
Log:
Simply use the TestBase.markFailure() callback method to set the __failed__ flag.

Modified:
    lldb/trunk/test/dotest.py
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=116559&r1=116558&r2=116559&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Thu Oct 14 21:28:13 2010
@@ -616,7 +616,6 @@
                 method = getattr(test, "markFailure", None)
                 if method:
                     method()
-                setattr(test, "__failed__", True)
 
         result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose,
                                           resultclass=LLDBTestResult).run(suite)

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116559&r1=116558&r2=116559&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Thu Oct 14 21:28:13 2010
@@ -411,12 +411,16 @@
         self.old_stderr = sys.stderr
         sys.stderr = self.session
 
+        # Optimistically set self.failed to False initially.
+        self.__failed__ = False
+
     def setTearDownCleanup(self, dictionary=None):
         self.dict = dictionary
         self.doTearDownCleanup = True
 
     def markFailure(self):
         """Callback invoked when we (the test case instance) failed."""
+        self.__failed__ = True
         with recording(self, False) as sbuf:
             # False because there's no need to write "FAIL" to the stderr again.
             print >> sbuf, "FAIL"
@@ -454,10 +458,10 @@
             if not module.cleanup(dictionary=self.dict):
                 raise Exception("Don't know how to do cleanup")
 
-        # lldb.test_result is an instance of unittest2.TextTestResult enforced
-        # as a singleton.  During tearDown(), lldb.test_result can be consulted
-        # in order to determine whether we failed for the current test instance.
-        if getattr(self, "__failed__", False):
+        # See also LLDBTestResult (dotest.py) which is a singlton class derived
+        # from TextTestResult and overwrites addFailure() method to allow us to
+        # to check the failure status here.
+        if self.__failed__:
             self.dumpSessionInfo()
 
         # Restore the sys.stderr to what it was before.





More information about the lldb-commits mailing list