xamarin-test-cloud 0.9.38 → 0.10.0.pre1

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: abcb70f026155c146d290a041b9cd7342fe23dde
4
- data.tar.gz: dc881fdb928b738262dc9a75938e53ecc7811a85
3
+ metadata.gz: d7e86b25f55da1aec8b4504629b006f925762f04
4
+ data.tar.gz: 8a161091309905209563051db183d9ea35075a52
5
5
  SHA512:
6
- metadata.gz: 715630681e945d5edb6c268420e8aaf5a11ea4eee11b92972cb9cb5ff2d36b8913b87890c67e571a535d4fb31842cadb178041a70a3d78385a64add36f879067
7
- data.tar.gz: 7cf78a4c8f993eceddca5337d0abfe89566076f40f0d233eb4e887e25495e44052c01bd4b25c514c34edefdd72ceec39e7848d4300f6351b27485ce63641ca26
6
+ metadata.gz: 7c8d729ac9bcac1faa00092cf01311eb240b877bb5e6d62ff87ba727c5d62b932fe1245890902f7f12d546cd3fa38ccf6c99d9ab8ff7ce03440c85aabd26e0b5
7
+ data.tar.gz: e8950226872229fdff8d0646cf5f226aea24cc85b83af2da7ab06eb7e9d232d46ac871aa4543dfcda38fae108ee1424512ed24c0d7dff719a77e3d0725b48a78
@@ -11,7 +11,12 @@ require 'tmpdir'
11
11
  require 'fileutils'
12
12
  require 'retriable'
13
13
  require 'xamarin-test-cloud/version'
14
+ require 'securerandom'
14
15
 
16
+ trap "SIGINT" do
17
+ puts "Exiting"
18
+ exit 10
19
+ end
15
20
 
16
21
  module XamarinTestCloud
17
22
 
@@ -21,11 +26,28 @@ module XamarinTestCloud
21
26
  class CLI < Thor
22
27
  include Thor::Actions
23
28
 
24
- attr_accessor :host, :app, :api_key, :appname, :app_explorer, :test_parameters,
29
+ attr_accessor :app, :api_key, :appname, :test_parameters,
25
30
  :workspace, :config, :profile, :skip_config_check, :dry_run,
26
31
  :device_selection, :pretty, :async, :priority, :endpoint_path,
27
32
  :locale, :series,
28
- :dsym
33
+ :dsym, :session_id
34
+
35
+ def self.exit_on_failure?
36
+ true
37
+ end
38
+
39
+ def initialize(*args)
40
+ self.session_id = SecureRandom.hex
41
+ begin
42
+ r = JSON.parse(http_post("check_version", {args: ARGV}))
43
+ if r["error_message"]
44
+ puts r["error_message"]
45
+ exit 1
46
+ end
47
+ rescue
48
+ end
49
+ super(*args)
50
+ end
29
51
 
30
52
  FILE_UPLOAD_ENDPOINT = 'upload2'
31
53
  FORM_URL_ENCODED_ENDPOINT = 'upload'
@@ -44,11 +66,6 @@ module XamarinTestCloud
44
66
  desc 'submit <APP> <API_KEY>', 'Submits your app and test suite to Xamarin Test Cloud'
45
67
 
46
68
 
47
- method_option :host,
48
- :desc => 'Test Cloud host to submit to',
49
- :aliases => '-h', :type => :string,
50
- :default => (ENV['XTC_ENDPOINT'] || 'https://testcloud.xamarin.com/ci')
51
-
52
69
  method_option 'app-name',
53
70
  :desc => 'App name to create or add test to',
54
71
  :aliases => '-a',
@@ -61,12 +78,6 @@ module XamarinTestCloud
61
78
  :required => true,
62
79
  :type => :string
63
80
 
64
- method_option 'app-explorer',
65
- :desc => 'Explore using AppExplorer only (no Calabash)',
66
- :aliases => '-e',
67
- :type => :boolean,
68
- :default => false
69
-
70
81
  method_option 'test-parameters',
71
82
  :desc => 'Test parameters (e.g., -params username:nat@xamarin.com password:xamarin)',
