Clean up the teardown logic to make it more robust and to record the additions and

invocations of them into session object.

Remove a debug statement.

llvm-svn: 116938
This commit is contained in:
Johnny Chen 2010-10-20 18:12:58 +00:00
parent f0888a3e8c
commit bf45719408
1 changed files with 8 additions and 4 deletions

View File

@ -475,7 +475,11 @@ class TestBase(unittest2.TestCase):
Hooks are executed in a first come first serve manner.
"""
self.hooks.append(hook)
if callable(hook):
with recording(self, traceAlways) as sbuf:
import inspect
print >> sbuf, "Adding tearDown hook:", inspect.getsource(hook)
self.hooks.append(hook)
def tearDown(self):
#import traceback
@ -483,11 +487,11 @@ class TestBase(unittest2.TestCase):
# Check and run any hook functions.
for hook in self.hooks:
#print "Executing hook:", hook
with recording(self, traceAlways) as sbuf:
import inspect
print >> sbuf, "Executing tearDown hook:", inspect.getsource(hook)
hook()
self.runCmd("settings show")
# Terminate the current process being debugged, if any.
if self.runStarted:
self.runCmd("process kill", PROCESS_KILLED, check=False)