From f2941e018a31a6dc83c2b5aa110bd07f42eaa7f0 Mon Sep 17 00:00:00 2001 From: Juhani Puurula Date: Thu, 20 Dec 2018 10:27:19 +0200 Subject: [PATCH] Fix to unit test losing process output due to timing issue --- UNITTESTS/unit_test/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UNITTESTS/unit_test/utils.py b/UNITTESTS/unit_test/utils.py index fe41dc8158..0a26cc7111 100644 --- a/UNITTESTS/unit_test/utils.py +++ b/UNITTESTS/unit_test/utils.py @@ -51,8 +51,13 @@ def execute_program(args, error_msg="An error occurred!", success_msg=None): stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + # Output is stripped to remove newline character. logging adds its own + # so we avoid double newlines. + # Because the process can terminate before the loop has read all lines, + # we read the output remnant just in case. Otherwise we lose it. while process.poll() is None: - logging.info(process.stdout.readline().decode("utf8")) + logging.info(process.stdout.readline().decode('utf8').rstrip('\n')) + logging.info(process.stdout.read().decode('utf8').rstrip('\n')) retcode = process.wait()