Skip to content

Commit

Permalink
Merge pull request #9168 from JuhPuur/unittest_logging_fix
Browse files Browse the repository at this point in the history
Fix to unit test losing process output due to timing issue
  • Loading branch information
adbridge authored Dec 24, 2018
2 parents a8fa6ec + 039fbe7 commit 1d230c1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion UNITTESTS/unit_test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 1d230c1

Please sign in to comment.