Skip to content

desktop_tester.py: some random improvements to help with debugging failed runs #1027

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

Merged
merged 4 commits into from
Jul 19, 2022
Merged
Changes from 3 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
26 changes: 20 additions & 6 deletions scripts/gha/desktop_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

import os
import platform
import shlex
import subprocess
import time
import threading

from absl import app
Expand Down Expand Up @@ -104,28 +106,40 @@ class Test(object):
# them as fields so they can be accessed from the main thread.
def run(self):
"""Executes this testapp."""
result = None # Ensures this var is defined if timeout occurs.
os.chmod(self.testapp_path, 0o777)
args = list(shlex.split(FLAGS.cmd_prefix)) + [self.testapp_path]
args_str = subprocess.list2cmdline(args)
logging.info("Test starting: %s", args_str)
start_time_secs = time.monotonic()
try:
result = subprocess.run(
args=FLAGS.cmd_prefix.split() + [self.testapp_path],
args=args,
cwd=os.path.dirname(self.testapp_path), # Testapp uses CWD for config
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
errors="replace",
check=False,
timeout=900)
except subprocess.TimeoutExpired as e:
logging.error("Testapp timed out!")
logging.error("Testapp timed out: %s", args_str)
# e.output will sometimes be bytes, sometimes string. Decode if needed.
try:
self.logs = e.output.decode()
except AttributeError: # This will happen if it's already a string.
self.logs = e.output
if result:
else:
self.logs = result.stdout
logging.info("Test result: %s", self.logs)
logging.info("Finished running %s", self.testapp_path)
logging.info(
"Test result of %s (exit code: %s): %s",
args_str, result.returncode, self.logs)

end_time_secs = time.monotonic()
elapsed_time_secs = end_time_secs - start_time_secs
elapsed_time_str = f"{elapsed_time_secs/60:.2f} minutes"
logging.info(
"Test completed (elapsed time: %s): %s",
elapsed_time_str, args_str)


if __name__ == "__main__":
Expand Down