Skip to content

Commit 36811c4

Browse files
committed
pexpect: Move error message out of drain_and_terminate()
1 parent c05fa2d commit 36811c4

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/pexpect_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ def terminate(self):
3838
self.child.terminate()
3939
self.wait_for_exit()
4040

41-
def drain_and_terminate(self, msg):
42-
logging.error(msg)
43-
41+
def drain_and_terminate(self):
4442
# Wait for the end of the oops, if it is one
4543
try:
4644
idx = self.child.expect(['--\[ end trace', pexpect.TIMEOUT], timeout=10)
@@ -53,7 +51,6 @@ def drain_and_terminate(self, msg):
5351
time.sleep(5)
5452

5553
self.terminate()
56-
raise Exception(msg)
5754

5855
def get_match(self, i=0):
5956
return self.child.match.group(i)
@@ -77,7 +74,10 @@ def expect(self, patterns, timeout=-1, bug_patterns=None):
7774
logging.debug("Matched: '%s' %s", self.get_match(), self.matches())
7875

7976
if idx >= len(patterns) - len(bug_patterns):
80-
self.drain_and_terminate("Error: saw oops/warning etc. while expecting")
77+
msg = "Error: saw oops/warning etc. while expecting"
78+
logging.error(msg)
79+
self.drain_and_terminate()
80+
raise Exception(msg)
8181

8282
return idx
8383

0 commit comments

Comments
 (0)