Class: TestCenter::Helper::MultiScanManager::RetryingScan

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RetryingScan

Returns a new instance of RetryingScan.



5
6
7
8
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb', line 5

def initialize(options = {})
  @options = options
  @retrying_scan_helper = RetryingScanHelper.new(@options)
end

Class Method Details

.run(options) ⇒ Object

:nocov:



44
45
46
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb', line 44

def self.run(options)
  RetryingScan.new(options).run
end

Instance Method Details

#prepare_scan_config_for_destinationObject

:nocov:



20
21
22
23
24
25
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb', line 20

def prepare_scan_config_for_destination
  # this allows multi_scan's `destination` option to be picked up by `scan`
  scan_config._values.delete(:device)
  scan_config._values.delete(:devices)
  scan_cache.clear
end

#runObject

:nocov:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb', line 49

def run
  try_count = @options[:try_count] || 1
  begin
    @retrying_scan_helper.before_testrun
    update_scan_options
    
    values = scan_config.values(ask: false)
    values[:xcode_path] = File.expand_path("../..", FastlaneCore::Helper.xcode_path)
    ScanHelper.print_scan_parameters(values)

    Scan::Runner.new.run
    @retrying_scan_helper.after_testrun
    true
  rescue FastlaneCore::Interface::FastlaneTestFailure => e
    @retrying_scan_helper.after_testrun(e)
    retry if @retrying_scan_helper.testrun_count < try_count
    false
  rescue FastlaneCore::Interface::FastlaneBuildFailure => e
    @retrying_scan_helper.after_testrun(e)
    retry if @retrying_scan_helper.testrun_count < try_count
    false
  end
end

#scan_cacheObject



15
16
17
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb', line 15

def scan_cache
  Scan.cache
end

#scan_configObject

:nocov:



11
12
13
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb', line 11

def scan_config
  Scan.config
end

#update_scan_optionsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb', line 27

def update_scan_options
  valid_scan_keys = Fastlane::Actions::ScanAction.available_options.map(&:key)
  scan_options = @options.select { |k,v| valid_scan_keys.include?(k) }
                          .merge(@retrying_scan_helper.scan_options)

  prepare_scan_config_for_destination
  scan_options[:build_for_testing] = false
  FastlaneCore::UI.verbose("retrying_scan #update_scan_options")
  scan_options.each do |k,v|
    next if v.nil?
 
    scan_config.set(k,v) unless v.nil?
    FastlaneCore::UI.verbose("\tSetting #{k.to_s} to #{v}")
  end
end