run_loop 1.5.5 → 1.5.6.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2423db81abf3240a09a78b36e626e7fe9805e1b5
4
- data.tar.gz: 2c121c18d79c9faaab075f94dea364042aed23d0
3
+ metadata.gz: 47569b6d831b193444445ef4c1df372e89c51ddb
4
+ data.tar.gz: 5bfa5312c3d512c6175a53dba49cd3ade7759b4e
5
5
  SHA512:
6
- metadata.gz: 5be1f66ae222c299dd0bdd685c52c4860064fabe99f91610a166662a88adc5e52c7d61450a5abb96ecd2390fae7ee5116a31c7afc19a2592ca4cd804c7a0554c
7
- data.tar.gz: 523a6ab61c1090605b802dd5701f280d5ab033343093b42684af40de6952b143a43e70508e1aafdf1d379831ef1f7b1a9e27ae38b77f35fd9190cda8525766ca
6
+ metadata.gz: f03b8e29911c15d68e10a2f63a422ff475193e316d28c33cd8cea9de705cf338440126674cd5c81151b9e88868ed3c3583f94fd56d3351cc0521283a743bde97
7
+ data.tar.gz: 2affeeb8e17db2f0d7e21b6dcb34098ec0d6d445732aae798ddadd4d36b1d5d4f7ada9c57f9ca7ee7ec29006870b738c6865c5dc15f7d27fa1f939e61918993f
@@ -57,23 +57,14 @@ module RunLoop
57
57
  device = options[:device]
58
58
 
59
59
  if device
60
- device = expect_device(options)
61
- if debug
62
- RunLoop::Environment.with_debugging do
63
- launch_simulator(device)
64
- end
65
- else
60
+ RunLoop::Environment.with_debugging(debug) do
66
61
  launch_simulator(device)
67
62
  end
68
63
  else
69
- if debug
70
- RunLoop::Environment.with_debugging do
71
- launch_each_simulator
72
- end
73
- else
74
- launch_each_simulator
75
- end
64
+ launch_each_simulator
76
65
  end
66
+
67
+ manage_processes
77
68
  end
78
69
 
79
70
  no_commands do
@@ -120,6 +111,14 @@ module RunLoop
120
111
  @sim_control ||= RunLoop::SimControl.new
121
112
  end
122
113
 
114
+ def xcode
115
+ @xcode ||= RunLoop::Xcode.new
116
+ end
117
+
118
+ def xcrun
119
+ @xcrun ||= RunLoop::Xcrun.new
120
+ end
121
+
123
122
  def booted_device
124
123
  sim_control.simulators.detect(nil) do |device|
125
124
  device.state == 'Booted'
@@ -127,7 +126,7 @@ module RunLoop
127
126
  end
128
127
  end
129
128
 
130
- desc 'install --app [OPTIONS]', 'Installs an app on a device'
129
+ desc 'install --app [OPTIONS]', 'Installs an app on a device.'
131
130
 
132
131
  method_option 'app',
133
132
  :desc => 'Path to a .app bundle to launch on simulator.',
@@ -141,16 +140,22 @@ module RunLoop
141
140
  :required => false,
142
141
  :type => :string
143
142
 
144
- method_option 'force',
145
- :desc => 'Force a re-install the existing app.',
146
- :aliases => '-f',
143
+ method_option 'debug',
144
+ :desc => 'Enable debug logging.',
145
+ :aliases => '-v',
147
146
  :required => false,
148
147
  :default => false,
149
148
  :type => :boolean
150
149
 
151
- method_option 'debug',
152
- :desc => 'Enable debug logging.',
153
- :aliases => '-v',
150
+ method_option 'reset-app-sandbox',
151
+ :desc => 'If the app is already installed, erase the app data.',
152
+ :aliases => '-r',
153
+ :default => false,
154
+ :type => :boolean
155
+
156
+ method_option 'force',
157
+ :desc => 'Force a re-install the existing app. Deprecated 1.5.6.',
158
+ :aliases => '-f',
154
159
  :required => false,
155
160
  :default => false,
156
161
  :type => :boolean
@@ -158,72 +163,22 @@ module RunLoop
158
163
  def install
