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

Unified Diff: build/android/test_runner.py

Issue 2593903002: [android] Use contextlib_ext.Optional for conditional context managers. (Closed)
Patch Set: rebase Created 4 years 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 | « build/android/pylib/local/device/local_device_perf_test_run.py ('k') | build/android/test_runner.pydeps » ('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 612060af416241d1b78e8039168a33095e5d7ed5..26d53b94a779456825cd9a2ee9d7742e9654c48c 100755
--- a/build/android/test_runner.py
+++ b/build/android/test_runner.py
@@ -39,6 +39,8 @@ from pylib.linker import setup as linker_setup
from pylib.results import json_results
from pylib.results import report_results
+from py_utils import contextlib_ext
+
_DEVIL_STATIC_CONFIG_FILE = os.path.abspath(os.path.join(
host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'devil_config.json'))
@@ -739,20 +741,16 @@ def RunTestsInPlatformMode(args):
all_iteration_results = []
@contextlib.contextmanager
- def noop():
- yield
-
- json_writer = noop()
- if args.json_results_file:
- @contextlib.contextmanager
- def write_json_file():
- try:
- yield
- finally:
- json_results.GenerateJsonResultsFile(
- all_raw_results, args.json_results_file)
-
- json_writer = write_json_file()
+ def write_json_file():
+ try:
+ yield
+ finally:
+ json_results.GenerateJsonResultsFile(
+ all_raw_results, args.json_results_file)
+
+ json_writer = contextlib_ext.Optional(
+ write_json_file(),
+ args.json_results_file)
### Set up test objects.
« no previous file with comments | « build/android/pylib/local/device/local_device_perf_test_run.py ('k') | build/android/test_runner.pydeps » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698