Commit 76697115 authored by Maksym Onufriienko's avatar Maksym Onufriienko Committed by Commit Bot

Extract DiagnosticData for Xc11.

Since XC11 new bundle file format to extract data need to use command
`xcresulttool export --type directory --id DIAGNOSTICS_REF
--output-path /export_folder --path ./RB.xcresult`

Data will be stored in %xcresult%_diagnostic folder

Bug: 978929
Change-Id: I1c7a76d24a88350409be8800bb9e3086af4d456d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761190Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Maksym Onufriienko <monufriienko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695421}
parent fed9c479
...@@ -183,7 +183,7 @@ class Xcode11LogParser(object): ...@@ -183,7 +183,7 @@ class Xcode11LogParser(object):
@staticmethod @staticmethod
def collect_test_results(xcresult, output): def collect_test_results(xcresult, output):
"""Gets test result data from xcresult. """Gets test result and diagnostic data from xcresult.
Args: Args:
xcresult: (str) A path to xcresult. xcresult: (str) A path to xcresult.
...@@ -224,6 +224,7 @@ class Xcode11LogParser(object): ...@@ -224,6 +224,7 @@ class Xcode11LogParser(object):
else: else:
test_results['failed'] = Xcode11LogParser._list_of_failed_tests(root) test_results['failed'] = Xcode11LogParser._list_of_failed_tests(root)
test_results['passed'] = Xcode11LogParser._list_of_passed_tests(xcresult) test_results['passed'] = Xcode11LogParser._list_of_passed_tests(xcresult)
Xcode11LogParser._export_diagnostic_data(xcresult + '.xcresult')
return test_results return test_results
@staticmethod @staticmethod
...@@ -250,6 +251,34 @@ class Xcode11LogParser(object): ...@@ -250,6 +251,34 @@ class Xcode11LogParser(object):
copy_screenshots_for_failed_test(failure_summary['message']['_value'], copy_screenshots_for_failed_test(failure_summary['message']['_value'],
test_case_folder) test_case_folder)
@staticmethod
def _export_diagnostic_data(xcresult):
"""Exports diagnostic data from xcresult to xcresult_diagnostic folder.
Since Xcode 11 format of result bundles changed, to get diagnostic data
need to run command below:
xcresulttool export --type directory --id DIAGNOSTICS_REF --output-path
./export_folder --path ./RB.xcresult
Args:
xcresult: (str) A path to xcresult directory.
"""
plist_path = os.path.join(xcresult, 'Info.plist')
if not (os.path.exists(xcresult) and os.path.exists(plist_path)):
return
root = json.loads(Xcode11LogParser._xcresulttool_get(xcresult))
try:
diagnostics_ref = root['actions']['_values'][0]['actionResult'][
'diagnosticsRef']['id']['_value']
export_command = ['xcresulttool', 'export',
'--type', 'directory',
'--id', diagnostics_ref,
'--path', xcresult,
'--output-path', '%s_diagnostic' % xcresult]
subprocess.check_output(export_command).strip()
except KeyError:
LOGGER.warn('Did not parse diagnosticsRef from %s!' % xcresult)
class XcodeLogParser(object): class XcodeLogParser(object):
"""Xcode log parser. Parses logs for Xcode until version 11.""" """Xcode log parser. Parses logs for Xcode until version 11."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment