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

Swaps deprecated instruments cli out for xctrace #21952

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions fastlane_core/lib/fastlane_core/device_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ def connected_devices(requested_os_type)

discover_devices(result[0], device_types, device_uuids) if result[0]

if device_uuids.count > 0 # instruments takes a little while to return so skip it if we have no devices
instruments_devices_output = ''
Open3.popen3("instruments -s devices") do |stdin, stdout, stderr, wait_thr|
instruments_devices_output = stdout.read
if device_uuids.count > 0 # xctrace takes a little while to return so skip it if we have no devices
xctrace_devices_output = ''
Open3.popen3("xctrace list devices") do |stdin, stdout, stderr, wait_thr|
xctrace_devices_output = stdout.read
end

instruments_devices_output.split(/\n/).each do |instruments_device|
xctrace_devices_output.split(/\n/).each do |xctrace_device|
device_uuids.each do |device_uuid|
match = instruments_device.match(/(.+) \(([0-9.]+)\) \[(\h{40}|\h{8}-\h{16})\]?/)
match = xctrace_device.match(/(.+) \(([0-9.]+)\) \((\h{40}|\h{8}-\h{16})\)?/)
if match && match[3].delete("-") == device_uuid
devices << Device.new(name: match[1], udid: match[3], os_type: requested_os_type, os_version: match[2], state: "Booted", is_simulator: false)
UI.verbose("USB Device Found - \"" + match[1] + "\" (" + match[2] + ") UUID:" + match[3])
Expand Down
26 changes: 13 additions & 13 deletions fastlane_core/spec/device_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
before(:all) do
@simctl_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerSimctlOutputXcode7')
@system_profiler_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerSystem_profilerOutput')
@instruments_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerInstrumentsOutput')
@xctrace_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerXCTraceOutput')
@system_profiler_output_items_without_items = File.read('./fastlane_core/spec/fixtures/DeviceManagerSystem_profilerOutputItemsWithoutItems')
@system_profiler_output_usb_hub = File.read('./fastlane_core/spec/fixtures/DeviceManagerSystem_profilerOutputUsbHub')

Expand Down Expand Up @@ -284,13 +284,13 @@
)
end

it "properly parses system_profiler and instruments output and generates Device objects for iOS" do
it "properly parses system_profiler and xctrace output and generates Device objects for iOS" do
response = "response"
expect(response).to receive(:read).and_return(@system_profiler_output)
expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil)

expect(response).to receive(:read).and_return(@instruments_output)
expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil)
expect(response).to receive(:read).and_return(@xctrace_output)
expect(Open3).to receive(:popen3).with("xctrace list devices").and_yield(nil, response, nil, nil)

devices = FastlaneCore::DeviceManager.connected_devices('iOS')
expect(devices.count).to eq(2)
Expand Down Expand Up @@ -324,8 +324,8 @@
expect(response).to receive(:read).and_return(@system_profiler_output_usb_hub)
expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil)

expect(response).to receive(:read).and_return(@instruments_output)
expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil)
expect(response).to receive(:read).and_return(@xctrace_output)
expect(Open3).to receive(:popen3).with("xctrace list devices").and_yield(nil, response, nil, nil)

devices = FastlaneCore::DeviceManager.connected_devices('iOS')
expect(devices.count).to eq(1)
Expand All @@ -337,13 +337,13 @@
)
end

it "properly parses system_profiler and instruments output and generates Device objects for tvOS" do
it "properly parses system_profiler and xctrace output and generates Device objects for tvOS" do
response = "response"
expect(response).to receive(:read).and_return(@system_profiler_output)
expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil)

expect(response).to receive(:read).and_return(@instruments_output)
expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil)
expect(response).to receive(:read).and_return(@xctrace_output)
expect(Open3).to receive(:popen3).with("xctrace list devices").and_yield(nil, response, nil, nil)

devices = FastlaneCore::DeviceManager.connected_devices('tvOS')
expect(devices.count).to eq(1)
Expand All @@ -361,8 +361,8 @@
expect(response).to receive(:read).and_return(@system_profiler_output)
expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil)

expect(response).to receive(:read).and_return(@instruments_output)
expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil)
expect(response).to receive(:read).and_return(@xctrace_output)
expect(Open3).to receive(:popen3).with("xctrace list devices").and_yield(nil, response, nil, nil)

expect(response).to receive(:read).and_return(@simctl_output)
expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil)
Expand Down Expand Up @@ -413,8 +413,8 @@
expect(response).to receive(:read).and_return(@system_profiler_output)
expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil)

expect(response).to receive(:read).and_return(@instruments_output)
expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil)
expect(response).to receive(:read).and_return(@xctrace_output)
expect(Open3).to receive(:popen3).with("xctrace list devices").and_yield(nil, response, nil, nil)

expect(response).to receive(:read).and_return(@simctl_output)
expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil)
Expand Down
19 changes: 0 additions & 19 deletions fastlane_core/spec/fixtures/DeviceManagerInstrumentsOutput

This file was deleted.

22 changes: 22 additions & 0 deletions fastlane_core/spec/fixtures/DeviceManagerXCTraceOutput
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
== Devices ==
Matthew’s MacBook Pro (38463BD9-FFFF-FFFF-FFFF-6C3219E6206E)
Matthew's iPhone (9.3) (f0f9f44e7c2dafbae53d1a83fe27c37418ffffff)
Matthew's Apple TV (9.1) (82f1fb5c8362ee9eb89a9c2c6829fa0563ffffff)

== Simulators ==
Apple TV 1080p (9.1) (4665DCBE-62C5-41A5-8026-A9F412DAED90)
iPad 2 (9.2) (5A76D586-71E4-4FF0-9384-5C9DCAD7B7FA)
iPad Air (9.2) (E86F2C01-87E2-45CD-A313-F403D2CCF47D)
iPad Air 2 (9.2) (6B0FA29E-E265-4239-BFE2-A4FF29544B03)
iPad Pro (9.2) (53FF055F-7297-40A7-8BF1-1638BC39DE11)
iPad Retina (9.2) (EAA26E29-5757-435F-A02A-3E878A479121)
iPhone 4s (9.2) (D447C6D3-3B08-4511-853E-2E7AE122B1DD)
iPhone 5 (9.2) (0C5336B1-FA0C-4D0D-9771-E14895743645)
iPhone 5s (9.2) (E5408FEB-320D-442A-A136-063D28B746AA)
iPhone 6 (9.2) (FBAD834B-0AD1-44D4-BA15-EF4A6DEB5AF5)
iPhone 6 Plus (9.2) (38463BD9-B894-450A-92DF-6C3219E6206E)
iPhone 6s (9.2) (3949A363-5369-49C9-9548-4CA9EE4C4024)
iPhone 6s (9.2) + Apple Watch - 38mm (2.1) (8D2E5D4F-B931-4DE8-8569-D38EA90010EE)
iPhone 6s Plus (9.2) (C793A9D9-47F8-4EAE-8410-C73083D05DAC)
iPhone 6s Plus (9.2) + Apple Watch - 42mm (2.1) (9E67145F-A0DF-4D61-8C98-B2A791A0951A)
iPhone XS Max (12.0) (00008020-0006302A0CFFFFFF)