Class: XamarinTestCloud::CLI
- Inherits:
-
Thor
- Object
- Thor
- XamarinTestCloud::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/xamarin-test-cloud/cli.rb
Constant Summary collapse
- FILE_UPLOAD_ENDPOINT =
'upload2'- FORM_URL_ENCODED_ENDPOINT =
'upload'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#app ⇒ Object
Returns the value of attribute app.
-
#app_explorer ⇒ Object
Returns the value of attribute app_explorer.
-
#appname ⇒ Object
Returns the value of attribute appname.
-
#async ⇒ Object
Returns the value of attribute async.
-
#config ⇒ Object
Returns the value of attribute config.
-
#device_selection ⇒ Object
Returns the value of attribute device_selection.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#endpoint_path ⇒ Object
Returns the value of attribute endpoint_path.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pretty ⇒ Object
Returns the value of attribute pretty.
-
#profile ⇒ Object
Returns the value of attribute profile.
-
#test_parameters ⇒ Object
Returns the value of attribute test_parameters.
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def api_key @api_key end |
#app ⇒ Object
Returns the value of attribute app.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def app @app end |
#app_explorer ⇒ Object
Returns the value of attribute app_explorer.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def app_explorer @app_explorer end |
#appname ⇒ Object
Returns the value of attribute appname.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def appname @appname end |
#async ⇒ Object
Returns the value of attribute async.
23 24 25 |
# File 'lib/xamarin-test-cloud/cli.rb', line 23 def async @async end |
#config ⇒ Object
Returns the value of attribute config.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def config @config end |
#device_selection ⇒ Object
Returns the value of attribute device_selection.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def device_selection @device_selection end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def dry_run @dry_run end |
#endpoint_path ⇒ Object
Returns the value of attribute endpoint_path.
24 25 26 |
# File 'lib/xamarin-test-cloud/cli.rb', line 24 def endpoint_path @endpoint_path end |
#host ⇒ Object
Returns the value of attribute host.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def host @host end |
#pretty ⇒ Object
Returns the value of attribute pretty.
23 24 25 |
# File 'lib/xamarin-test-cloud/cli.rb', line 23 def pretty @pretty end |
#profile ⇒ Object
Returns the value of attribute profile.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def profile @profile end |
#test_parameters ⇒ Object
Returns the value of attribute test_parameters.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def test_parameters @test_parameters end |
#workspace ⇒ Object
Returns the value of attribute workspace.
21 22 23 |
# File 'lib/xamarin-test-cloud/cli.rb', line 21 def workspace @workspace end |
Class Method Details
.source_root ⇒ Object
30 31 32 |
# File 'lib/xamarin-test-cloud/cli.rb', line 30 def self.source_root File.join(File.dirname(__FILE__), '..') end |
Instance Method Details
#submit(app, api_key) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/xamarin-test-cloud/cli.rb', line 102 def submit(app, api_key) self.host = [:host] self.pretty = [:pretty] app_path = File.(app) unless File.exist?(app_path) raise ValidationError, "App is not a file: #{app_path}" end if shared_runtime?(app_path) puts "Xamarin Test Cloud doesn't yet support shared runtime apps." puts "To test your app it needs to be compiled for release." puts "You can learn how to compile you app for release here:" puts "http://docs.xamarin.com/guides/android/deployment%2C_testing%2C_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release" raise ValidationError, "Aborting" end app_extension = File.extname(app_path) unless /ipa/i.match(app_extension) || /apk/i.match(app_extension) raise ValidationError, "App #{app_path} must be an .ipa or .apk file" end self.app = app_path self.async = [:async] self.dry_run = ['dry-run'] self.api_key = api_key self.test_parameters = ['test-parameters'] || {} self.appname = ['app-name'] self.device_selection = ['device-selection'] device_selection_data = validate_device_selection self.app_explorer = ['app-explorer'] unless app_explorer parse_and_set_config_and_profile end workspace_path = [:workspace] || File.('.') unless File.directory?(workspace_path) raise ValidationError, "Provided workspace: #{workspace_path} is not a directory." end workspace_basename = File.basename(workspace_path) if workspace_basename.downcase == 'features' self.workspace = File.(File.join(workspace_path,'..')) puts "Deriving workspace #{self.workspace} from features folder #{workspace_basename}" else self.workspace = File.(workspace_path) end self.workspace = File.join(self.workspace, File::Separator) if ENV['DEBUG'] puts "Host = #{self.host}" puts "App = #{self.app}" puts "App Name = #{self.app}" puts "AppExplorer = #{self.app_explorer}" puts "TestParams = #{self.test_parameters}" puts "API Key = #{self.api_key}" puts "Device Selection = #{self.device_selection}" puts "Workspace = #{self.workspace}" puts "Config = #{self.config}" puts "Profile = #{self.profile}" end #Argument parsing done test_jon_data = submit_test_job(device_selection_data) if self.dry_run return end json = test_jon_data[:body] if ENV['DEBUG']=='1' p json end log_header("Test enqueued") puts "User: #{json["user_email"]}" puts "Devices:" json["devices"].each do |device| puts device end puts "" unless self.async wait_for_job(json["id"]) else log 'Async mode: not awaiting test results' end end |
#version ⇒ Object
36 37 38 |
# File 'lib/xamarin-test-cloud/cli.rb', line 36 def version puts XamarinTestCloud::VERSION end |