run_loop 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,8 @@
1
1
  module RunLoop
2
+
3
+ # @!visibility private
4
+ #
5
+ # This class is required for the XTC.
2
6
  class Logging
3
7
 
4
8
  def self.log_info(logger, message)
@@ -33,4 +37,68 @@ module RunLoop
33
37
  end
34
38
 
35
39
  end
40
+
41
+ # These are suitable for anything that does not need to be logged on the XTC.
42
+
43
+ # cyan
44
+ def self.log_unix_cmd(msg)
45
+ if RunLoop::Environment.debug?
46
+ puts self.cyan("EXEC: #{msg}") if msg
47
+ end
48
+ end
49
+
50
+ # blue
51
+ def self.log_warn(msg)
52
+ puts self.blue("WARN: #{msg}") if msg
53
+ end
54
+
55
+ # magenta
56
+ def self.log_debug(msg)
57
+ if RunLoop::Environment.debug?
58
+ puts self.magenta("DEBUG: #{msg}") if msg
59
+ end
60
+ end
61
+
62
+ # red
63
+ def self.log_error(msg)
64
+ puts self.red("ERROR: #{msg}") if msg
65
+ end
66
+
67
+ private
68
+
69
+ # @!visibility private
70
+ def self.windows_env?
71
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
72
+ end
73
+
74
+ # @!visibility private
75
+ def self.colorize(string, color)
76
+ if self.windows_env?
77
+ string
78
+ elsif RunLoop::Environment.xtc?
79
+ string
80
+ else
81
+ "\033[#{color}m#{string}\033[0m"
82
+ end
83
+ end
84
+
85
+ # @!visibility private
86
+ def self.red(string)
87
+ colorize(string, 31)
88
+ end
89
+
90
+ # @!visibility private
91
+ def self.blue(string)
92
+ colorize(string, 34)
93
+ end
94
+
95
+ # @!visibility private
96
+ def self.magenta(string)
97
+ colorize(string, 35)
98
+ end
99
+
100
+ # @!visibility private
101
+ def self.cyan(string)
102
+ colorize(string, 36)
103
+ end
36
104
  end
@@ -47,6 +47,21 @@ module RunLoop::Simctl
47
47
  terminate_core_simulator_processes
48
48
  end
49
49
 
50
+ # The sha1 of the installed app.
51
+ def installed_app_sha1
52
+ installed_bundle = fetch_app_dir
53
+ if installed_bundle
54
+ RunLoop::Directory.directory_digest(installed_bundle)
55
+ else
56
+ nil
57
+ end
58
+ end
59
+
60
+ # Is the app that is install the same as the one we have in hand?
61
+ def same_sha1_as_installed?
62
+ app.sha1 == installed_app_sha1
63
+ end
64
+
50
65
  # @!visibility private
51
66
  def is_sdk_8?
52
67
  @is_sdk_8 ||= device.version >= RunLoop::Version.new('8.0')
@@ -198,8 +213,6 @@ module RunLoop::Simctl
198
213
 
199
214
  # Xcode 7
200
215
  ['ids_simd', true],
201
- ['com.apple.CoreSimulator.CoreSimulatorService', true],
202
- ['com.apple.CoreSimulator.SimVerificationService', true]
203
216
  ].each do |pair|
204
217
  name = pair[0]
205
218
  send_term = pair[1]
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = '1.5.1'
2
+ VERSION = '1.5.2'
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
@@ -24,6 +24,14 @@ module RunLoop
24
24
  to_s
25
25
  end
26
26
 
27
+ # Returns a version instance for `Xcode 7.1`; used to check for the
28
+ # availability of features and paths to various items on the filesystem.
29
+ #
30
+ # @return [RunLoop::Version] 7.1
31
+ def v71
32
+ fetch_version(:v71)
33
+ end
34
+
27
35
  # Returns a version instance for `Xcode 7.0`; used to check for the
28
36
  # availability of features and paths to various items on the filesystem.
29
37
  #
@@ -88,6 +96,13 @@ module RunLoop
88
96
  fetch_version(:v50)
89
97
  end
90
98
 
99
+ # Is the active Xcode version 7.1 or above?
100
+ #
101
+ # @return [Boolean] `true` if the current Xcode version is >= 7.1
102
+ def version_gte_71?
103
+ version >= v71
104
+ end
105
+
91
106
  # Is the active Xcode version 7 or above?
92
107
  #
93
108
  # @return [Boolean] `true` if the current Xcode version is >= 7.0
