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

[BE-4993]: Added -legacy flag for xcode cli xcresulttool command #4

Open
wants to merge 6 commits into
base: feature/BE-4788
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
25 changes: 21 additions & 4 deletions xcode_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,36 @@ def execute_cmd(cmd)
output
end

def get_object(id = nil)
cmd = "xcrun xcresulttool get --format json --path #{@test_path}"
@@xcode_version = nil
def get_xcode_version
@@xcode_version ||= begin
output = execute_cmd("xcodebuild -version")
output.match(/Xcode (\d+(\.\d+)?)/)[1].to_f
end
end

def get_xcrun_command(cmd_func, id: nil, filename: nil, output_path: nil)
cmd = "xcrun xcresulttool #{cmd_func}"
cmd += " object --legacy" if get_xcode_version >= 16.0
cmd += " --format json" if cmd_func == "get"
cmd += " --path #{@test_path}"
cmd += " --id #{id}" if id
cmd += " --output-path '#{output_path}' --type file" if output_path
cmd
end

def get_object(id = nil)
cmd = get_xcrun_command("get", id: id)
raw_result = execute_cmd(cmd)
JSON.parse raw_result
JSON.parse(raw_result)
end

def extract_attachment(filename, id)
attachments_path = (Pathname.new @output_path).join('test_attachments')
FileUtils.mkdir_p(attachments_path) unless Dir.exist?(attachments_path)
output_path = File.join(attachments_path, filename)
puts "Exporting attachment #{filename}"
cmd = "xcrun xcresulttool export --path #{@test_path} --id '#{id}' --output-path '#{output_path}' --type file"
cmd = get_xcrun_command("export", id: id, output_path: output_path)
execute_cmd(cmd)
end

Expand Down