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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4f481d7fa3c5ff99d22180aa3833ebb3ee45ff4
4
- data.tar.gz: 0aa2ee0d4af6dbfbf744792acc2c47428c958e15
3
+ metadata.gz: 01af1105eafa64b8a8e2763cf9f2e61196317422
4
+ data.tar.gz: 9fc4979cb92bf1d3045f99f2b685cd3c26b7e4cd
5
5
  SHA512:
6
- metadata.gz: 60af1755b4ca4381fae9c80ffc49bf1242cbb8d9fee88edd1af3bd17246c87f4d7bedddcdf7dae62d6fd7fd904d67275960d0fd83096c90d29754ebdd60ef715
7
- data.tar.gz: 6a38d56469f78a62f7f7bc051b5010a5e2c2c898026d577f1ced8aeb5e6e44281b24c4c4710bf22f52ff710f7f7ed478cf0a9c293b436479f76da62b97b333fd
6
+ metadata.gz: 16a81550bb111ba11b13c729e14fca3b357d7aadbc12f4acd7f357272766ccdc214e96354fadfe57b33aad2fe6b85fdcaf7720305cbff0e59310c1c14661c041
7
+ data.tar.gz: b37580bc3a4716308584c2d453a4b04744ea10b9d8d73da6e24467f22b16a54733ad6181e65b41049268873c652de9bc41b8e9540dd15c2238a470b0704476ec
data/README.md CHANGED
@@ -36,6 +36,49 @@ I18n.enforce_available_locales = false
36
36
  To integrate briar and your calabash-ios console see: https://github.com/jmoody/briar/wiki/Integrating-Briar-Into-Your-Calabash-Console
37
37
 
38
38
 
39
+ ## briar binary
40
+
41
+ The briar binary provides useful commands to improve your calabash workflow.
42
+
43
+ There is detailed help about how to use the .xamarin convention and dotenv to setup your environment.
44
+
45
+ ```
46
+ # help
47
+ $ briar help
48
+ $ briar help console
49
+ $ briar help .xamarin
50
+
51
+ # open a console against simulators
52
+ $ briar console sim6 <== against the current simulator
53
+ $ briar console sim7 ipad_r_64 <== changes the default simulator
54
+
55
+ # open a console against named devices
56
+ $ briar console venus
57
+ $ briar console neptune
58
+
59
+ # install the calabash server from a local repo and remove all stale simulator targets in one command
60
+ $ briar install calabash-server
61
+
62
+ # do a clean install of your .ipa on named device
63
+ $ briar install pluto
64
+ $ briar install earp
65
+
66
+ # open a cucumber html report in your default browser
67
+ $ briar report <== last run against the simulator
68
+ $ briar report venus <== last run against venus
69
+
70
+ # remove all *-cal targets from the simulator (without resetting the device)
71
+ $ briar rm sim-targets
72
+
73
+ # resolve APP_BUNDLE_PATH auto-detection problems by removing spurious DerivedData directories
74
+ $ briar rm dups
75
+ $ briar rm dups briar-ios-example
76
+
77
+ # change the simulator version
78
+ $ briar sim ipad_r
79
+ $ briar sim iphone_4in
80
+ ```
81
+
39
82
  ## Xamarin Test Cloud
40
83
 
41
84
  There is currently an issue with using briar predefined steps on the XTC:
data/bin/briar CHANGED
@@ -1,141 +1,110 @@
1
1
  #!/usr/bin/env ruby
2
2
  #http://tech.natemurray.com/2007/03/ruby-shell-commands.html
3
3
  require 'find'
4
+ require 'rainbow'
5
+ require 'require_relative'
6
+ require 'ansi/logger'
4
7
 
8
+ @log = ANSI::Logger.new(STDOUT)
5
9
 
6
- require File.join(File.dirname(__FILE__), 'briar_helpers')
7
- require File.join(File.dirname(__FILE__), 'briar_resign')
10
+ require 'dotenv'
11
+ Dotenv.load
8
12
 
