Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the run_tests.py terminated with exception when timeout occurs. #3488

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions demos/tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ def option_to_args(key, value):
exit_msg = f'Exit code: {e.returncode}\n'
elif isinstance(e, subprocess.TimeoutExpired):
exit_msg = f'Command timed out after {e.timeout} seconds\n'
output += exit_msg
print(output)
print('{}\n{}'.format(output, exit_msg))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output var is used to save log file below: write_log(output, args.log_file). So you need this output += exit_msg.

If I understand correctly, TimeoutExpired.output is of bytes type for you. Maybe you can cast it to str before that +=

Please, add a comment to code with link to a bug https://bugs.python.org/issue43431 to explain why we have such cast.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, TimeoutExpired.output is of bytes type for you. Maybe you can cast it to str before that +=

Yes, you are right. output var is bytes type under that host env when timeout happened. While don't know why the output is Str type on my host when timeout happened.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the bug. It appears on python3.8+ may be you have python3.7 or 3.6 on your host

failed_tests.append(test_descr + '\n' + exit_msg)
num_failures += 1
execution_time = -1
Expand Down