72
83
  :aliases => '-params',
@@ -131,8 +142,6 @@ module XamarinTestCloud
131
142
 
132
143
  def submit(app, api_key)
133
144
 
134
- self.host = options[:host]
135
-
136
145
  self.pretty = options[:pretty]
137
146
 
138
147
  app_path = File.expand_path(app)
@@ -170,8 +179,6 @@ module XamarinTestCloud
170
179
 
171
180
  device_selection_data = validate_device_selection
172
181
 
173
- self.app_explorer = options['app-explorer']
174
-
175
182
  self.locale = options['locale']
176
183
 
177
184
  self.series = options['series']
@@ -188,17 +195,12 @@ module XamarinTestCloud
188
195
  end
189
196
  end
190
197
 
191
-
192
198
  workspace_path = options[:workspace] || File.expand_path('.')
193
199
 
194
- unless self.app_explorer
195
- unless File.directory?(workspace_path)
196
- raise ValidationError, "Provided workspace: #{workspace_path} is not a directory."
197
- end
200
+ unless File.directory?(workspace_path)
201
+ raise ValidationError, "Provided workspace: #{workspace_path} is not a directory."
198
202
  end
199
203
 
200
-
201
-
202
204
  workspace_basename = File.basename(workspace_path)
203
205
  if workspace_basename.downcase == 'features'
204
206
  self.workspace = File.expand_path(File.join(workspace_path,'..'))
@@ -210,37 +212,31 @@ module XamarinTestCloud
210
212
  self.workspace = File.join(self.workspace, File::Separator)
211
213
 
212
214
 
213
- unless self.app_explorer
214
- unless File.directory?(File.join(self.workspace, 'features'))
215
- log_header "Did not find features folder in workspace #{self.workspace}"
216
- puts "Either run the test-cloud command from the directory containing your features"
217
- puts "or use the --workspace option to refer to this directory"
218
- puts "See also test-cloud help submit"
219
- raise ValidationError, "Unable to find features folder in #{self.workspace}"
220
- end
215
+ unless File.directory?(File.join(self.workspace, 'features'))
216
+ log_header "Did not find features folder in workspace #{self.workspace}"
217
+ puts "Either run the test-cloud command from the directory containing your features"
218
+ puts "or use the --workspace option to refer to this directory"
219
+ puts "See also test-cloud help submit"
220
+ raise ValidationError, "Unable to find features folder in #{self.workspace}"
221
221
  end
222
222
 
223
- unless app_explorer
224
- parse_and_set_config_and_profile
225
- unless self.skip_config_check
226
- default_config = File.join(self.workspace,'config','cucumber.yml')
227
- if File.exist?(default_config) && self.config.nil?
228
- log_header 'Warning: Detected cucumber.yml config file, but no --config specified'
229
- puts "Please specify --config #{default_config}"
230
- puts 'and specify a profile via --profile'
231
- puts 'If you know what you are doing you can skip this check with'
232
- puts '--skip-config-check'
233
- raise ValidationError, "#{default_config} detected but no profile selected."
234
- end
223
+ parse_and_set_config_and_profile
224
+ unless self.skip_config_check
225
+ default_config = File.join(self.workspace,'config','cucumber.yml')
226
+ if File.exist?(default_config) && self.config.nil?
227
+ log_header 'Warning: Detected cucumber.yml config file, but no --config specified'
228
+ puts "Please specify --config #{default_config}"
229
+ puts 'and specify a profile via --profile'
230
+ puts 'If you know what you are doing you can skip this check with'
231
+ puts '--skip-config-check'
232
+ raise ValidationError, "#{default_config} detected but no profile selected."
235
233
  end
236
234
  end
237
235
 
238
-
239
236
  if debug?
240
237
  puts "Host = #{self.host}"
241
238
  puts "App = #{self.app}"
242
239
  puts "App Name = #{self.app}"
243
- puts "AppExplorer = #{self.app_explorer}"
244
240
  puts "TestParams = #{self.test_parameters}"
245
241
  puts "API Key = #{self.api_key}"