159
164
  debug = options[:debug]
160
165
 
161
- if debug
162
- ENV['DEBUG'] = '1'
163
- end
164
-
165
- debug_logging = RunLoop::Environment.debug?
166
-
167
166
  device = expect_device(options)
168
167
  app = expect_app(options, device)
169
168
 
170
- bridge = RunLoop::Simctl::Bridge.new(device, app.path)
171
-
172
- xcode = bridge.sim_control.xcode
173
- if xcode.version >= RunLoop::Version.new('7.0')
174
- puts "ERROR: Xcode #{xcode.version.to_s} detected."
175
- puts "ERROR: Apple's simctl install/uninstall is broken for this version of Xcode."
176
- puts "ERROR: See the following links for details:"
177
- puts "ERROR: https://forums.developer.apple.com/message/51922"
178
- puts "ERROR: https://github.com/calabash/run_loop/issues/235"
179
- puts "ERROR: exiting 1"
180
- exit 1
181
- end
182
-
183
- force_reinstall = options[:force]
169
+ core_sim = RunLoop::CoreSimulator.new(device, app)
184
170
 
185
- before = Time.now
171
+ RunLoop::Environment.with_debugging(debug) do
172
+ if options['reset-app-sandbox']
186
173
 
187
- if bridge.app_is_installed?
188
- if debug_logging
189
- puts "App with bundle id '#{app.bundle_identifier}' is already installed."
190
- end
191
-
192
- if force_reinstall
193
- if debug_logging
194
- puts 'Will force a re-install.'
195
- end
196
- bridge.uninstall
197
- bridge.install
198
- else
199
- new_digest = RunLoop::Directory.directory_digest(app.path)
200
- if debug_logging
201
- puts " New app has SHA: '#{new_digest}'."
202
- end
203
- installed_app_bundle = bridge.fetch_app_dir
204
- old_digest = RunLoop::Directory.directory_digest(installed_app_bundle)
205
- if debug_logging
206
- puts "Installed app has SHA: '#{old_digest}'."
207
- end
208
- if new_digest != old_digest
209
- if debug_logging
210
- puts "Will re-install '#{app.bundle_identifier}' because the SHAs don't match."
211
- end
212
- bridge.uninstall
213
- bridge.install
174
+ if core_sim.app_is_installed?
175
+ RunLoop.log_debug('Resetting the app sandbox')
176
+ core_sim.uninstall_app_and_sandbox
214
177
  else
215
- if debug_logging
216
- puts "Will not re-install '#{app.bundle_identifier}' because the SHAs match."
217
- end
178
+ RunLoop.log_debug('App is not installed; skipping sandbox reset')
218
179
  end
219
180
  end
220
- else
221
- bridge.install
222
- end
223
-
224
- if debug_logging
225
- "Launching took #{Time.now-before} seconds"
226
- puts "Installed '#{app.bundle_identifier}' on #{device} in #{Time.now-before} seconds."
181
+ core_sim.install
227
182
  end
228
183
  end
229
184
 
@@ -233,8 +188,8 @@ module RunLoop
233
188
  simulators = sim_control.simulators
234
189
  if device_from_options.nil?
235
190
  default_name = RunLoop::Core.default_simulator
236
- device = simulators.detect do |sim|
237
- sim.instruments_identifier == default_name
191
+ device = simulators.find do |sim|
192
+ sim.instruments_identifier(xcode) == default_name
238
193
  end
239
194
 
240
195
  if device.nil?
@@ -242,9 +197,9 @@ module RunLoop
242
197
  "Could not find a simulator with name that matches '#{device_from_options}'"
243
198
  end
244
199
  else
245
- device = simulators.detect do |sim|
200
+ device = simulators.find do |sim|
246
201
  sim.udid == device_from_options ||
247
- sim.instruments_identifier == device_from_options
202
+ sim.instruments_identifier(xcode) == device_from_options
248
203
  end
249
204
 
250
205
  if device.nil?
data/lib/run_loop/core.rb CHANGED
@@ -138,22 +138,16 @@ module RunLoop
138
138
  #
139
139
  # 1. enabling accessibility and software keyboard