9
- if ARGV.length == 0
10
- print_usage
11
- exit 0
12
- end
13
-
14
- if ARGV.length == 2
15
- arg1 = ARGV[0]
16
- unless arg1 == BRIAR_CMD_INSTALL
17
- print_usage
18
- exit 1
19
- end
20
- allowed = [BRIAR_INSTALL_GEM, BRIAR_INSTALL_CALABASH_GEM, BRIAR_INSTALL_CALABASH_SERVER]
21
- arg2 = ARGV[1]
22
- unless allowed.include?(arg2)
23
- print_usage
24
- exit 1
25
- end
26
-
27
- if arg2 == BRIAR_INSTALL_GEM
28
-
29
- puts 'will install briar gem'
30
- gem_dir = "#{ENV['HOME']}/git/briar"
31
- unless File.exists?(gem_dir)
32
- puts "expected gem '#{gem_dir}' - cannot install the briar gem"
33
- exit 1
34
- end
35
- system("cd #{gem_dir}; rake install")
36
- exit 0
37
- elsif arg2 == BRIAR_INSTALL_CALABASH_GEM
38
-
39
- puts 'will install calabash-cucumber gem'
40
- gem_dir = "#{ENV['HOME']}/git/calabash-ios/calabash-cucumber"
41
- unless File.exists?(gem_dir)
42
- puts "expected gem '#{gem_dir}' - cannot install the calabash-cucumber gem"
43
- exit 1
44
- end
45
- system("cd #{gem_dir}; rake install")
46
- exit 0
47
- elsif arg2 == BRIAR_INSTALL_CALABASH_SERVER
48
-
49
- puts 'will install calabash-ios server'
50
- cal_framework = 'calabash.framework'
51
- unless File.exists?(cal_framework)
52
- puts "expected '#{cal_framework}' to be in the local directory."
53
- puts "run this command in the directory that contins '#{cal_framework}'"
54
- exit 1
55
- end
56
-
57
- gem_dir = "#{ENV['HOME']}/git/calabash-ios/calabash-cucumber"
58
- unless File.exists?(gem_dir)
59
- puts "expected gem '#{gem_dir}' - cannot install the calabash server"
60
- exit 1
61
- end
62
-
63
- server_dir = "#{ENV['HOME']}/git/calabash-ios-server"
64
- unless File.exists?(server_dir)
65
- puts "expected calabash-ios server to be in dir '#{server_dir}'"
66
- puts "will not be able run '#{gem_dir}/rake build_server'"
67
- exit 1
68
- end
13
+ require_relative './briar_help'
14
+ require_relative './briar_resign'
15
+ require_relative './briar_install'
16
+ require_relative './briar_console'
17
+ require_relative './briar_rm'
18
+ require_relative './briar_xtc'
19
+ require_relative './briar_report'
20
+ require_relative './briar_sim'
69
21
 
70
- version_file = File.read("#{server_dir}/calabash/Classes/FranklyServer/Routes/LPVersionRoute.h")
71
- tokens = version_file.split(/define kLPCALABASHVERSION/)
72
- line = tokens[1].split("\n").first
73
- version = line.tr('^A-Za-z0-9.\-\_', '')
22
+ num_args = ARGV.length
74
23
 
75
- puts "building calabash server using 'rake build_server'"
76
- system("cd #{gem_dir}; rake build_server")
77
- puts 'remove old cal simulator targets'
78
- system('briar rm-cal-targets')
79
- puts 'copying new framework to ./'
80
- system("cp #{gem_dir}/staticlib/#{cal_framework}.zip ./")
81
- puts 'removing old framework'
82
- system("rm -rf #{cal_framework}")
83
- puts 'unzipping new framework'
84
- system("unzip #{cal_framework}.zip")
85
- puts 'cleaning up'
86
- system("rm -rf #{cal_framework}.zip")
87
- puts "installed new server version '#{version}'"
88
24
 
89
- exit 0
90
- end
91
- puts 'fell through install conditional'
92
- exit 1
25
+ def briar_version
26
+ Briar::VERSION
93
27
  end
94
28
 
95
- cmd = ARGV.shift
96
- if cmd == 'help'
29
+ if num_args == 0
97
30
  print_usage
98
31
  exit 0
99
- elsif cmd == BRIAR_VERSION_CMD
100
- puts "#{Briar::VERSION}"
101
- elsif cmd == BRIAR_RM_CAL_TARGETS
102
- puts 'quiting the simulator'
103
- `/usr/bin/osascript -e 'tell application "iPhone Simulator" to quit'`
104
- sim_dir="#{ENV['HOME']}/Library/Application Support/iPhone Simulator"
32
+ end
105
33
 
106
- # `find "#{sim_dir}" -type d -name '*-cal.app' | sed 's#\(.*\)/.*#\1#' | xargs -I{} rm -rf {}`
107
- cal_targets = []
108
- Find.find(sim_dir) do |path|
109
- if path =~ /.*\-cal.app/
110
- puts "found '#{File.basename(path)}' in '#{File.dirname(path)}'"
111
- cal_targets << File.dirname(path)
112
- Find.prune
113
- end
34
+ if num_args == 1 and (ARGV[0] == 'help' or ARGV[0] == 'version')
35
+ command = ARGV[0]
36
+ case command
37
+ when 'help'
38
+ print_usage
39
+ when 'version'
40
+ briar_version
41
+ else
42
+ @log.error{"'#{command}' is not defined"}
43
+ @log.error('can you try something else?')
44
+ exit 1
114
45
  end
46
+ exit 0
47
+ end
115
48
 
116
- if cal_targets.empty?
117
- puts "found no *-cal.app targets in '#{sim_dir}'"
118
- exit 0
49
+ if num_args == 2 and ARGV[0] == 'help'
50
+ command = ARGV[1]
51
+ case command
52
+ when 'console'
53
+ print_console_help
54
+ when 'cucumber-reports'
55
+ print_cucumber_reports_help
56
+ when 'install'
57
+ print_install_help
58
+ when 'resign'
59
+ print_resign_help
60
+ when 'report'
61
+ print_report_help
62
+ when 'rm'
63
+ print_rm_help
64
+ when 'sim'
65
+ print_sim_help
66
+ when 'version'
67
+ print_version_help
68
+ when '.xamarin'
69
+ print_dot_xamarin_help
70
+ when 'xtc'
71
+ print_xtc_help
72
+ when 'xtc-profiles'
73
+ print_xtc_profiles_help
74
+ else
75
+ @log.error("'#{command}' is not defined, so there is no help for you")
76
+ exit 1
119
77
  end
78
+ exit 0
79
+ end
120
80
 
121
- cal_targets.each do |path|
122
- FileUtils.rm_r path
123
- end
124
81
 
125
- elsif cmd == BRIAR_INSTALL_CALABASH_GEM
126
- puts "use 'briar install calabash-gem'"
127
- exit 1
128
- elsif cmd == BRIAR_INSTALL_GEM
129
- puts "use 'briar install gem'"
130
- exit 1
131
- elsif cmd == BRIAR_INSTALL_CALABASH_SERVER
132
- puts "use 'briar install calabash-server'"
133
- exit 1
134
- elsif cmd == BRIAR_RESIGN_IPA
135
- puts 'will resign'
136
- briar_resign(ARGV)
137
- exit 0
138
- else
139
- print_usage
140
- exit 1
82
+
83
+ command = ARGV[0]
84
+ args = ARGV.drop(1)
85
+ case command
86
+ when 'console'
87
+ briar_console(args)
88
+ when 'install'
89
+ briar_install(args)
90
+ when 'report'
91
+ briar_report(args)
92
+ when 'resign'
93
+ briar_resign(args)
94
+ when 'rm'
95
+ briar_rm(args)
96
+ when 'sim'
97
+ briar_sim(args)
98
+ when 'xtc'
99
+ briar_xtc(args)
100
+
101
+ # deprecated
102
+ when BRIAR_RM_CAL_TARGETS
103
+ puts Rainbow('DEPRECATED 0.1.3 - replaced with $ briar rm sim-targets').yellow
104
+ briar_rm(['sim-targets'])
105
+ else
106
+ @log.error{"'#{command}' is not defined"}
107
+ @log.error('can you try something else?')
108
+ exit 1
141
109
  end
