Skip to content

Commit

Permalink
Fixing failed device tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ark-konopacki committed May 23, 2016
1 parent fc369cf commit cac3abd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
33 changes: 19 additions & 14 deletions lib/run_loop/detect_aut/xcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ def find_xcodeproj
# @!visibility private
def self.find_user_state_file
username = RunLoop::Environment.username
xcworkspace = RunLoop::Environment.xcodeproj.gsub("xcodeproj", "xcworkspace")
file = Dir.glob("#{xcworkspace}/xcuserdata/#{username}.xcuserdatad/UserInterfaceState.xcuserstate")
if !file.nil? && file.is_a?(Array)
return file[0]
xcworkspace = RunLoop::Environment.xcodeproj
unless xcworkspace.nil?
xcworkspace = xcworkspace.gsub("xcodeproj", "xcworkspace")
file = Dir.glob("#{xcworkspace}/xcuserdata/#{username}.xcuserdatad/UserInterfaceState.xcuserstate")
if !file.nil? && file.is_a?(Array)
return file[0]
end
end
end

Expand Down Expand Up @@ -156,22 +159,24 @@ def xcode_preferences_plist
end

# @!visibility private
def self.pbuddy
def pbuddy
@pbuddy ||= RunLoop::PlistBuddy.new
end

# @!visibility private
def self.detect_selected_device
file_name = find_user_state_file
selected_device = @pbuddy.plist_find_device(file_name)

udid = selected_device.split(':')[1]
selected_device = RunLoop::Device.device_with_identifier(udid)
#TODO now only returning detected device if simulator detected
if selected_device.simulator?
selected_device
else
nil
pbuddy ||= RunLoop::PlistBuddy.new
selected_device = pbuddy.plist_find_device(file_name)
if selected_device != '' && !selected_device.nil?
udid = selected_device.split(':')[1]
selected_device = RunLoop::Device.device_with_identifier(udid)
#TODO now only returning detected device if simulator detected
if selected_device.simulator?
selected_device
else
nil
end
end
end
end
Expand Down
9 changes: 7 additions & 2 deletions lib/run_loop/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,13 @@ def self.device_with_identifier(udid_or_name, options={})
# @raise [ArgumentError] If DEVICE_TARGET or options specify an identifier
# that does not match an iOS Simulator or physical device.
def self.detect_device(options, xcode, simctl, instruments)
device = RunLoop::DetectAUT::Xcode.detect_selected_device ||
self.device_from_opts_or_env(options)
detected_device = RunLoop::DetectAUT::Xcode.detect_selected_device
if detected_device.is_a?(RunLoop::Device)
device = detected_device
else
device = self.device_from_opts_or_env(options)
end


# Passed an instance of RunLoop::Device
return device if device && device.is_a?(RunLoop::Device)
Expand Down

0 comments on commit cac3abd

Please sign in to comment.