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

Unified Diff: build/android/pylib/local/device/local_device_gtest_run.py

Issue 2362143002: [Android] Add experimental gtest xml result handling. (Closed)
Patch Set: rnephew comments Created 4 years, 3 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 | « build/android/pylib/gtest/gtest_test_instance.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6679962e0617636355af2fec417c4677a3b7cde8 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,40 @@ 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)
+ 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 = self._test_instance.test_arguments or ''
+ if self._test_instance.enable_xml_result_parsing:
+ flags += ' --gtest_output=xml:%s' % device_tmp_results_file.name
+
+ output = self._delegate.Run(
+ test, device, flags=flags,
+ timeout=timeout, retries=0)
+
+ if self._test_instance.enable_xml_result_parsing:
+ 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
« no previous file with comments | « build/android/pylib/gtest/gtest_test_instance.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698