110
+ exit 0
@@ -0,0 +1,126 @@
1
+ require_relative './briar_dot_xamarin'
2
+ require_relative './briar_env'
3
+
4
+ require 'ansi/logger'
5
+ @log = ANSI::Logger.new(STDOUT)
6
+
7
+ # returns an iOS version string based on a canonical key
8
+ #
9
+ # the iOS version string is used to control which version of the simulator is
10
+ # launched. use this to set the +SDK_VERSION+.
11
+ #
12
+ # IMPORTANT: launching an iOS 5 simulator is not support in Xcode 5 or greater
13
+ # IMPORTANT: Instruments 5.0 cannot be used to launch an app on an iOS 5 device
14
+ def sdk_versions
15
+ {:ios5 => '5.1',
16
+ :ios6 => '6.1',
17
+ :ios7 => '7.0'}
18
+ end
19
+
20
+ # returns a hash with default arguments for various launch and irb functions
21
+ def default_console_opts
22
+ {:sdk_version => sdk_versions[:ios7],
23
+ :irbrc => ENV['IRBRC'] || './.irbrc',
24
+ :bundle_exec => ENV['BUNDLE_EXEC'] == '1'
25
+ }
26
+ end
27
+
28
+ def screenshot_path
29
+ path = ENV['SCREENSHOT_PATH'] || './screenshots'
30
+ # *** trailing slash required ***
31
+ ENV['SCREENSHOT_PATH'] = "#{path}/"
32
+ # make a screenshot directory if one does not exist
33
+ FileUtils.mkdir(path) unless File.exists?(path)
34
+ path
35
+ end
36
+
37
+ def logging_level
38
+ {'DEBUG' => ENV['DEBUG'] || '1',
39
+ 'CALABASH_FULL_CONSOLE_OUTPUT' => ENV['CALABASH_FULL_CONSOLE_OUTPUT'] || '1'}
40
+ end
41
+
42
+ def simulator_variables(sdk_version)
43
+ {'DEVICE_TARGET' => 'simulator',
44
+ 'SKD_VERSION' => sdk_version}
45
+ end
46
+
47
+ def device_variables(device)
48
+ {'DEVICE_TARGET' => read_device_info(device, :udid),
49
+ 'DEVICE_ENDPOINT' => read_device_info(device, :ip),
50
+ 'BUNDLE_ID' => expect_bundle_id()
51
+ }
52
+ end
53
+
54
+
55
+ # returns a string that can be use to launch a <tt>calabash-ios console</tt>
56
+ # that is configured using the opts hash
57
+ #
58
+ # ios_console_cmd('neptune') # => a command to launch an irb against neptune
59
+ #
60
+ def ios_console_cmd(device, opts={})
61
+ default_opts = default_console_opts()
62
+ opts = default_opts.merge(opts)
63
+
64
+ env = ["SCREENSHOT_PATH=#{screenshot_path}"]
65
+
66
+ logging_level.each { |key,value|
67
+ env << "#{key}=#{value}"
68
+ }
69
+
70
+ if device.eql? :simulator
71
+ simulator_variables(opts[:sdk_version]).each { |key,value|
72
+ env << "#{key}=#{value}"
73
+ }
74
+ else
75
+ device_variables(device).each { |key,value|
76
+ env << "#{key}=#{value}"
77
+ }
78
+ end
79
+
80
+ env << "IRBRC=#{opts[:irbrc]}"
81
+ env << 'bundle exec' if opts[:bundle_exec]
82
+ env << 'irb'
83
+ env.join(' ')
84
+ end
85
+
86
+ # starts a console using the opts hash
87
+ def console(device, opts={})
88
+
89
+ ### unexpected ###
90
+ # do not be tempted to use IRB.start
91
+ # this can cause some terrible problems at > exit
92
+ ##################
93
+
94
+ default_opts = default_console_opts()
95
+ opts = default_opts.merge(opts)
96
+ cmd = ios_console_cmd(device, opts)
97
+ puts Rainbow(cmd).green
98
+ exec cmd
99
+ end
100
+
101
+
102
+ def briar_console(args)
103
+ arg_len = args.length
104
+ if arg_len == 0
105
+ print_console_help
106
+ exit 0
107
+ end
108
+
109
+ where = args[0]
110
+
111
+ sim = arg_len == 2 ? args[1] : nil
112
+
113
+ case where
114
+ when 'sim6'
115
+ set_default_simulator sim.to_sym if sim
116
+ console(:simulator, {:sdk_version => sdk_versions[:ios6]})
117
+ when 'sim7'
118
+ set_default_simulator sim.to_sym if sim
119
+ console(:simulator, {:sdk_version => sdk_versions[:ios7]})
120
+ else
121
+ if arg_len != 1
122
+ @log.warn { "expected only one arg but found '#{args}' - ignoring extra input" }
123
+ end
124
+ console(where)
125
+ end
126
+ end
@@ -0,0 +1,74 @@
1
+ require 'ansi/logger'
2
+
3
+ @log = ANSI::Logger.new(STDOUT)
4
+
5
+ # return the device info by reading and parsing the relevant file in the
6
+ # ~/.xamarin directory
7
+ #
8
+ # read_device_info('neptune', :udid) # => reads the neptune udid (iOS)
9
+ # read_device_info('earp', :ip) # => reads the earp udid (iOS)
10
+ # read_device_info('r2d2', :serial) # => read the r2d2 serial number (android)
11
+ def read_device_info (device, kind)
12
+ kind = kind.to_sym
13
+ kinds = [:ip, :udid, :serial]
14
+ unless kinds.include?(kind)
15
+ raise "illegal argument '#{kind}' - must be one of '#{kinds}'"
16
+ end
17
+
18
+ path = File.expand_path("~/.xamarin/devices/#{device}/#{kind}")
19
+
20
+ unless File.exist?(path)
21
+ @log.fatal{"cannot read device information for '#{device}'"}
22
+ @log.fatal{"file '#{path}' does not exist"}
23
+ exit 1
24
+ end
25
+
26
+ begin
27
+ IO.readlines(path).first.strip
28
+ rescue Exception => e
29
+ @log.fatal{"cannot read device information for '#{device}'"}
30
+ @log.fatal{e}
31
+ exit 1
32
+ end
33
+ end
34
+
35
+ # return a +Hash+ of XTC device sets where the key is some arbitrary description
36
+ # and the value is a <tt>XTC device set</tt>
37
+ def read_device_sets(path='~/.xamarin/test-cloud/ios-sets.csv')
38
+ ht = Hash.new
39
+ begin
40
+ File.read(File.expand_path(path)).split("\n").each do |line|
41
+ # not 1.8 compat
42
+ # unless line[0].eql?('#')
43
+ unless line.chars.to_a.first.eql?('#')
44
+ tokens = line.split(',')
45
+ if tokens.count == 2
46
+ ht[tokens[0].strip] = tokens[1].strip
47
+ end
48
+ end
49
+ end
50
+ ht
51
+ rescue Exception => e
52
+ @log.fatal{'cannot read device set information'}
53
+ @log.fatal{e}
54
+ exit 1
55
+ end
56
+ end
57
+
58
+ def read_api_token(account_name)
59
+ path = File.expand_path("~/.xamarin/test-cloud/#{account_name}")
60
+
61
+ unless File.exist?(path)
62
+ @log.fatal{"cannot read account information for '#{account_name}'"}
63
+ @log.fatal{"file '#{path}' does not exist"}
64
+ exit 1
65
+ end
66
+
67
+ begin
68
+ IO.readlines(path).first.strip
69
+ rescue Exception => e
70
+ @log.fatal{"cannot read account information for '#{account_name}'"}
71
+ @log.fatal{e}
72
+ exit 1
73
+ end
74
+ end