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

Unified Diff: build/android/pylib/gtest/gtest_test_instance.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 | « no previous file | build/android/pylib/local/device/local_device_gtest_run.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/gtest/gtest_test_instance.py
diff --git a/build/android/pylib/gtest/gtest_test_instance.py b/build/android/pylib/gtest/gtest_test_instance.py
index dcb7c11d580fccf23a1a7c96ef0be23eedaba75b..8858297a70f0b3765ca46e562a151c914d4166ad 100644
--- a/build/android/pylib/gtest/gtest_test_instance.py
+++ b/build/android/pylib/gtest/gtest_test_instance.py
@@ -2,10 +2,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import HTMLParser
import logging
import os
import re
import tempfile
+import xml.etree.ElementTree
from devil.android import apk_helper
from pylib import constants
@@ -169,6 +171,33 @@ def ParseGTestOutput(output):
return results
+def ParseGTestXML(xml_content):
+ """Parse gtest XML result."""
+ results = []
+
+ html = HTMLParser.HTMLParser()
+
+ # TODO(jbudorick): Unclear how this handles crashes.
+ testsuites = xml.etree.ElementTree.fromstring(xml_content)
+ for testsuite in testsuites:
+ suite_name = testsuite.attrib['name']
+ for testcase in testsuite:
+ case_name = testcase.attrib['name']
+ result_type = base_test_result.ResultType.PASS
+ log = []
+ for failure in testcase:
+ result_type = base_test_result.ResultType.FAIL
+ log.append(html.unescape(failure.attrib['message']))
+
+ results.append(base_test_result.BaseTestResult(
+ '%s.%s' % (suite_name, case_name),
+ result_type,
+ int(float(testcase.attrib['time']) * 1000),
+ log=('\n'.join(log) if log else '')))
+
+ return results
+
+
class GtestTestInstance(test_instance.TestInstance):
def __init__(self, args, isolate_delegate, error_func):
@@ -251,6 +280,9 @@ class GtestTestInstance(test_instance.TestInstance):
self._test_arguments = args.test_arguments
+ # TODO(jbudorick): Remove this once it's deployed.
+ self._enable_xml_result_parsing = args.enable_xml_result_parsing
+
@property
def activity(self):
return self._apk_helper and self._apk_helper.GetActivityName()
@@ -272,6 +304,10 @@ class GtestTestInstance(test_instance.TestInstance):
return self._app_data_files
@property
+ def enable_xml_result_parsing(self):
+ return self._enable_xml_result_parsing
+
+ @property
def exe_dist_dir(self):
return self._exe_dist_dir
« no previous file with comments | « no previous file | build/android/pylib/local/device/local_device_gtest_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698