246
242
  puts "Device Selection = #{self.device_selection}"
@@ -303,50 +299,23 @@ module XamarinTestCloud
303
299
  def wait_for_job(id)
304
300
  while(true)
305
301
  status_json = retriable :tries => 60, :interval => 10 do
306
- JSON.parse(http_post("status", {'id' => id, 'api_key' => api_key}))
302
+ JSON.parse(http_post("status_v3", {'id' => id, 'api_key' => api_key}))
307
303
  end
308
304
 
309
- log "Status: #{status_json["status_description"]}"
310
- if status_json["status"] == "finished"
311
- puts "Done!"
312
- if debug?
313
- log "Status JSON result"
314
- puts status_json
315
- end
316
- log_header "Test Summary"
317
- calabash_data = status_json["calabash_data"]
318
-
319
- if calabash_data
320
- failed = calabash_data["scenarios"]["failed"].to_i
321
- puts "Total scenarios: #{calabash_data["scenarios"]["total"]}"
322
- puts "#{calabash_data["scenarios"]["passed"]} passed"
323
- puts "#{failed} failed"
324
- puts "Total steps: #{calabash_data["steps"]["total"]}"
325
-
326
- puts ""
327
- puts "Test Report:"
328
- puts status_json['share_link']
329
- if failed > 0
330
- exit 1
331
- end
332
- end
333
- exit 0
305
+ if debug?
306
+ log "Status JSON result:"
307
+ puts status_json
334
308
  end
335
309
 
336
- if ["cancelled", "invalid"].include?(status_json["status"])
337
- puts "Failed!"
338
- if status_json['reason']
339
- puts "Reason: #{status_json['status']}"
340
- puts "Details:"
341
- puts status_json['reason']
342
- end
343
- exit 1
344
- end
345
- if debug?
346
- sleep 1
347
- else
348
- sleep 10
310
+ wait_time = (Integer status_json["wait_time"] rescue nil) || 10
311
+ wait_time = 1 if debug?
312
+ log status_json["message"]
313
+
314
+ if status_json["exit_code"]
315
+ exit Integer status_json["exit_code"]
349
316
  end
317
+
318
+ sleep wait_time
350
319
  end
351
320
  end
352
321
 
@@ -373,30 +342,27 @@ module XamarinTestCloud
373
342
  end
374
343
  start_at = Time.now
375
344
 
376
- unless self.app_explorer
377
- server = verify_app_and_extract_test_server
345
+ server = verify_app_and_extract_test_server
378
346
 
379
- log_header('Checking for Gemfile')
347
+ log_header('Checking for Gemfile')
380
348
 
381
- if File.exist?(workspace_gemfile)
382
- FileUtils.cp workspace_gemfile, tmpdir
383
- FileUtils.cp workspace_gemfile_lock, tmpdir if File.exist?(workspace_gemfile_lock)
384
- else
385
- copy_default_gemfile(File.join(tmpdir, "Gemfile"), server)
386
- end
349
+ if File.exist?(workspace_gemfile)
350
+ FileUtils.cp workspace_gemfile, tmpdir
351
+ FileUtils.cp workspace_gemfile_lock, tmpdir if File.exist?(workspace_gemfile_lock)
352
+ else
353
+ copy_default_gemfile(File.join(tmpdir, "Gemfile"), server)
354
+ end
387
355
 
388
- log_header('Packaging')
356
+ log_header('Packaging')
389
357
 
390
- ENV['BUNDLE_GEMFILE'] = File.join(tmpdir, "Gemfile")
391
- FileUtils.cd(self.workspace) do
392
- unless system('bundle package --all')
393
- log_and_abort 'Bundler failed. Please check command: bundle package'
394
- end
358
+ ENV['BUNDLE_GEMFILE'] = File.join(tmpdir, "Gemfile")
359
+ FileUtils.cd(self.workspace) do
360
+ unless system('bundle package --all')
361
+ log_and_abort 'Bundler failed. Please check command: bundle package'
395
362
  end
396
- log_header('Verifying dependencies')
397
- verify_dependencies(tmpdir)
398
363
  end