@@ -0,0 +1,75 @@
1
+ module RunLoop
2
+ class Xcrun
3
+
4
+ DEFAULT_OPTIONS =
5
+ {
6
+ :timeout => 10,
7
+ :log_cmd => false
8
+ }
9
+
10
+ DEFAULT_TIMEOUT = 10
11
+
12
+ # Raised when Xcrun fails.
13
+ class XcrunError < RuntimeError; end
14
+
15
+ attr_reader :stdin, :stdout, :stderr, :pid
16
+
17
+ def exec(args, options={})
18
+ merged_options = DEFAULT_OPTIONS.merge(options)
19
+
20
+ timeout = merged_options[:timeout]
21
+
22
+ unless args.is_a?(Array)
23
+ raise ArgumentError,
24
+ "Expected args '#{args}' to be an Array, but found '#{args.class}'"
25
+ end
26
+
27
+ @stdin, @stdout, out, @stderr, err, process_status, @pid, exit_status = nil
28
+
29
+ cmd = "xcrun #{args.join(' ')}"
30
+
31
+ # Don't see your log?
32
+ # Commands are only logged when debugging.
33
+ RunLoop.log_unix_cmd(cmd) if merged_options[:log_cmd]
34
+
35
+ begin
36
+ Timeout.timeout(timeout, TimeoutError) do
37
+ @stdin, @stdout, @stderr, process_status = Open3.popen3('xcrun', *args)
38
+
39
+ @pid = process_status.pid
40
+ exit_status = process_status.value.exitstatus
41
+
42
+ err = @stderr.read.force_encoding('utf-8').chomp
43
+ err = nil if err == ''
44
+
45
+ out = @stdout.read.force_encoding('utf-8').chomp
46
+ end
47
+
48
+ {
49
+ :err => err,
50
+ :out => out,
51
+ :pid => pid,
52
+ :exit_status => exit_status
53
+ }
54
+ rescue StandardError => e
55
+ raise XcrunError, e
56
+ ensure
57
+ stdin.close if stdin && !stdin.closed?
58
+ stdout.close if stdout && !stdout.closed?
59
+ stderr.close if stderr && !stderr.closed?
60
+
61
+ if pid
62
+ terminator = RunLoop::ProcessTerminator.new(pid, 'TERM', cmd)
63
+ unless terminator.kill_process
64
+ terminator = RunLoop::ProcessTerminator.new(pid, 'KILL', cmd)
65
+ terminator.kill_process
66
+ end
67
+ end
68
+
69
+ if process_status
70
+ process_status.join
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -22,6 +22,16 @@ module RunLoop
22
22
  # @todo Refactor instruments related code to instruments class.
23
23
  class XCTools
24
24
 
25
+ # @deprecated Since 1.5.0 - replaced with RunLoop::Xcode
26
+ # Returns a version instance for `Xcode 7.1`; used to check for the
27
+ # availability of features and paths to various items on the filesystem.
28
+ #
29
+ # @return [RunLoop::Version] 7.1
30
+ def v71
31
+ RunLoop.deprecated('1.5.0', 'Replaced with RunLoop::Xcode')
32
+ xcode.v71
33
+ end
34
+
25
35
  # @deprecated Since 1.5.0 - replaced with RunLoop::Xcode
26
36
  # Returns a version instance for `Xcode 7.0`; used to check for the
27
37
  # availability of features and paths to various items on the filesystem.
@@ -147,6 +157,15 @@ module RunLoop
147
157
  xcode.version_gte_6?
148
158
  end
149
159
 
160
+ # @deprecated Since 1.5.0 - replaced with RunLoop::Xcode
161
+ # Are we running Xcode 7.1 or above?
162
+ #
163
+ # @return [Boolean] `true` if the current Xcode version is >= 7.1
164
+ def xcode_version_gte_71?
165
+ RunLoop.deprecated('1.5.0', 'Replaced with RunLoop::Xcode')
166
+ xcode.version_gte_71?
167
+ end
168
+
150
169
  # @deprecated Since 1.5.0 - replaced with RunLoop::Xcode
151
170
  # Are we running Xcode 7 or above?
152
171
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-08 00:00:00.000000000 Z
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -210,20 +210,6 @@ dependencies:
210
210
  - - "~>"
211
211
  - !ruby/object:Gem::Version
212
212
  version: '1.0'
213
- - !ruby/object:Gem::Dependency
214
- name: rb-readline
215
- requirement: !ruby/object:Gem::Requirement
216
- requirements:
217
- - - "~>"
218
- - !ruby/object:Gem::Version
219
- version: '0.5'
220
- type: :development
221
- prerelease: false
222
- version_requirements: !ruby/object:Gem::Requirement
223
- requirements:
224
- - - "~>"
225
- - !ruby/object:Gem::Version
226
- version: '0.5'
227
213
  - !ruby/object:Gem::Dependency
228
214
  name: stub_env
229
215
  requirement: !ruby/object:Gem::Requirement
@@ -299,6 +285,7 @@ files:
299
285
  - lib/run_loop/instruments.rb
300
286
  - lib/run_loop/ipa.rb
301
287
  - lib/run_loop/l10n.rb
288
+ - lib/run_loop/life_cycle/core_simulator.rb
302
289
  - lib/run_loop/lipo.rb
303
290
  - lib/run_loop/lldb.rb
304
291
  - lib/run_loop/logging.rb
@@ -313,6 +300,7 @@ files:
313
300
  - lib/run_loop/simctl/plists.rb
314
301
  - lib/run_loop/version.rb
315
302
  - lib/run_loop/xcode.rb
303
+ - lib/run_loop/xcrun.rb
316
304
  - lib/run_loop/xctools.rb
317
305
  - plists/simctl/com.apple.UIAutomation.plist
318
306
  - plists/simctl/com.apple.UIAutomationPlugIn.plist
@@ -353,3 +341,4 @@ specification_version: 4
353
341
  summary: The bridge between Calabash iOS and Xcode command-line tools like instruments
354
342
  and simctl.
355
343
  test_files: []
344
+ has_rdoc: