Make the lldbtest tear down routine a little less error prone
authorDaniel Malea <daniel.malea@intel.com>
Fri, 22 Feb 2013 00:41:26 +0000 (00:41 +0000)
committerDaniel Malea <daniel.malea@intel.com>
Fri, 22 Feb 2013 00:41:26 +0000 (00:41 +0000)
- replace "catch-all" except clause with one that specifically catches what pexpect throws
- handle case where child is already terminated (or is terminating) by the time tear-down is run

llvm-svn: 175844

lldb/test/lldbtest.py

index a1a3864..d45e6d4 100644 (file)
@@ -777,15 +777,17 @@ class Base(unittest2.TestCase):
         if self.child and self.child.isalive():
             with recording(self, traceAlways) as sbuf:
                 print >> sbuf, "tearing down the child process...."
-            if self.child_in_script_interpreter:
-                self.child.sendline('quit()')
-                self.child.expect_exact(self.child_prompt)
-            self.child.sendline('settings set interpreter.prompt-on-quit false')
-            self.child.sendline('quit')
             try:
+                if self.child_in_script_interpreter:
+                    self.child.sendline('quit()')
+                    self.child.expect_exact(self.child_prompt)
+                self.child.sendline('settings set interpreter.prompt-on-quit false')
+                self.child.sendline('quit')
                 self.child.expect(pexpect.EOF)
-            except:
+            except ValueError, ExceptionPexpect:
+                # child is already terminated
                 pass
+
             # Give it one final blow to make sure the child is terminated.
             self.child.close()