399
-
364
+ log_header('Verifying dependencies')
365
+ verify_dependencies(tmpdir)
400
366
 
401
367
  if dry_run
402
368
  log_header('Dry run only')
@@ -415,7 +381,6 @@ module XamarinTestCloud
415
381
  'device_selection' => device_selection_data,
416
382
  'app' => self.appname,
417
383
  'test_parameters' => self.test_parameters,
418
- 'app_explorer' => self.app_explorer,
419
384
  'locale' => self.locale,
420
385
  'series' => self.series,
421
386
  'api_key' => api_key,
@@ -659,30 +624,25 @@ module XamarinTestCloud
659
624
  def all_files(tmpdir)
660
625
  dir = workspace
661
626
 
662
- if self.app_explorer
663
- files = []
664
- else
665
- files = Dir.glob(File.join("#{dir}features", '**', '*'))
666
-
667
- if File.directory?("#{dir}playback")
668
- files += Dir.glob(File.join("#{dir}playback", '*'))
669
- end
627
+ files = Dir.glob(File.join("#{dir}features", '**', '*'))
670
628
 
671
- if config
672
- files << config
673
- end
629
+ if File.directory?("#{dir}playback")
630
+ files += Dir.glob(File.join("#{dir}playback", '*'))
631
+ end
674
632
 
675
- files += Dir.glob(File.join(tmpdir,"vendor", 'cache', '*'))
633
+ if config
634
+ files << config
635
+ end
676
636
 
677
- if workspace and workspace.strip != ''
678
- files += Dir.glob("#{workspace}Gemfile")
679
- files += Dir.glob("#{workspace}Gemfile.lock")
680
- end
637
+ files += Dir.glob(File.join(tmpdir,"vendor", 'cache', '*'))
681
638
 
682
- if is_android?
683
- files << test_server_path
684
- end
639
+ if workspace and workspace.strip != ''
640
+ files += Dir.glob("#{workspace}Gemfile")
641
+ files += Dir.glob("#{workspace}Gemfile.lock")
642
+ end
685
643
 
644
+ if is_android?
645
+ files << test_server_path
686
646
  end
687
647
 
688
648
  {:feature_prefix => dir, :workspace_prefix => workspace, :files => files.find_all { |file_or_dir| File.file? file_or_dir }}
@@ -694,8 +654,13 @@ module XamarinTestCloud
694
654
  end
695
655
  end
696
656
 
657
+ def host
658
+ ENV['XTC_ENDPOINT'] || 'https://testcloud.xamarin.com/ci'
659
+ end
660
+
697
661
  def http_post(address, args = {}, &block)
698
662
  args['uploader_version'] = XamarinTestCloud::VERSION
663
+ args['session_id'] = session_id
699
664
  exec_options = {}
700
665
  if ENV['XTC_USERNAME'] && ENV['XTC_PASSWORD']
701
666
  exec_options[:user] = ENV['XTC_USERNAME']
@@ -758,8 +723,12 @@ module XamarinTestCloud
758
723
 
759
724
 
760
725
  def log(message)
761
- puts "#{Time.now } #{message}"
762
- $stdout.flush
726
+ if message.is_a? Array
727
+ message.each{ |m| log(m)}
728
+ else
729
+ puts "#{Time.now } #{message}"
730
+ $stdout.flush
731
+ end
763
732
  end
764
733
 
765
734
  def log_header(message)
@@ -1,3 +1,3 @@
1
1
  module XamarinTestCloud
2
- VERSION = '0.9.38'
2
+ VERSION = '0.10.0.pre1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xamarin-test-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.38
4
+ version: 0.10.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-06 00:00:00.000000000 Z
12
+ date: 2014-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -164,12 +164,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  requirements:
167
- - - '>='
167
+ - - '>'
168
168
  - !ruby/object:Gem::Version
169
- version: '0'
169
+ version: 1.3.1
170
170
  requirements: []
171
171
  rubyforge_project:
172
- rubygems_version: 2.0.2
172
+ rubygems_version: 2.1.10
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Command-line interface to Xamarin Test Cloud