Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix xcresulttool for Xcode 16 #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions xctestrunner/test_runner/xcresult_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import subprocess

from xctestrunner.shared import ios_errors
from xctestrunner.shared import xcode_info_util


def ExposeXcresult(xcresult_path, output_path):
Expand Down Expand Up @@ -50,11 +51,12 @@ def _ExposeDiagnostics(xcresult_path, output_path, action_result):
if 'diagnosticsRef' not in action_result:
return
diagnostics_id = action_result['diagnosticsRef']['id']['_value']
subprocess.check_call([
'xcrun', 'xcresulttool', 'export', '--path', xcresult_path,
'--output-path', output_path, '--type', 'directory', '--id',
diagnostics_id
export_command = _MakeXcresulttoolCommand([
'export', '--path', xcresult_path,
'--output-path', output_path, '--type', 'directory', '--id',
diagnostics_id
])
subprocess.check_call(export_command)


def _ExposeAttachments(xcresult_path, output_path, action_result):
Expand Down Expand Up @@ -90,11 +92,12 @@ def _ExposeAttachments(xcresult_path, output_path, action_result):
target_file_path = os.path.join(target_file_dir, file_name)

payload_ref_id = attachment['payloadRef']['id']['_value']
subprocess.check_call([
'xcrun', 'xcresulttool', 'export', '--path', xcresult_path,
'--output-path', target_file_path, '--type', 'file', '--id',
payload_ref_id
export_command = _MakeXcresulttoolCommand([
'export', '--path', xcresult_path,
'--output-path', target_file_path, '--type', 'file', '--id',
payload_ref_id
])
subprocess.check_call(export_command)


def _GetResultBundleObject(xcresult_path, bundle_id=None):
Expand All @@ -107,10 +110,9 @@ def _GetResultBundleObject(xcresult_path, bundle_id=None):
Returns:
A dict, result bundle object in json format.
"""
command = [
'xcrun', 'xcresulttool', 'get', '--format', 'json', '--path',
xcresult_path
]
command = _MakeXcresulttoolCommand([
'get', '--format', 'json', '--path', xcresult_path
])
if bundle_id:
command.extend(['--id', bundle_id])
return json.loads(subprocess.check_output(command).decode('utf-8'))
Expand All @@ -135,3 +137,17 @@ def _GetFailureTestRefs(test_summary):
summary_ref_id = test_summary['summaryRef']['id']['_value']
failure_test_refs.append(summary_ref_id)
return failure_test_refs

def _MakeXcresulttoolCommand(args):
"""Constructs xcresulttool command for selected Xcode version.
Args:
args: array, a list of arguments to pass to xcresulttool.
Returns:
The xcresulttool command.
"""
command = ['xcrun', 'xcresulttool'] + args
xcode_version = xcode_info_util.GetXcodeVersionNumber()
if xcode_version >= 1600:
command.extend(['--legacy'])
return command