Skip to content

Commit 05abcdf

Browse files
committed
WIP: bag of commits from the boat - POP
1 parent 395867a commit 05abcdf

File tree

4 files changed

+69
-11
lines changed

4 files changed

+69
-11
lines changed

Guardfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ end
1313
guard :rspec, cmd: 'bundle exec rspec', spec_paths: ['spec/lib'] do
1414
watch(%r{^spec/.+_spec\.rb$})
1515
watch(%r{^lib/run_loop/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
16-
watch(%r{^lib/run_loop/bin/(.+)\.rb$}) { |m| "spec/lib/bin/#{m[1]}_spec.rb" }
16+
#watch(%r{^lib/run_loop/bin/(.+)\.rb$}) { |m| "spec/lib/bin/#{m[1]}_spec.rb" }
1717
watch('lib/run_loop.rb') { 'spec/lib' }
1818
watch('spec/spec_helper.rb') { 'spec/lib' }
1919
watch('spec/resources.rb') { 'spec/lib' }

lib/run_loop/cli/simctl.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def install
133133
def expect_device(options)
134134
device = nil
135135
device_from_options = options[:device]
136-
simulators = RunLoop::SimControl.new.simulators
136+
simulators = sim_control.simulators
137137
if device_from_options.nil?
138138
default_name = RunLoop::Core.default_simulator
139139
device = simulators.detect do |sim|

lib/run_loop/simctl/bridge.rb

+28-9
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ def reset_app_sandbox
131131
reset_app_sandbox_internal
132132
end
133133

134+
def install_uia_plists
135+
136+
end
137+
134138
def update_device_state(options={})
135139
merged_options = UPDATE_DEVICE_STATE_OPTS.merge(options)
136140

@@ -233,6 +237,15 @@ def app_is_installed?
233237
!fetch_app_dir.nil?
234238
end
235239

240+
# @!visibility private
241+
def fetch_app_dir
242+
sim_app_dir = device_applications_dir
243+
return nil if !File.exist?(sim_app_dir)
244+
Dir.glob("#{sim_app_dir}/**/*.app").detect(nil) do |path|
245+
RunLoop::App.new(path).bundle_identifier == app.bundle_identifier
246+
end
247+
end
248+
236249
def wait_for_app_install
237250
return true if app_is_installed?
238251

@@ -424,15 +437,6 @@ def fetch_matching_device
424437
end
425438
end
426439

427-
# @!visibility private
428-
def fetch_app_dir
429-
sim_app_dir = device_applications_dir
430-
return nil if !File.exist?(sim_app_dir)
431-
Dir.glob("#{sim_app_dir}/**/*.app").detect(nil) do |path|
432-
RunLoop::App.new(path).bundle_identifier == app.bundle_identifier
433-
end
434-
end
435-
436440
# @!visibility private
437441
def reset_app_sandbox_internal_shared
438442
[app_documents_dir, app_tmp_dir].each do |dir|
@@ -498,5 +502,20 @@ def reset_app_sandbox_internal
498502
reset_app_sandbox_internal_sdk_lt_8
499503
end
500504
end
505+
506+
# @!visibility private
507+
def app_uia_crash_logs
508+
base_dir = app_data_dir
509+
if base_dir.nil?
510+
nil
511+
else
512+
dir = File.join(base_dir, 'Library', 'CrashReporter', 'UIALogs')
513+
if Dir.exist?(dir)
514+
Dir.glob("#{dir}/*.plist")
515+
else
516+
nil
517+
end
518+
end
519+
end
501520
end
502521
end

spec/lib/cli/simctl_spec.rb

+39
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,43 @@
1919
expect(simctl.booted_device).to be == device
2020
end
2121
end
22+
23+
describe '#expect_device' do
24+
describe 'default simulator' do
25+
it 'raises error if device cannot be created from default simulator' do
26+
expect(simctl.sim_control).to receive(:simulators).and_return([])
27+
expect {
28+
simctl.expect_device({})
29+
}.to raise_error RunLoop::CLI::ValidationError
30+
31+
end
32+
33+
it 'can create a device from default simulator' do
34+
expect(simctl.expect_device({})).to be_a_kind_of( RunLoop::Device)
35+
end
36+
end
37+
38+
describe 'when passed a UDID or instruments-ready simulator name' do
39+
let(:device) {
40+
Resources.shared.simulator_with_sdk_test(lambda { |_|
41+
true
42+
},
43+
simctl.sim_control)
44+
}
45+
46+
it 'UUID' do
47+
options = { :device => device.udid }
48+
expect(simctl.expect_device(options).udid).to be == device.udid
49+
end
50+
51+
it 'name' do
52+
53+
end
54+
55+
it 'raises error error if no match can be found' do
56+
57+
end
58+
59+
end
60+
end
2261
end

0 commit comments

Comments
 (0)