Chromium Code Reviews| 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 72961708288aa54ea3b630a069d8788ebd00a2b3..9fca2b1636b1748ecfcf3123e634b771a6b8c4c9 100644 |
| --- a/build/android/pylib/local/device/local_device_gtest_run.py |
| +++ b/build/android/pylib/local/device/local_device_gtest_run.py |
| @@ -7,6 +7,7 @@ import itertools |
| import logging |
| import os |
| import posixpath |
| +import tempfile |
| from devil.android import device_errors |
| from devil.android import device_temp_file |
| @@ -19,8 +20,6 @@ from pylib.local import local_test_server_spawner |
| from pylib.local.device import local_device_environment |
| 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.NativeTest.CommandLineFile') |
| @@ -116,6 +115,9 @@ class _ApkDelegate(object): |
| device.Install(self._apk_helper, reinstall=True, |
| permissions=self._permissions) |
| + def ResultsDirectory(self, device): |
| + return device.GetApplicationDataDirectory(self._package) |
| + |
| def Run(self, test, device, flags=None, **kwargs): |
| extras = dict(self._extras) |
| @@ -175,6 +177,11 @@ class _ExeDelegate(object): |
| device.PushChangedFiles([(self._host_dist_dir, self._device_dist_dir)], |
| delete_device_stale=True) |
| + def ResultsDirectory(self, device): |
| + # pylint: disable=no-self-use |
| + # pylint: disable=unused-argument |
| + return constants.TEST_EXECUTABLE_DIR |
| + |
| def Run(self, test, device, flags=None, **kwargs): |
| tool = self._test_run.GetTool(device).GetTestWrapper() |
| if tool: |
| @@ -341,20 +348,35 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): |
| # Run the test. |
| timeout = (self._test_instance.shard_timeout |
| * self.GetTool(device).GetTimeoutScale()) |
| - output = self._delegate.Run( |
| - test, device, flags=self._test_instance.test_arguments, |
| - timeout=timeout, retries=0) |
| - for s in self._servers[str(device)]: |
| - s.Reset() |
| - if self._test_instance.app_files: |
| - self._delegate.PullAppFiles(device, self._test_instance.app_files, |
| - self._test_instance.app_file_dir) |
| - if not self._env.skip_clear_data: |
| - self._delegate.Clear(device) |
| - |
| - # Parse the output. |
| - # TODO(jbudorick): Transition test scripts away from parsing stdout. |
| - results = gtest_test_instance.ParseGTestOutput(output) |
| + flags = self._test_instance.test_arguments or '' |
| + with tempfile.NamedTemporaryFile(suffix='.xml') as host_tmp_results_file: |
| + with device_temp_file.DeviceTempFile( |
| + adb=device.adb, |
| + dir=self._delegate.ResultsDirectory(device), |
| + suffix='.xml') as device_tmp_results_file: |
| + flags += ' --gtest_output=xml:%s' % device_tmp_results_file.name |
|
rnephew (Reviews Here)
2016/09/23 14:10:51
Do we want this always on, or should we check for
jbudorick
2016/09/23 15:23:02
It works w/ the flag off, but it's unnecessary. I'
|
| + output = self._delegate.Run( |
| + test, device, flags=flags, |
| + timeout=timeout, retries=0) |
| + device.PullFile( |
| + device_tmp_results_file.name, |
| + host_tmp_results_file.name) |
| + |
| + for s in self._servers[str(device)]: |
| + s.Reset() |
| + if self._test_instance.app_files: |
| + self._delegate.PullAppFiles(device, self._test_instance.app_files, |
| + self._test_instance.app_file_dir) |
| + if not self._env.skip_clear_data: |
| + self._delegate.Clear(device) |
| + |
| + # Parse the output. |
| + # TODO(jbudorick): Transition test scripts away from parsing stdout. |
| + if self._test_instance.enable_xml_result_parsing: |
| + with open(host_tmp_results_file.name) as xml_results_file: |
| + results = gtest_test_instance.ParseGTestXML(xml_results_file.read()) |
| + else: |
| + results = gtest_test_instance.ParseGTestOutput(output) |
| # Check whether there are any crashed testcases. |
| self._crashes.update(r.GetName() for r in results |