briar 0.1.3.rc1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -0
- data/bin/briar +90 -121
- data/bin/briar_console.rb +126 -0
- data/bin/briar_dot_xamarin.rb +74 -0
- data/bin/briar_env.rb +51 -0
- data/bin/briar_help.rb +383 -0
- data/bin/briar_ideviceinstaller.rb +41 -0
- data/bin/briar_install.rb +122 -0
- data/bin/briar_report.rb +55 -0
- data/bin/briar_rm.rb +84 -0
- data/bin/briar_sim.rb +107 -0
- data/bin/briar_xtc.rb +108 -0
- data/briar.gemspec +6 -1
- data/lib/briar.rb +8 -0
- data/lib/briar/irbrc.rb +18 -7
- data/lib/briar/uia/briar_ipad_emulation.rb +2 -2
- data/lib/briar/version.rb +1 -1
- metadata +71 -6
- data/bin/briar_helpers.rb +0 -53
data/bin/briar_env.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'ansi/logger'
|
2
|
+
|
3
|
+
@log = ANSI::Logger.new(STDOUT)
|
4
|
+
|
5
|
+
def expect_bundle_id
|
6
|
+
bundle_id = ENV['BUNDLE_ID']
|
7
|
+
unless ENV['BUNDLE_ID']
|
8
|
+
@log.fatal{'BUNDLE_ID must be set'}
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
bundle_id
|
12
|
+
end
|
13
|
+
|
14
|
+
def expect_build_script(build_script)
|
15
|
+
unless File.exists?(File.expand_path(build_script))
|
16
|
+
@log.fatal{ 'arguments say there is supposed to be a build script' }
|
17
|
+
@log.fatal{ "expected it here '#{build_script}'" }
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
build_script
|
21
|
+
end
|
22
|
+
|
23
|
+
def expect_ideviceinstaller
|
24
|
+
bin_path = ENV['IDEVICEINSTALLER_BIN']
|
25
|
+
unless File.exists?(File.expand_path(bin_path))
|
26
|
+
@log.fatal{'cannot find ideviceinstaller'}
|
27
|
+
@log.fatal{ "expected it here '#{bin_path}'"}
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def expect_ipa(ipa_path)
|
33
|
+
unless File.exists?(File.expand_path(ipa_path))
|
34
|
+
@log.fatal{'ipa does not exist'}
|
35
|
+
@log.fatal{"expected it here '#{ipa_path}'"}
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
ipa_path
|
39
|
+
end
|
40
|
+
|
41
|
+
def expect_xtc_account
|
42
|
+
account = ENV['XTC_ACCOUNT']
|
43
|
+
unless account
|
44
|
+
@log.fatal{ 'XTC_ACCOUNT must be set' }
|
45
|
+
exit 1
|
46
|
+
end
|
47
|
+
account
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
data/bin/briar_help.rb
ADDED
@@ -0,0 +1,383 @@
|
|
1
|
+
require 'briar'
|
2
|
+
require 'rainbow'
|
3
|
+
require 'ansi/code'
|
4
|
+
require 'ansi/string'
|
5
|
+
require 'ansi/mixin'
|
6
|
+
require 'ansi/columns'
|
7
|
+
|
8
|
+
# these have been deprecated since 0.1.3
|
9
|
+
BRIAR_RM_CAL_TARGETS='rm-cal-targets'
|
10
|
+
BRIAR_INSTALL_CALABASH_GEM='calabash-gem'
|
11
|
+
BRIAR_INSTALL_CALABASH_SERVER='calabash-server'
|
12
|
+
BRIAR_INSTALL_GEM='gem'
|
13
|
+
BRIAR_RESIGN_IPA='resign'
|
14
|
+
BRIAR_VERSION_CMD='version'
|
15
|
+
BRIAR_CMD_INSTALL='install'
|
16
|
+
|
17
|
+
def warn_deprecated(version, msg)
|
18
|
+
puts ANSI.cyan { "deprecated'#{version}' - '#{msg}'" }
|
19
|
+
end
|
20
|
+
|
21
|
+
def help_warn_destructive
|
22
|
+
Rainbow('# These is are destructive operations! You have been warned.').red.underline
|
23
|
+
end
|
24
|
+
|
25
|
+
def help_experimental
|
26
|
+
Rainbow('EXPERIMENTAL').underline.magenta
|
27
|
+
end
|
28
|
+
|
29
|
+
def help_deprecated(version, msg)
|
30
|
+
ANSI.cyan { "DEPRECATED #{version} - #{msg}" }
|
31
|
+
end
|
32
|
+
|
33
|
+
def help_nyi
|
34
|
+
ANSI.yellow { 'NYI' }
|
35
|
+
end
|
36
|
+
|
37
|
+
def help_command(sig)
|
38
|
+
Rainbow("briar #{sig}").cyan
|
39
|
+
end
|
40
|
+
|
41
|
+
def help_requires_env_vars
|
42
|
+
Rainbow('REQUIRES ENV VARIABLES').magenta
|
43
|
+
end
|
44
|
+
|
45
|
+
def help_env_var(name, msg)
|
46
|
+
"#{Rainbow(name).yellow} => #{msg}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def help_examples
|
50
|
+
'EXAMPLES'
|
51
|
+
end
|
52
|
+
|
53
|
+
def help_example_comment(comment)
|
54
|
+
Rainbow("# #{comment}").magenta
|
55
|
+
end
|
56
|
+
|
57
|
+
def help_example(example)
|
58
|
+
Rainbow("$ briar #{example}").cyan
|
59
|
+
end
|
60
|
+
|
61
|
+
def help_requires_dot_xamarin
|
62
|
+
Rainbow('REQUIRES adopting .xamarin convention.').magenta
|
63
|
+
end
|
64
|
+
|
65
|
+
def help_see_dot_xamarin_help
|
66
|
+
"see #{Rainbow('$ briar help .xamarin').yellow} for details"
|
67
|
+
end
|
68
|
+
|
69
|
+
def help_requires_xtc_profiles
|
70
|
+
Rainbow('REQUIRES xtc-profiles.yml').magenta
|
71
|
+
end
|
72
|
+
|
73
|
+
def help_see_xtc_profiles_help
|
74
|
+
"see #{Rainbow('$ briar help xtc-profiles').yellow} for details"
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def help_customize
|
79
|
+
Rainbow('CUSTOMIZATION').green
|
80
|
+
end
|
81
|
+
|
82
|
+
def help_requires_cucumber_profiles
|
83
|
+
Rainbow('REQUIRES cucumber profiles').magenta
|
84
|
+
end
|
85
|
+
|
86
|
+
def help_see_cucumber_reports_help
|
87
|
+
"see #{Rainbow('$ briar help cucumber-reports').yellow} for details"
|
88
|
+
end
|
89
|
+
|
90
|
+
def print_dot_xamarin_help
|
91
|
+
puts <<EOF
|
92
|
+
|
93
|
+
#{Rainbow('THE PITCH').cyan.underline}
|
94
|
+
|
95
|
+
The .xamarin convention helps manage devices, projects, and XTC accounts by
|
96
|
+
stashing all of your calabash configuration details in one place.
|
97
|
+
|
98
|
+
* Do you have more than one device?
|
99
|
+
* More that one calabash project?
|
100
|
+
* Are you working cross-platform?
|
101
|
+
* Are your device IP address not stable?
|
102
|
+
* Do you have an XTC account?
|
103
|
+
|
104
|
+
If you answered yes to any of those questions, .xamarin will improve your
|
105
|
+
workflow.
|
106
|
+
|
107
|
+
https://github.com/jmoody/briar/wiki/The-.xamarin-Convention
|
108
|
+
|
109
|
+
EOF
|
110
|
+
end
|
111
|
+
|
112
|
+
def print_version_help
|
113
|
+
puts <<EOF
|
114
|
+
#{Rainbow('are you serious?').cyan}
|
115
|
+
EOF
|
116
|
+
end
|
117
|
+
|
118
|
+
def print_rm_help
|
119
|
+
puts <<EOF
|
120
|
+
#{help_command('rm sim-targets')}
|
121
|
+
deletes all *-cal targets from simulator
|
122
|
+
useful for clearing out old calabash targets when the framework has been updated.
|
123
|
+
|
124
|
+
#{help_command('rm dups [project-prefix]')}
|
125
|
+
deletes duplicate directories from your Xcode DerivedData directory
|
126
|
+
|
127
|
+
helps resolves problems with calabash detecting the #{Rainbow('APP_BUNDLE_PATH').yellow}
|
128
|
+
|
129
|
+
#{help_requires_env_vars}
|
130
|
+
#{help_env_var(' DERIVED_DATA', 'defaults to "${HOME}/Library/Developer/Xcode/DerivedData')}
|
131
|
+
#{help_env_var('DERIVED_DATA_PREFIX', 'must be set or project-prefix must be passed as arg')}
|
132
|
+
|
133
|
+
#{help_examples}
|
134
|
+
#{help_example_comment('raises an error if DERIVED_DATA_PREFIX is not defined')}
|
135
|
+
#{help_example('rm dups')}
|
136
|
+
#{help_example('rm dups Briar')}
|
137
|
+
#{help_example('rm dups briar-ios-example')}
|
138
|
+
|
139
|
+
#{help_warn_destructive}
|
140
|
+
|
141
|
+
EOF
|
142
|
+
end
|
143
|
+
|
144
|
+
def print_install_help
|
145
|
+
puts <<EOF
|
146
|
+
#{help_command('install calabash-server')}
|
147
|
+
1. builds the calabash server using calabash-cucumber #{Rainbow('$ rake task :build_server').cyan}
|
148
|
+
2. replaces calabash.framework in the current directory,
|
149
|
+
3. removes all *-cal targets from simulator, and
|
150
|
+
4. removes duplicate derived data directories
|
151
|
+
|
152
|
+
#{help_requires_env_vars}
|
153
|
+
#{help_env_var('CALABASH_SERVER_PATH', 'top level directory of your local calabash-ios-server repo')}
|
154
|
+
#{help_env_var(' CALABASH_GEM_PATH', 'top level directory of your local calabash-ios repo')}
|
155
|
+
|
156
|
+
#{help_examples}
|
157
|
+
#{help_example_comment('raises an error if calabash server and gem paths are not defined')}
|
158
|
+
#{help_example('install calabash-server')}
|
159
|
+
|
160
|
+
#{help_command('install < device-name >')}
|
161
|
+
do a clean install of an .ipa on device
|
162
|
+
|
163
|
+
if #{Rainbow("ENV['IPA_BUILD_SCRIPT']").yellow} is defined, this command will call that script
|
164
|
+
to generate an .ipa.
|
165
|
+
|
166
|
+
#{help_requires_dot_xamarin}
|
167
|
+
#{help_see_dot_xamarin_help}
|
168
|
+
|
169
|
+
#{help_requires_env_vars}
|
170
|
+
#{help_env_var(' IPA', 'path to the .ipa you want installed')}
|
171
|
+
#{help_env_var(' BUNDLE_ID', 'bundle id of the app - eg. com.littlejoysoftware.Briar-cal')}
|
172
|
+
#{help_env_var('IDEVICEINSTALLER_BIN', 'path to ideviceinstaller binary')}
|
173
|
+
#{help_env_var(' IPA_BUILD_SCRIPT', '(optional) script that generates the IPA')}
|
174
|
+
|
175
|
+
#{help_warn_destructive}
|
176
|
+
|
177
|
+
EOF
|
178
|
+
end
|
179
|
+
|
180
|
+
def print_console_help
|
181
|
+
puts <<EOF
|
182
|
+
#{help_command('console { sim6 | sim7 } [simulator version]}')}
|
183
|
+
starts a calabash console targeting a specific sdk
|
184
|
+
|
185
|
+
optionally sets the simulator version
|
186
|
+
|
187
|
+
#{help_examples}
|
188
|
+
#{help_example('sim6')}
|
189
|
+
#{help_example('sim6 iphone_4in')}
|
190
|
+
#{help_example('sim7 ipad_r')}
|
191
|
+
#{help_example('sim7 iphone_4in_64')}
|
192
|
+
|
193
|
+
#{help_command('<device name>')}
|
194
|
+
start a calabash console against a physical device
|
195
|
+
|
196
|
+
#{help_requires_dot_xamarin}
|
197
|
+
#{help_see_dot_xamarin_help}
|
198
|
+
|
199
|
+
#{help_examples}
|
200
|
+
#{help_example('console venus')}
|
201
|
+
|
202
|
+
#{help_customize}
|
203
|
+
#{help_example_comment('you can customize the console using these variables')}
|
204
|
+
#{help_env_var(' SCREENSHOT_PATH', 'where to put console screenshots - defaults to ./screenshots')}
|
205
|
+
#{help_env_var(' DEBUG', 'verbose logging')}
|
206
|
+
#{help_env_var('CALABASH_FULL_CONSOLE_OUTPUT', 'verboser logging')}
|
207
|
+
#{help_env_var(' IRBRC', 'location of custom .irbrc file - defaults to ./.irbrc')}
|
208
|
+
#{help_env_var(' BUNDLE_EXEC', 'start console with bundle exec - defaults to 0')}
|
209
|
+
|
210
|
+
EOF
|
211
|
+
end
|
212
|
+
|
213
|
+
def print_resign_help
|
214
|
+
puts <<EOF
|
215
|
+
|
216
|
+
#{help_experimental}
|
217
|
+
|
218
|
+
#{help_command('resign </path/to/your.ipa> </path/to/your.mobileprovision> <wildcard-prefix> <signing-identity>')}
|
219
|
+
|
220
|
+
EOF
|
221
|
+
end
|
222
|
+
|
223
|
+
def print_cucumber_reports_help
|
224
|
+
puts <<EOF
|
225
|
+
#{Rainbow('USE CUCUMBER PROFILES TO GENERATE REPORTS').cyan.underline}
|
226
|
+
|
227
|
+
#{help_example_comment('example cucumber.yml')}
|
228
|
+
#{Rainbow("<%
|
229
|
+
|
230
|
+
date = Time.now.strftime('%Y-%m-%d-%H%M-%S')
|
231
|
+
default_report = \"./reports/calabash-\#{date}.html\"
|
232
|
+
FileUtils.mkdir(\"./reports\") unless File.exists?(\"./reports\")
|
233
|
+
|
234
|
+
%>
|
235
|
+
|
236
|
+
html_report: -f 'Calabash::Formatters::Html' -o <%= default_report %>
|
237
|
+
default: -p html_report").yellow}
|
238
|
+
|
239
|
+
#{help_example_comment('run wip tests on iOS 7 simulator and then open the results')}
|
240
|
+
#{Rainbow('$ cucumber -t @wip').cyan}
|
241
|
+
#{Rainbow('$ briar report').cyan}
|
242
|
+
|
243
|
+
For a more complete example see:
|
244
|
+
|
245
|
+
https://github.com/jmoody/briar-ios-example/blob/master/Briar/cucumber.yml
|
246
|
+
|
247
|
+
#{help_example_comment('run keyboard tests on the iOS 6 simulator using sim launch then open the results')}
|
248
|
+
#{Rainbow('$ cucumber -p sim6 -p launch -t @keyboard').cyan}
|
249
|
+
#{Rainbow('$ briar report').cyan}
|
250
|
+
|
251
|
+
#{help_example_comment('run table view tests on venus (an iOS 7 iPad 4)then open the the results')}
|
252
|
+
#{Rainbow('$ cucumber -p venus -t @table').cyan}
|
253
|
+
#{Rainbow('$ briar report').cyan}
|
254
|
+
|
255
|
+
EOF
|
256
|
+
end
|
257
|
+
|
258
|
+
def print_report_help
|
259
|
+
puts <<EOF
|
260
|
+
|
261
|
+
#{help_requires_cucumber_profiles}
|
262
|
+
#{help_see_cucumber_reports_help}
|
263
|
+
|
264
|
+
#{help_command('report')}
|
265
|
+
opens the most recent cucumber report generated by a run against the simulator in the default browser
|
266
|
+
|
267
|
+
#{help_command('report <device>')}
|
268
|
+
opens the most recent cucumber report generated by a run against < device > in the default browser
|
269
|
+
|
270
|
+
#{help_requires_dot_xamarin}
|
271
|
+
#{help_see_dot_xamarin_help}
|
272
|
+
|
273
|
+
EOF
|
274
|
+
end
|
275
|
+
|
276
|
+
def print_sim_help
|
277
|
+
puts <<EOF
|
278
|
+
#{help_command('sim')}
|
279
|
+
prints the available simulators
|
280
|
+
|
281
|
+
#{help_command('sim quit')}
|
282
|
+
quits the simulator
|
283
|
+
|
284
|
+
#{help_command('sim open')}
|
285
|
+
makes the simulator the front-most app
|
286
|
+
|
287
|
+
#{help_command('sim <simulator version>')}
|
288
|
+
quits the simulator and sets the default simulator to <simulator version>
|
289
|
+
|
290
|
+
#{help_examples}
|
291
|
+
#{help_example('sim iphone_4in')}
|
292
|
+
#{help_example('sim ipad_r')}
|
293
|
+
#{help_example('sim iphone_4in_64')}
|
294
|
+
EOF
|
295
|
+
|
296
|
+
end
|
297
|
+
|
298
|
+
def print_xtc_help
|
299
|
+
puts <<EOF
|
300
|
+
|
301
|
+
#{help_experimental}
|
302
|
+
|
303
|
+
#{help_requires_dot_xamarin}
|
304
|
+
#{help_see_dot_xamarin_help}
|
305
|
+
|
306
|
+
#{help_requires_xtc_profiles}
|
307
|
+
#{help_see_xtc_profiles_help}
|
308
|
+
|
309
|
+
#{help_command('xtc')}
|
310
|
+
prints the available XTC device sets
|
311
|
+
|
312
|
+
#{help_command('xtc <device-set> [profile]')} #{help_experimental} #{help_nyi}
|
313
|
+
submits a job to the XTC targeting devices specified in < device-set >
|
314
|
+
|
315
|
+
if no profile is set, the 'default' profile in the xtc-cucumber.yml will be used
|
316
|
+
|
317
|
+
#{help_requires_env_vars}
|
318
|
+
#{help_env_var(' IPA', 'path to the .ipa you submitting')}
|
319
|
+
#{help_env_var(' XTC_PROFILES', 'cucumber profiles for the XTC')}
|
320
|
+
#{help_env_var(' XTC_ACCOUNT', 'name of a directory in ~/.xamarin/test-cloud/<account> that contains the api token')}
|
321
|
+
#{help_example_comment('if a build script is defined, the .ipa will be built before submission')}
|
322
|
+
#{help_env_var('IPA_BUILD_SCRIPT', '(optional) script that generates the IPA')}
|
323
|
+
|
324
|
+
EOF
|
325
|
+
end
|
326
|
+
|
327
|
+
def print_xtc_profiles_help
|
328
|
+
puts <<EOF
|
329
|
+
#{Rainbow('MOTIVATION').cyan.underline}
|
330
|
+
|
331
|
+
Let's face it. Your development cucumber.yml is probably a mess. Plus, your
|
332
|
+
XTC goals are a different. Use different set of cucumber profiles for the XTC.
|
333
|
+
|
334
|
+
#{help_example_comment('example xtc-cucumber.yml')}
|
335
|
+
#{Rainbow('# careful using the @not_xtc tag - you should avoid not running tests!
|
336
|
+
# use for Scenario Outlines which are nyi on XTC
|
337
|
+
not_xtc: --tags ~@not_xtc
|
338
|
+
not_sim: --tags ~@simulator --tags ~@simulator_only
|
339
|
+
no_launch: --tags ~@no_launch
|
340
|
+
|
341
|
+
tags: -p not_xtc -p not_sim -p no_launch
|
342
|
+
default: -p tags
|
343
|
+
|
344
|
+
wip: -p tags --tags @wip
|
345
|
+
').yellow}
|
346
|
+
|
347
|
+
For a more complex example see:
|
348
|
+
|
349
|
+
https://github.com/jmoody/briar-ios-example/blob/master/Briar/features/xtc-profiles.yml
|
350
|
+
|
351
|
+
To take advantage of the #{Rainbow('briar xtc <device-set> [profile]').yellow}
|
352
|
+
command, set the #{Rainbow('XTC_PROFILES').cyan} variable to your xtc-profiles.yml
|
353
|
+
|
354
|
+
EOF
|
355
|
+
end
|
356
|
+
|
357
|
+
def print_usage
|
358
|
+
puts <<EOF
|
359
|
+
#{Rainbow("Welcome to briar #{Briar::VERSION}!").cyan}
|
360
|
+
|
361
|
+
briar help { command } for more information a command
|
362
|
+
|
363
|
+
console { sim6 [simulator version] | sim7 [simulator version] | <device-name> }
|
364
|
+
install { calabash-server | <device-name> }
|
365
|
+
report [device]
|
366
|
+
resign #{help_experimental}
|
367
|
+
rm { sim-targets | dups [project-name] }
|
368
|
+
sim [{quit | <simulator version>}]
|
369
|
+
version
|
370
|
+
xtc [<device-set> [profile]] #{help_experimental} #{help_nyi}
|
371
|
+
|
372
|
+
#{Rainbow('ADDITIONAL HELP TOPICS').green}
|
373
|
+
help .xamarin
|
374
|
+
help cucumber-reports
|
375
|
+
help xtc-profiles
|
376
|
+
|
377
|
+
#{Rainbow('DEPRECATED').yellow}
|
378
|
+
* #{Rainbow(BRIAR_RM_CAL_TARGETS).yellow} #{help_deprecated('0.1.3', 'replaced with $ briar rm sim-targets')}
|
379
|
+
* #{Rainbow("#{BRIAR_CMD_INSTALL} #{BRIAR_INSTALL_GEM}").yellow} #{help_deprecated('0.1.3', 'will be removed')}
|
380
|
+
* #{Rainbow("#{BRIAR_CMD_INSTALL} #{BRIAR_INSTALL_CALABASH_GEM}").yellow} #{help_deprecated('0.1.3', 'will be removed')}
|
381
|
+
|
382
|
+
EOF
|
383
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative './briar_dot_xamarin'
|
2
|
+
require_relative './briar_rm'
|
3
|
+
require_relative './briar_env'
|
4
|
+
|
5
|
+
require 'ansi/logger'
|
6
|
+
|
7
|
+
@log = ANSI::Logger.new(STDOUT)
|
8
|
+
|
9
|
+
def ideviceinstaller(device, cmd, opts={})
|
10
|
+
default_opts = {:build_script => ENV['IPA_BUILD_SCRIPT'],
|
11
|
+
:ipa => ENV['IPA'],
|
12
|
+
:bundle_id => expect_bundle_id(),
|
13
|
+
:ideviceinstaller => expect_ideviceinstaller()}
|
14
|
+
opts = default_opts.merge(opts)
|
15
|
+
|
16
|
+
cmds = [:install, :uninstall, :reinstall]
|
17
|
+
unless cmds.include? cmd
|
18
|
+
raise "illegal option '#{cmd}' must be one of '#{cmds}'"
|
19
|
+
end
|
20
|
+
|
21
|
+
build_script = opts[:build_script]
|
22
|
+
expect_build_script(build_script) if build_script
|
23
|
+
|
24
|
+
udid = read_device_info(device, :udid)
|
25
|
+
|
26
|
+
if cmd == :install
|
27
|
+
if build_script
|
28
|
+
system "#{build_script}"
|
29
|
+
briar_remove_derived_data_dups
|
30
|
+
end
|
31
|
+
ipa = opts[:ipa]
|
32
|
+
expect_ipa(ipa)
|
33
|
+
|
34
|
+
system "#{bin_path} -u #{udid} --install #{ipa}"
|
35
|
+
elsif cmd == :uninstall
|
36
|
+
system "#{bin_path} -u #{udid} --uninstall #{bundle_id}"
|
37
|
+
else
|
38
|
+
ideviceinstaller(device, :uninstall)
|
39
|
+
ideviceinstaller(device, :install)
|
40
|
+
end
|
41
|
+
end
|