[Lldb-commits] [lldb] r246063 - Don't throw an exception when module cleanup fails.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 26 12:44:57 PDT 2015
Author: zturner
Date: Wed Aug 26 14:44:56 2015
New Revision: 246063
URL: http://llvm.org/viewvc/llvm-project?rev=246063&view=rev
Log:
Don't throw an exception when module cleanup fails.
Just because one test fails to clean up correctly, it should not
prevent other tests from attempting to run.
Modified:
lldb/trunk/test/dotest.py
lldb/trunk/test/lldbtest.py
lldb/trunk/test/unittest2/case.py
lldb/trunk/test/unittest2/result.py
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=246063&r1=246062&r2=246063&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Wed Aug 26 14:44:56 2015
@@ -1685,6 +1685,17 @@ for ia in range(len(archs) if iterArchs
if parsable:
self.stream.write("FAIL: LLDB (%s) :: %s\n" % (self._config_string(test), str(test)))
+ def addCleanupError(self, test, err):
+ global sdir_has_content
+ global parsable
+ sdir_has_content = True
+ super(LLDBTestResult, self).addCleanupError(test, err)
+ method = getattr(test, "markCleanupError", None)
+ if method:
+ method()
+ if parsable:
+ self.stream.write("CLEANUP ERROR: LLDB (%s) :: %s\n" % (self._config_string(test), str(test)))
+
def addFailure(self, test, err):
global sdir_has_content
global failuresPerCategory
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=246063&r1=246062&r2=246063&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Aug 26 14:44:56 2015
@@ -1195,8 +1195,7 @@ class Base(unittest2.TestCase):
if doCleanup and not lldb.skip_build_and_cleanup:
# First, let's do the platform-specific cleanup.
module = builder_module()
- if not module.cleanup():
- raise Exception("Don't know how to do cleanup")
+ module.cleanup()
# Subclass might have specific cleanup function defined.
if getattr(cls, "classCleanup", None):
@@ -1385,6 +1384,7 @@ class Base(unittest2.TestCase):
# initially. If the test errored/failed, the session info
# (self.session) is then dumped into a session specific file for
# diagnosis.
+ self.__cleanup_errored__ = False
self.__errored__ = False
self.__failed__ = False
self.__expected__ = False
@@ -1616,9 +1616,6 @@ class Base(unittest2.TestCase):
self.disableLogChannelsForCurrentTest()
- # Decide whether to dump the session info.
- self.dumpSessionInfo()
-
# =========================================================
# Various callbacks to allow introspection of test progress
# =========================================================
@@ -1631,6 +1628,14 @@ class Base(unittest2.TestCase):
# Once by the Python unittest framework, and a second time by us.
print >> sbuf, "ERROR"
+ def markCleanupError(self):
+ """Callback invoked when an error occurs while a test is cleaning up."""
+ self.__cleanup_errored__ = True
+ with recording(self, False) as sbuf:
+ # False because there's no need to write "CLEANUP_ERROR" to the stderr twice.
+ # Once by the Python unittest framework, and a second time by us.
+ print >> sbuf, "CLEANUP_ERROR"
+
def markFailure(self):
"""Callback invoked when a failure (test assertion failure) occurred."""
self.__failed__ = True
@@ -1729,6 +1734,9 @@ class Base(unittest2.TestCase):
if self.__errored__:
pairs = lldb.test_result.errors
prefix = 'Error'
+ if self.__cleanup_errored__:
+ pairs = lldb.test_result.cleanup_errors
+ prefix = 'CleanupError'
elif self.__failed__:
pairs = lldb.test_result.failures
prefix = 'Failure'
Modified: lldb/trunk/test/unittest2/case.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unittest2/case.py?rev=246063&r1=246062&r2=246063&view=diff
==============================================================================
--- lldb/trunk/test/unittest2/case.py (original)
+++ lldb/trunk/test/unittest2/case.py Wed Aug 26 14:44:56 2015
@@ -383,9 +383,11 @@ class TestCase(unittest.TestCase):
try:
self.tearDown()
except Exception:
- result.addError(self, sys.exc_info())
+ result.addCleanupError(self, sys.exc_info())
success = False
+ self.dumpSessionInfo()
+
cleanUpSuccess = self.doCleanups()
success = success and cleanUpSuccess
if success:
Modified: lldb/trunk/test/unittest2/result.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unittest2/result.py?rev=246063&r1=246062&r2=246063&view=diff
==============================================================================
--- lldb/trunk/test/unittest2/result.py (original)
+++ lldb/trunk/test/unittest2/result.py Wed Aug 26 14:44:56 2015
@@ -42,6 +42,7 @@ class TestResult(unittest.TestResult):
self.failures = []
self.passes = []
self.errors = []
+ self.cleanup_errors = []
self.testsRun = 0
self.skipped = []
self.expectedFailures = []
@@ -109,6 +110,13 @@ class TestResult(unittest.TestResult):
self.errors.append((test, self._exc_info_to_string(err, test)))
self._mirrorOutput = True
+ def addCleanupError(self, test, err):
+ """Called when an error has occurred during cleanup. 'err' is a tuple of
+ values as returned by sys.exc_info().
+ """
+ self.cleanup_errors.append((test, self._exc_info_to_string(err, test)))
+ self._mirrorOutput = True
+
@failfast
def addFailure(self, test, err):
"""Called when an error has occurred. 'err' is a tuple of values as
More information about the lldb-commits
mailing list