run_loop 0.2.1 → 1.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,163 @@
1
1
  module RunLoop
2
- VERSION = '0.2.1'
2
+ VERSION = '1.0.0.pre3'
3
+
4
+ # A model of a software release version that can be used to compare two versions.
5
+ #
6
+ # Calabash and RunLoop try very hard to comply with Semantic Versioning rules.
7
+ # However, the semantic versioning spec is incompatible with RubyGem's patterns
8
+ # for pre-release gems.
9
+ #
10
+ # > "But returning to the practical: No release version of SemVer is compatible with Rubygems." - _David Kellum_
11
+ #
12
+ # Calabash and RunLoop version numbers will be in the form `<major>.<minor>.<patch>[.pre<N>]`.
13
+ #
14
+ # @see http://semver.org/
15
+ # @see http://gravitext.com/2012/07/22/versioning.html
16
+ class Version
17
+
18
+ # @!attribute [rw] major
19
+ # @return [Integer] the major version
20
+ attr_accessor :major
21
+
22
+ # @!attribute [rw] minor
23
+ # @return [Integer] the minor version
24
+ attr_accessor :minor
25
+
26
+ # @!attribute [rw] patch
27
+ # @return [Integer] the patch version
28
+ attr_accessor :patch
29
+
30
+ # @!attribute [rw] pre
31
+ # @return [Boolean] true if this is a pre-release version
32
+ attr_accessor :pre
33
+
34
+ # @!attribute [rw] pre_version
35
+ # @return [Integer] if this is a pre-release version, returns the
36
+ # pre-release version; otherwise this is nil
37
+ attr_accessor :pre_version
38
+
39
+ # Creates a new Version instance with all the attributes set.
40
+ #
41
+ # @example
42
+ # version = Version.new(0.10.1)
43
+ # version.major => 0
44
+ # version.minor => 10
45
+ # version.patch => 1
46
+ # version.pre => false
47
+ # version.pre_release => nil
48
+ #
49
+ # @example
50
+ # version = Version.new(1.6.3.pre5)
51
+ # version.major => 1
52
+ # version.minor => 6
53
+ # version.patch => 3
54
+ # version.pre => true
55
+ # version.pre_release => 5
56
+ #
57
+ # @param [String] version the version string to parse.
58
+ # @raise [ArgumentError] if version is not in the form 5, 6.1, 7.1.2, 8.2.3.pre1
59
+ def initialize(version)
60
+ tokens = version.strip.split('.')
61
+ count = tokens.count
62
+ if tokens.empty?
63
+ raise ArgumentError, "expected '#{version}' to be like 5, 6.1, 7.1.2, 8.2.3.pre1"
64
+ end
65
+
66
+ if count < 4 and tokens.any? { |elm| elm =~ /\D/ }
67
+ raise ArgumentError, "expected '#{version}' to be like 5, 6.1, 7.1.2, 8.2.3.pre1"
68
+ end
69
+
70
+ if count == 4
71
+ @pre = tokens[3]
72
+ pre_tokens = @pre.scan(/\D+|\d+/)
73
+ @pre_version = pre_tokens[1].to_i if pre_tokens.count == 2
74
+ end
75
+
76
+ @major, @minor, @patch = version.split('.').map(&:to_i)
77
+ end
78
+
79
+ # Returns an string representation of this version.
80
+ # @return [String] a string in the form `<major>.<minor>.<patch>[.pre<N>]`
81
+ def to_s
82
+ str = [major, minor, patch].compact.join('.')
83
+ str = "#{str}.#{pre}" if pre
84
+ str
85
+ end
86
+
87
+ # Compare this version to another for equality.
88
+ # @param [Version] other the version to compare against
89
+ # @return [Boolean] true if this Version is the same as `other`
90
+ def == (other)
91
+ Version.compare(self, other) == 0
92
+ end
93
+
94
+ # Compare this version to another for inequality.
95
+ # @param [Version] other the version to compare against
96
+ # @return [Boolean] true if this Version is not the same as `other`
97
+ def != (other)
98
+ Version.compare(self, other) != 0
99
+ end
100
+
101
+ # Is this version less-than another version?
102
+ # @param [Version] other the version to compare against
103
+ # @return [Boolean] true if this Version is less-than `other`
104
+ def < (other)
105
+ Version.compare(self, other) < 0
106
+ end
107
+
108
+ # Is this version greater-than another version?
109
+ # @param [Version] other the version to compare against
110
+ # @return [Boolean] true if this Version is greater-than `other`
111
+ def > (other)
112
+ Version.compare(self, other) > 0
113
+ end
114
+
115
+ # Is this version less-than or equal to another version?
116
+ # @param [Version] other the version to compare against
117
+ # @return [Boolean] true if this Version is less-than or equal `other`
118
+ def <= (other)
119
+ Version.compare(self, other) <= 0
120
+ end
121
+
122
+ # Is this version greater-than or equal to another version?
123
+ # @param [Version] other the version to compare against
124
+ # @return [Boolean] true if this Version is greater-than or equal `other`
125
+ def >= (other)
126
+ Version.compare(self, other) >= 0
127
+ end
128
+
129
+ # Compare version `a` to version `b`.
130
+ #
131
+ # @example
132
+ # compare Version.new(0.10.0), Version.new(0.9.0) => 1
133
+ # compare Version.new(0.9.0), Version.new(0.10.0) => -1
134
+ # compare Version.new(0.9.0), Version.new(0.9.0) => 0
135
+ #
136
+ # @return [Integer] an integer `(-1, 1)`
137
+ def self.compare(a, b)
138
+
139
+ if a.major != b.major
140
+ return a.major > b.major ? 1 : -1
141
+ end
142
+
143
+ if a.minor != b.minor
144
+ return a.minor.to_i > b.minor.to_i ? 1 : -1
145
+ end
146
+
147
+ if a.patch != b.patch
148
+ return a.patch.to_i > b.patch.to_i ? 1 : -1
149
+ end
150
+
151
+ return 1 if a.pre and (not b.pre)
152
+ return -1 if (not a.pre) and b.pre
153
+
154
+ return 1 if a.pre_version and (not b.pre_version)
155
+ return -1 if (not a.pre_version) and b.pre_version
156
+
157
+ if a.pre_version != b.pre_version
158
+ return a.pre_version.to_i > b.pre_version.to_i ? 1 : -1
159
+ end
160
+ 0
161
+ end
162
+ end
3
163
  end
