For a test with unexpected success status, we also dump its session info into a unique file.

llvm-svn: 131011
This commit is contained in:
Johnny Chen 2011-05-06 20:30:22 +00:00
parent d5a7bfc51d
commit 44932b6805
2 changed files with 32 additions and 8 deletions

View File

@ -812,7 +812,8 @@ if not sdir_name:
sdir_name = timestamp sdir_name = timestamp
os.environ["LLDB_SESSION_DIRNAME"] = sdir_name os.environ["LLDB_SESSION_DIRNAME"] = sdir_name
sys.stderr.write("\nSession logs for test failures/errors will go into directory '%s'\n" % sdir_name) sys.stderr.write("\nSession logs for test failures/errors/unexpected successes"
" will go into directory '%s'\n" % sdir_name)
sys.stderr.write("Command invoked: %s\n" % getMyCommandLine()) sys.stderr.write("Command invoked: %s\n" % getMyCommandLine())
# #
@ -979,6 +980,14 @@ for ia in range(len(archs) if iterArchs else 1):
if method: if method:
method() method()
def addUnexpectedSuccess(self, test):
global sdir_has_content
sdir_has_content = True
super(LLDBTestResult, self).addUnexpectedSuccess(test)
method = getattr(test, "markUnexpectedSuccess", None)
if method:
method()
# Invoke the test runner. # Invoke the test runner.
if count == 1: if count == 1:
result = unittest2.TextTestRunner(stream=sys.stderr, result = unittest2.TextTestRunner(stream=sys.stderr,
@ -998,7 +1007,8 @@ for ia in range(len(archs) if iterArchs else 1):
if sdir_has_content: if sdir_has_content:
sys.stderr.write("Session logs for test failures/errors can be found in directory '%s'\n" % sdir_name) sys.stderr.write("Session logs for test failures/errors/unexpected successes"
" can be found in directory '%s'\n" % sdir_name)
# Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined. # Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
# This should not be necessary now. # This should not be necessary now.

View File

@ -566,6 +566,8 @@ class TestBase(unittest2.TestCase):
self.__errored__ = False self.__errored__ = False
self.__failed__ = False self.__failed__ = False
self.__expected__ = False self.__expected__ = False
# We are also interested in unexpected success.
self.__unexpected__ = False
# See addTearDownHook(self, hook) which allows the client to add a hook # See addTearDownHook(self, hook) which allows the client to add a hook
# function to be run during tearDown() time. # function to be run during tearDown() time.
@ -599,6 +601,15 @@ class TestBase(unittest2.TestCase):
# Once by the Python unittest framework, and a second time by us. # Once by the Python unittest framework, and a second time by us.
print >> sbuf, "expected failure" print >> sbuf, "expected failure"
def markUnexpectedSuccess(self):
"""Callback invoked when an unexpected success occurred."""
self.__unexpected__ = True
with recording(self, False) as sbuf:
# False because there's no need to write "unexpected success" to the
# stderr twice.
# Once by the Python unittest framework, and a second time by us.
print >> sbuf, "unexpected success"
def dumpSessionInfo(self): def dumpSessionInfo(self):
""" """
Dump the debugger interactions leading to a test error/failure. This Dump the debugger interactions leading to a test error/failure. This
@ -628,10 +639,13 @@ class TestBase(unittest2.TestCase):
elif self.__expected__: elif self.__expected__:
pairs = lldb.test_result.expectedFailures pairs = lldb.test_result.expectedFailures
prefix = 'ExpectedFailure' prefix = 'ExpectedFailure'
elif self.__unexpected__:
prefix = "UnexpectedSuccess"
else: else:
# Simply return, there's no session info to dump! # Simply return, there's no session info to dump!
return return
if not self.__unexpected__:
for test, traceback in pairs: for test, traceback in pairs:
if test is self: if test is self:
print >> self.session, traceback print >> self.session, traceback