Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1623)

Unified Diff: build/android/test_runner.py

Issue 2695963003: Use logdog butler subcommand to run tests. (Closed)
Patch Set: using context manager Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/test_wrapper/logdog_wrapper.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/test_runner.py
diff --git a/build/android/test_runner.py b/build/android/test_runner.py
index 08ec868e2b55155acc85e226f9088fae6134bda1..5bcbdc30cfd903a8d5d7713c6ba3093d5e2b8197 100755
--- a/build/android/test_runner.py
+++ b/build/android/test_runner.py
@@ -12,6 +12,7 @@ import contextlib
import itertools
import logging
import os
+import shutil
import signal
import sys
import threading
@@ -36,6 +37,7 @@ from pylib.base import test_run_factory
from pylib.constants import host_paths
from pylib.results import json_results
from pylib.results import report_results
+from pylib.utils import logdog_helper
from py_utils import contextlib_ext
@@ -115,6 +117,9 @@ def AddCommonOptions(parser):
help='Path to save test_runner trace data to. This option '
'has been implemented for gtest, instrumentation '
'test and perf test.')
+ group.add_argument('--upload-logcats-file', action='store_true',
+ dest='upload_logcats_file',
+ help='Whether to upload logcat file to logdog.')
logcat_output_group = group.add_mutually_exclusive_group()
logcat_output_group.add_argument(
@@ -709,6 +714,25 @@ def RunTestsInPlatformMode(args):
write_json_file(),
args.json_results_file)
+ @contextlib.contextmanager
+ def upload_logcats_file():
+ try:
+ yield
+ finally:
+ if not args.logcat_output_file:
+ logging.critical('Cannot upload logcats file. '
+ 'File to save logcat is not specified.')
+ else:
+ with open(args.logcat_output_file) as src:
jbudorick 2017/03/04 02:19:59 nit: this should eat and log any IOError it receiv
+ dst = logdog_helper.open_text('unified_logcats')
+ if dst:
+ with open(dst) as dst:
+ shutil.copyfileobj(src, dst)
+
+ logcats_uploader = contextlib_ext.Optional(
+ upload_logcats_file(),
+ args.upload_logcats_file)
+
### Set up test objects.
env = environment_factory.CreateEnvironment(args, infra_error)
@@ -718,7 +742,7 @@ def RunTestsInPlatformMode(args):
### Run.
- with json_writer, env, test_instance, test_run:
+ with json_writer, logcats_uploader, env, test_instance, test_run:
repetitions = (xrange(args.repeat + 1) if args.repeat >= 0
else itertools.count())
« no previous file with comments | « no previous file | build/android/test_wrapper/logdog_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698