@@ -0,0 +1,184 @@
1
+ require 'open3'
2
+ require 'retriable'
3
+
4
+ module RunLoop
5
+
6
+ # A class for interacting with the Xcode tools.
7
+ #
8
+ # @note All command line tools are run in the context of `xcrun`.
9
+ #
10
+ # Throughout this class's documentation, there are references to the
11
+ # _current version of Xcode_. The current Xcode version is the one returned
12
+ # by `xcrun xcodebuild`. The current Xcode version can be set using
13
+ # `xcode-select` or overridden using the `DEVELOPER_DIR`.
14
+ #
15
+ # @todo Refactor instruments related code to instruments class.
16
+ class XCTools
17
+
18
+ # Returns a version instance for `Xcode 6.0`; used to check for the
19
+ # availability of features and paths to various items on the filesystem.
20
+ #
21
+ # @return [RunLoop::Version] 6.0
22
+ def v60
23
+ @xc60 ||= Version.new('6.0')
24
+ end
25
+
26
+ # Returns a version instance for `Xcode 5.1`; used to check for the
27
+ # availability of features and paths to various items on the filesystem.
28
+ #
29
+ # @return [RunLoop::Version] 5.1
30
+ def v51
31
+ @xc51 ||= Version.new('5.1')
32
+ end
33
+
34
+ # Returns a version instance for `Xcode 5.0`; ; used to check for the
35
+ # availability of features and paths to various items on the filesystem.
36
+ #
37
+ # @return [RunLoop::Version] 5.0
38
+ def v50
39
+ @xc50 ||= Version.new('5.0')
40
+ end
41
+
42
+ # Are we running Xcode 6 or above?
43
+ #
44
+ # @return [Boolean] `true` if the current Xcode version is >= 6.0
45
+ def xcode_version_gte_6?
46
+ @xcode_gte_6 ||= xcode_version >= v60
47
+ end
48
+
49
+ # Are we running Xcode 5.1 or above?
50
+ #
51
+ # @return [Boolean] `true` if the current Xcode version is >= 5.1
52
+ def xcode_version_gte_51?
53
+ @xcode_gte_51 ||= xcode_version >= v51
54
+ end
55
+
56
+ # Returns the current version of Xcode.
57
+ #
58
+ # @return [RunLoop::Version] The current version of Xcode as reported by
59
+ # `xcrun xcodebuild -version`.
60
+ def xcode_version
61
+ @xcode_version ||= lambda {
62
+ xcode_build_output = `xcrun xcodebuild -version`.split(/\s/)[1]
63
+ Version.new(xcode_build_output)
64
+ }.call
65
+ end
66
+
67
+ # Returns the path to the current developer directory.
68
+ #
69
+ # From the man pages:
70
+ #
71
+ # ```
72
+ # $ man xcode-select
73
+ # DEVELOPER_DIR
74
+ # Overrides the active developer directory. When DEVELOPER_DIR is set,
75
+ # its value will be used instead of the system-wide active developer
76
+ # directory.
77
+ #```
78
+ #
79
+ # @return [String] path to current developer directory
80
+ def xcode_developer_dir
81
+ @xcode_developer_dir ||=
82
+ if ENV['DEVELOPER_DIR']
83
+ ENV['DEVELOPER_DIR']
84
+ else
85
+ # fall back to xcode-select
86
+ `xcode-select --print-path`.chomp
87
+ end
88
+ end
89
+
90
+ # Method for interacting with instruments.
91
+ #
92
+ # @example Getting a runnable command for instruments
93
+ # instruments #=> 'xcrun instruments'
94
+ #
95
+ # @example Getting a the version of instruments.
96
+ # instruments(:version) #=> 5.1.1 - a Version object
97
+ #
98
+ # @example Getting list of known simulators.
99
+ # instruments(:sims) #=> < list of known simulators >
100
+ #
101
+ # @param [Version] cmd controls the return value. currently accepts `nil`,
102
+ # `:sims`, `:templates`, and `:version` as valid parameters
103
+ # @return [String,Array,Version] based on the value of `cmd` version, a list known
104
+ # simulators, the version of current instruments tool, or the path to the
105
+ # instruments binary.
106
+ # @raise [ArgumentError] if invalid `cmd` is passed
107
+ def instruments(cmd=nil)
108
+ instruments = 'xcrun instruments'
109
+ return instruments if cmd == nil
110
+
111
+ case cmd
112
+ when :version
113
+ @instruments_version ||= lambda {
114
+ # Xcode 6 can print out some very strange output, so we have to retry.
115
+ Retriable.retriable({:tries => 5}) do
116
+ Open3.popen3("#{instruments}") do |_, _, stderr, _|
117
+ version_str = stderr.read.chomp.split(/\s/)[2]
118
+ Version.new(version_str)
119
+ end
120
+ end
121
+ }.call
122
+ when :sims
123
+ @instruments_sims ||= lambda {
124
+ devices = `#{instruments} -s devices`.chomp.split("\n")
125
+ devices.select { |device| device.downcase.include?('simulator') }
126
+ }.call
127
+
128
+ when :templates
129
+ @instruments_templates ||= lambda {
130
+ cmd = "#{instruments} -s templates"
131
+ if self.xcode_version >= self.v51
132
+ `#{cmd}`.split("\n").delete_if do |path|
133
+ not path =~ /tracetemplate/
134
+ end.map { |elm| elm.strip }
135
+ else
136
+ # prints to $stderr (>_>) - seriously?
137
+ Open3.popen3(cmd) do |_, _, stderr, _|
138
+ stderr.read.chomp.split(/(,|\(|")/).map do |elm|
139
+ elm.strip
140
+ end.delete_if { |path| not path =~ /tracetemplate/ }
141
+ end
142
+ end
143
+ }.call
144
+
145
+ when :devices
146
+ @devices ||= lambda {
147
+ all = `#{instruments} -s devices`.chomp.split("\n")
148
+ valid = all.select { |device| device =~ /[a-f0-9]{40}/ }
149
+ valid.map do |device|
150
+ udid = device[/[a-f0-9]{40}/, 0]
151
+ version = device[/(\d\.\d(\.\d)?)/, 0]
152
+ name = device.split('(').first.strip
153
+ RunLoop::Device.new(name, version, udid)
154
+ end
155
+ }.call
156
+ else
157
+ candidates = [:version, :sims, :devices]
158
+ raise(ArgumentError, "expected '#{cmd}' to be one of '#{candidates}'")
159
+ end
160
+ end
161
+
162
+ # Does the instruments `version` accept the -s flag?
163
+ #
164
+ # @example
165
+ # instruments_supports_hyphen_s?('4.6.3') => false
166
+ # instruments_supports_hyphen_s?('5.0.2') => true
167
+ # instruments_supports_hyphen_s?('5.1') => true
168
+ #
169
+ # @param [String, Version] version (instruments(:version))
170
+ # a major.minor[.patch] version string or a Version object
171
+ #
172
+ # @return [Boolean] true if the version is >= 5.*
173
+ def instruments_supports_hyphen_s?(version=instruments(:version))
174
+ @instruments_supports_hyphen_s ||= lambda {
175
+ if version.is_a? String
176
+ _version = Version.new(version)
177
+ else
178
+ _version = version
179
+ end
180
+ _version >= Version.new('5.1')
181
+ }.call
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,4 @@
1
+ process attach -n '<%= cf_bundle_executable %>'
2
+ expr (void*)dlopen("<%= dylib_path_for_target %>", 0x2)
3
+ detach
4
+ exit
metadata CHANGED
@@ -1,78 +1,227 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-26 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.19'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.19'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: retriable
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: CFPropertyList
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: travis
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '10.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '10.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: awesome_print
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '1.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: '1.2'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: '4.3'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: '4.3'
153
+ - !ruby/object:Gem::Dependency
154
+ name: guard-bundler
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: '2.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: '2.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: growl
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '1.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ~>
179
+ - !ruby/object:Gem::Version
180
+ version: '1.0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rb-readline
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ~>
186
+ - !ruby/object:Gem::Version
187
+ version: '0.5'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ~>
193
+ - !ruby/object:Gem::Version
194
+ version: '0.5'
41
195
  description: calabash-cucumber drives tests for native iOS apps. RunLoop provides
42
196
  a number of tools associated with running Calabash tests.
43
197
  email:
44
- - karl@lesspainful.com
198
+ - karl.krukow@xamarin.com
45
199
  executables:
46
200
  - run-loop
47
201
  extensions: []
48
202
  extra_rdoc_files: []
49
203
  files:
50
- - scripts/udidetect
51
- - .gitignore
52
- - .gitmodules
53
- - .irbrc
54
- - CHANGES.txt
55
- - Gemfile
56
- - LICENSE
57
- - README.md
58
- - Rakefile
59
204
  - bin/run-loop
60
- - build_to_run_loop.sh
61
- - docs/intro.md
62
- - irb.sh
63
- - lib/run_loop.rb
64
205
  - lib/run_loop/cli.rb
65
206
  - lib/run_loop/core.rb
207
+ - lib/run_loop/device.rb
208
+ - lib/run_loop/plist_buddy.rb
209
+ - lib/run_loop/sim_control.rb
66
210
  - lib/run_loop/version.rb
67
- - run_loop.gemspec
211
+ - lib/run_loop/xctools.rb
212
+ - lib/run_loop.rb
68
213
  - scripts/calabash_script_uia.js
69
214
  - scripts/json2-min.js
70
215
  - scripts/json2.js
71
216
  - scripts/run_dismiss_location.js
72
217
  - scripts/run_loop_fast_uia.js
73
218
  - scripts/run_loop_host.js
219
+ - scripts/udidetect
220
+ - scripts/calabash.lldb.erb
221
+ - LICENSE
74
222
  homepage: http://calaba.sh
75
- licenses: []
223
+ licenses:
224
+ - MIT
76
225
  metadata: {}
77
226
  post_install_message:
78
227
  rdoc_options: []
@@ -82,12 +231,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
231
  requirements:
83
232
  - - '>='
84
233
  - !ruby/object:Gem::Version
85
- version: '0'
234
+ version: '1.9'
86
235
  required_rubygems_version: !ruby/object:Gem::Requirement
87
236
  requirements:
88
- - - '>='
237
+ - - '>'
89
238
  - !ruby/object:Gem::Version
90
- version: '0'
239
+ version: 1.3.1
91
240
  requirements: []
92
241
  rubyforge_project:
93
242
  rubygems_version: 2.0.3
@@ -95,3 +244,4 @@ signing_key:
95
244
  specification_version: 4
96
245
  summary: Tools related to running Calabash iOS tests
97
246
  test_files: []
247
+ has_rdoc: