Browse Source

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.
v0.9.6-release
Ben Noordhuis 12 years ago
parent
commit
fa3bfc3a66
  1. 10
      tools/test.py

10
tools/test.py

@ -400,9 +400,19 @@ 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:
# 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) self.AfterRun(result)
return result return result

Loading…
Cancel
Save