[gnome-settings-daemon/benzea/ci-fixes] tests: Correctly handle EOF in OutputChecker
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/benzea/ci-fixes] tests: Correctly handle EOF in OutputChecker
- Date: Tue, 20 Jul 2021 11:43:15 +0000 (UTC)
commit da2046ae788712857edd83b45871bcf7ac215b71
Author: Benjamin Berg <bberg redhat com>
Date: Tue Jul 20 13:42:49 2021 +0200
tests: Correctly handle EOF in OutputChecker
tests/output_checker.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/tests/output_checker.py b/tests/output_checker.py
index 453d2698..c5ae2619 100644
--- a/tests/output_checker.py
+++ b/tests/output_checker.py
@@ -58,6 +58,9 @@ class OutputChecker(object):
r = os.read(self._pipe_fd_r, 1024)
if not r:
+ os.close(self._pipe_fd_r)
+ self._pipe_fd_r = -1
+ self._lines_sem.release()
return
except OSError as e:
if e.errno == errno.EWOULDBLOCK:
@@ -88,6 +91,13 @@ class OutputChecker(object):
try:
l = self._lines.pop(0)
except IndexError:
+ # EOF, throw error
+ if self._pipe_fd_r == -1:
+ if failmsg:
+ raise AssertionError("No further messages: " % failmsg)
+ else:
+ raise AssertionError('No client waiting for needle %s' % (str(needle_re)))
+
# Check if should wake up
if not self._lines_sem.acquire(timeout = deadline - time.time()):
if failmsg:
@@ -121,6 +131,10 @@ class OutputChecker(object):
try:
l = self._lines.pop(0)
except IndexError:
+ # EOF, so everything good
+ if self._pipe_fd_r == -1:
+ break
+
# Check if should wake up
if not self._lines_sem.acquire(timeout = deadline - time.time()):
# Timed out, so everything is good
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]