test: put tty in blocking mode after test
Tests can leave the tty in non-blocking mode. If the test runner tries to print to stdout/stderr after that and the tty buffer is full, it'll die with a EAGAIN OSError. Ergo, put the tty back in blocking mode before proceeding.
This commit is contained in:
parent
4e1a2f9a89
commit
fa3bfc3a66
@ -400,10 +400,20 @@ class TestCase(object):
|
|||||||
|
|
||||||
def Run(self):
|
def Run(self):
|
||||||
self.BeforeRun()
|
self.BeforeRun()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = self.RunCommand(self.GetCommand())
|
result = self.RunCommand(self.GetCommand())
|
||||||
finally:
|
finally:
|
||||||
self.AfterRun(result)
|
# Tests can leave the tty in non-blocking mode. If the test runner
|
||||||
|
# tries to print to stdout/stderr after that and the tty buffer is
|
||||||
|
# full, it'll die with a EAGAIN OSError. Ergo, put the tty back in
|
||||||
|
# blocking mode before proceeding.
|
||||||
|
if sys.platform != 'win32':
|
||||||
|
from fcntl import fcntl, F_GETFL, F_SETFL
|
||||||
|
from os import O_NONBLOCK
|
||||||
|
for fd in 0,1,2: fcntl(fd, F_SETFL, ~O_NONBLOCK & fcntl(fd, F_GETFL))
|
||||||
|
|
||||||
|
self.AfterRun(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def Cleanup(self):
|
def Cleanup(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user