Fix to unit test losing process output due to timing issue

pull/9208/head
Juhani Puurula 2018-12-20 10:27:19 +02:00 committed by Cruz Monrreal II
parent a332a90586
commit f2941e018a
1 changed files with 6 additions and 1 deletions

View File

@ -51,8 +51,13 @@ def execute_program(args, error_msg="An error occurred!", success_msg=None):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) 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: 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() retcode = process.wait()