Index: build/android/pylib/local/device/local_device_gtest_run.py |
diff --git a/build/android/pylib/local/device/local_device_gtest_run.py b/build/android/pylib/local/device/local_device_gtest_run.py |
index caef0548d2daf93f7dc392449f7d935df0851632..4413e84b0dde28ee986f3648a05bfc55b8182bd1 100644 |
--- a/build/android/pylib/local/device/local_device_gtest_run.py |
+++ b/build/android/pylib/local/device/local_device_gtest_run.py |
@@ -19,6 +19,7 @@ from pylib.local.device import local_device_test_run |
_COMMAND_LINE_FLAGS_SUPPORTED = True |
+_MAX_INLINE_FLAGS_LENGTH = 50 # Arbitrarily chosen. |
_EXTRA_COMMAND_LINE_FILE = ( |
'org.chromium.native_test.NativeTestActivity.CommandLineFile') |
_EXTRA_COMMAND_LINE_FLAGS = ( |
@@ -26,6 +27,9 @@ _EXTRA_COMMAND_LINE_FLAGS = ( |
_EXTRA_TEST_LIST = ( |
'org.chromium.native_test.NativeTestInstrumentationTestRunner' |
'.TestList') |
+_EXTRA_TEST = ( |
+ 'org.chromium.native_test.NativeTestInstrumentationTestRunner' |
+ '.Test') |
_MAX_SHARD_SIZE = 256 |
_SECONDS_TO_NANOS = int(1e9) |
@@ -121,21 +125,35 @@ class _ApkDelegate(object): |
extras[gtest_test_instance.EXTRA_SHARD_NANO_TIMEOUT] = int( |
kwargs['timeout'] * _SECONDS_TO_NANOS) |
- with device_temp_file.DeviceTempFile(device.adb) as command_line_file: |
- device.WriteFile(command_line_file.name, '_ %s' % flags if flags else '_') |
- extras[_EXTRA_COMMAND_LINE_FILE] = command_line_file.name |
- |
- with device_temp_file.DeviceTempFile(device.adb) as test_list_file: |
- if test: |
- device.WriteFile(test_list_file.name, '\n'.join(test)) |
- extras[_EXTRA_TEST_LIST] = test_list_file.name |
- |
- try: |
- return device.StartInstrumentation( |
- self._component, extras=extras, raw=False, **kwargs) |
- except Exception: |
- device.ForceStop(self._package) |
- raise |
+ command_line_file = None |
jbudorick
2015/10/20 17:41:23
I'll be honest, this is a lot messier than the pre
agrieve
2015/10/20 18:36:55
Did some googling and came up with:
https://docs.p
|
+ if flags: |
+ if len(flags) > _MAX_INLINE_FLAGS_LENGTH: |
+ command_line_file = device_temp_file.DeviceTempFile(device.adb) |
+ device.WriteFile(command_line_file.name, '_ %s' % flags) |
+ extras[_EXTRA_COMMAND_LINE_FILE] = command_line_file.name |
+ else: |
+ extras[_EXTRA_COMMAND_LINE_FLAGS] = flags |
+ |
+ test_list_file = None |
+ if test: |
+ if len(test) > 1: |
+ test_list_file = device_temp_file.DeviceTempFile(device.adb) |
+ device.WriteFile(test_list_file.name, '\n'.join(test)) |
+ extras[_EXTRA_TEST_LIST] = test_list_file.name |
+ else: |
+ extras[_EXTRA_TEST] = test[0] |
+ |
+ try: |
+ return device.StartInstrumentation( |
+ self._component, extras=extras, raw=False, **kwargs) |
+ except Exception: |
+ device.ForceStop(self._package) |
+ raise |
+ finally: |
+ if command_line_file: |
+ command_line_file.close() |
+ if test_list_file: |
+ test_list_file.close() |
def PullAppFiles(self, device, files, directory): |
PullAppFilesImpl(device, self._package, files, directory) |