140
140
  # 2. installing / uninstalling apps
141
- # 3. @todo resetting the app sandbox
142
- #
143
- # `Bridge#launch_simulator` launches the targeted iOS Simulator. The
144
- # simulator itself has several async tasks that must be completed before
145
- # we start interacting with it. If your simulator ends up in a bad state,
146
- # you can increase the post-launch wait time by setting the
147
- # `CAL_SIM_POST_LAUNCH_WAIT` environment variable. The default wait time
148
- # is 1.0. This was arrived at through testing.
149
141
  def self.prepare_simulator(launch_options, sim_control)
150
142
 
143
+ xcode = sim_control.xcode
144
+
151
145
  # Respect option passed from Calabash
152
146
  if launch_options[:relaunch_simulator]
153
147
  sim_control.quit_sim
154
148
  end
155
149
 
156
- if !sim_control.xcode_version_gte_6?
150
+ if !xcode.version_gte_6?
157
151
  # Xcode 5.1.1
158
152
 
159
153
  # Will quit the simulator!
@@ -175,7 +169,6 @@ module RunLoop
175
169
  end
176
170
 
177
171
  udid = launch_options[:udid]
178
- xcode = sim_control.xcode
179
172
 
180
173
  device = sim_control.simulators.find do |sim|
181
174
  sim.udid == udid || sim.instruments_identifier(xcode) == udid
@@ -189,9 +182,10 @@ module RunLoop
189
182
  # Validate the architecture.
190
183
  self.expect_simulator_compatible_arch(device, app, xcode)
191
184
 
192
- bridge = RunLoop::LifeCycle::CoreSimulator.new(app, device, sim_control)
185
+ # Quits the simulator.
186
+ core_sim = RunLoop::CoreSimulator.new(device, app)
193
187
 
194
- bridge.ensure_app_same
188
+ core_sim.install
195
189
 
196
190
  # Will quit the simulator if it is running.
197
191
  # @todo fix accessibility_enabled? so we don't have to quit the sim
@@ -205,13 +199,12 @@ module RunLoop
205
199
  # https://github.com/calabash/run_loop/issues/167
206
200
  sim_control.ensure_software_keyboard(device)
207
201
 
208
-
209
202
  # Xcode 6.3 instruments cannot launch an app that is already installed on
210
203
  # iOS 8.3 Simulators. See: https://github.com/calabash/calabash-ios/issues/744
211
- if sim_control.xcode.version_gte_63?
204
+ if xcode.version_gte_63?
212
205
 
213
- if bridge.app_is_installed? && !sim_control.sim_is_running?
214
- bridge.launch_simulator
206
+ if core_sim.app_is_installed? && !sim_control.sim_is_running?
207
+ core_sim.launch_simulator
215
208
  end
216
209
  end
217
210
  end
@@ -220,6 +213,8 @@ module RunLoop
220
213
  def self.run_with_options(options)
221
214
  before = Time.now
222
215
 
216
+ self.prepare(options)
217
+
223
218
  logger = options[:logger]
224
219
  sim_control ||= options[:sim_control] || RunLoop::SimControl.new
225
220
 
@@ -245,7 +240,7 @@ Please update your sources to pass an instance of RunLoop::Xcode))
245
240
  log_file = options[:log_path]
246
241
  timeout = options[:timeout] || 30
247
242
 
248
- results_dir = options[:results_dir] || Dir.mktmpdir('run_loop')
243
+ results_dir = options[:results_dir] || RunLoop::DotDir.make_results_dir
249
244
  results_dir_trace = File.join(results_dir, 'trace')
250
245
  FileUtils.mkdir_p(results_dir_trace)
251
246
 
@@ -820,5 +815,13 @@ Please update your sources to pass an instance of RunLoop::Instruments))
820
815
  def self.pids_for_run_loop(run_loop, &block)
821
816
  RunLoop::Instruments.new.instruments_pids(&block)
822
817
  end
818
+
819
+ private
820
+
821
+ def self.prepare(run_options)
822
+ RunLoop::DotDir.rotate_result_directories
823
+ RunLoop::Instruments.rotate_cache_directories
824
+ true
825
+ end
823
826
  end
824
827
  end