Skip to content

Commit

Permalink
[android] Handle non-existent gtest XML result file.
Browse files Browse the repository at this point in the history
Bug: 765673
Change-Id: Icb0dcc89e2898f7a03c6558aa4ff07eef9508ac6
Reviewed-on: https://chromium-review.googlesource.com/668796
Reviewed-by: Benjamin Pastene <bpastene@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502382}
  • Loading branch information
jbudorick authored and Commit Bot committed Sep 15, 2017
1 parent 517d415 commit 79cd156
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion build/android/pylib/gtest/gtest_test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ def handle_possibly_unknown_test():
def ParseGTestXML(xml_content):
"""Parse gtest XML result."""
results = []
if not xml_content:
return 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']
Expand Down
4 changes: 4 additions & 0 deletions build/android/pylib/gtest/gtest_test_instance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ def testParseGTestOutput_deathTestCrashOk(self):
self.assertEquals(1, actual[0].GetDuration())
self.assertEquals(base_test_result.ResultType.PASS, actual[0].GetType())

def testParseGTestXML_none(self):
actual = gtest_test_instance.ParseGTestXML(None)
self.assertEquals([], actual)

def testConvertTestFilterFile_commentsAndBlankLines(self):
input_lines = [
'positive1',
Expand Down
13 changes: 10 additions & 3 deletions build/android/pylib/local/device/local_device_gtest_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,16 @@ def _RunTest(self, device, test):
timeout=timeout, retries=0)

if self._test_instance.enable_xml_result_parsing:
gtest_xml = device.ReadFile(
device_tmp_results_file.name,
as_root=True)
try:
gtest_xml = device.ReadFile(
device_tmp_results_file.name,
as_root=True)
except device_errors.CommandFailedError as e:
logging.warning(
'Failed to pull gtest results XML file %s: %s',
device_tmp_results_file.name,
str(e))
gtest_xml = None

for s in self._servers[str(device)]:
s.Reset()
Expand Down

0 comments on commit 79cd156

Please sign in to comment.