summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2024-02-05 16:19:12 +0000
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-02-05 17:29:11 +0000
commit5be4a0882bbc3765a0c1421ddd656e9776e4138d (patch)
tree467569bbae53741bc162b531dfea13a223679f56
parentc313906c6b07ff283f3365c8c02bb35fa58074a0 (diff)
Revert^2 "Support running run-tests under nohup"
This reverts commit 22503c540f74537562ef62e4552a043af6d53cf8. Reason for revert: Reland Bug: 319140709 Test: nohup ./art/test.py -b -r --host --optimizing 001 Change-Id: I0aa0ce6e50a3552924ef4cc3b3f47605b8aeb8c8
-rwxr-xr-xtest/testrunner/testrunner.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index 78f83deb34..14fd0ca469 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -81,6 +81,7 @@ import env
from target_config import target_config
from device_config import device_config
from typing import Dict, Set, List
+from functools import lru_cache
# TODO: make it adjustable per tests and for buildbots
#
@@ -717,6 +718,12 @@ def run_test(args, test, test_variant, test_name):
failed_tests.append((test_name, str(e)))
return (test_name, 'FAIL', ('%s\n%s\n\n') % (command, str(e)), datetime.timedelta())
+@lru_cache
+def get_console_width(default=100):
+ # NB: The command may fail if we are running under 'nohup'.
+ proc = subprocess.run(['stty', 'size'], capture_output=True)
+ return int(proc.stdout.decode("utf8").split()[1]) if proc.returncode == 0 else default
+
def print_test_info(test_count, test_name, result, failed_test_info="",
test_time=datetime.timedelta()):
"""Print the continous test information
@@ -738,8 +745,7 @@ def print_test_info(test_count, test_name, result, failed_test_info="",
# Without --verbose, the testrunner erases passing test info. It
# does that by overriding the printed text with white spaces all across
# the console width.
- console_width = int(os.popen('stty size', 'r').read().split()[1])
- info = '\r' + ' ' * console_width + '\r'
+ info = '\r' + ' ' * get_console_width() + '\r'
try:
percent = (test_count * 100) / total_test_count
progress_info = ('[ %d%% %d/%d ]') % (
@@ -778,7 +784,7 @@ def print_test_info(test_count, test_name, result, failed_test_info="",
total_output_length = 2 # Two spaces
total_output_length += len(progress_info)
total_output_length += len(result)
- allowed_test_length = console_width - total_output_length
+ allowed_test_length = get_console_width() - total_output_length
test_name_len = len(test_name)
if allowed_test_length < test_name_len:
test_name = ('...%s') % (
@@ -946,8 +952,7 @@ def print_analysis():
# Without --verbose, the testrunner erases passing test info. It
# does that by overriding the printed text with white spaces all across
# the console width.
- console_width = int(os.popen('stty size', 'r').read().split()[1])
- eraser_text = '\r' + ' ' * console_width + '\r'
+ eraser_text = '\r' + ' ' * get_console_width() + '\r'
print_text(eraser_text)
# Prints information about the total tests run.