Class: Fastlane::Actions::MultiScanAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::MultiScanAction
- Defined in:
- lib/fastlane/plugin/retry/actions/multi_scan.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .scan_options ⇒ Object
Class Method Summary collapse
-
.config_with_retry(config, count) ⇒ Object
Create scan config.
-
.get_folder_root(folder) ⇒ Object
Get folder location.
-
.merge_reports(scan_options, final_report_path) ⇒ Object
Merge results from all retries.
-
.parse_failures(plist, scheme_name) ⇒ Object
Parse the names of the failed test cases.
- .plist_report_filepath(config) ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
111 112 113 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 111 def self. ["Gloria Chow/@gmgchow"] end |
.available_options ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 98 def self. + [ FastlaneCore::ConfigItem.new( key: :try_count, env_name: "FL_MULTI_SCAN_TRY_COUNT", description: "The number of times to retry running tests via scan", type: Integer, is_string: false, default_value: 1 ) ] end |
.config_with_retry(config, count) ⇒ Object
Create scan config
65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 65 def self.config_with_retry(config, count) folder = get_folder_root(config[:result_bundle]) config[:result_bundle] = (folder + count.to_s) config[:output_directory] = (folder + count.to_s) config end |
.description ⇒ Object
86 87 88 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 86 def self.description "Uses scan to run Xcode tests a given number of times: only re-testing failing tests." end |
.details ⇒ Object
90 91 92 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 90 def self.details "Use this action to run your tests if you have fragile tests that fail sporadically." end |
.get_folder_root(folder) ⇒ Object
Get folder location
73 74 75 76 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 73 def self.get_folder_root(folder) folder = folder.gsub(/ *\d+$/, '') folder end |
.is_supported?(platform) ⇒ Boolean
115 116 117 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 115 def self.is_supported?(platform) platform == :ios end |
.merge_reports(scan_options, final_report_path) ⇒ Object
Merge results from all retries
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 49 def self.merge_reports(, final_report_path) folder = get_folder_root([:output_directory]) report_files = Dir.glob("#{folder}*/**/action_TestSummaries.plist").sort asset_files = Dir.glob("#{folder}*/**/Attachments") log_files = Dir.glob("#{folder}*/**/action.xcactivitylog") if report_files.size > 1 other_action.collate_junit_reports( reports: report_files, collated_report: final_report_path, assets: asset_files, logs: log_files, ) end end |
.parse_failures(plist, scheme_name) ⇒ Object
Parse the names of the failed test cases
38 39 40 41 42 43 44 45 46 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 38 def self.parse_failures(plist, scheme_name) failures = Array.new target_report = File.open(plist) {|f| Nokogiri::XML(f)} failed = target_report.xpath("//key[contains(.,'Failure')]/../key[contains(.,'TestIdentifier')]/following-sibling::string[contains(.,'()') and contains (., '/')]") failed.each do |test_name| failures << ("#{scheme_name}/" + test_name.to_s.split('(')[0].split('>')[1]) end failures end |
.plist_report_filepath(config) ⇒ Object
78 79 80 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 78 def self.plist_report_filepath(config) File.absolute_path(File.join(config[:output_directory], "/#{config[:scheme]}.test_result/TestSummaries.plist")) end |
.run(params) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 9 def self.run(params) try_count = 0 = params.values.reject { |k| k == :try_count } final_report_path = [:result_bundle] unless Helper.test? FastlaneCore::PrintTable.print_values( config: params._values.reject { |k, v| .key?(k) }, title: "Summary for multi_scan" ) end begin try_count += 1 = config_with_retry(, try_count) config = FastlaneCore::Configuration.create(Fastlane::Actions::ScanAction., ) Fastlane::Actions::ScanAction.run(config) rescue FastlaneCore::Interface::FastlaneTestFailure => e UI.verbose("Scan failed with #{e}") if try_count < params[:try_count] report_filepath = plist_report_filepath() failed_tests = parse_failures(report_filepath, params[:scheme]) [:only_testing] = failed_tests retry end end merge_reports(, final_report_path) end |
.scan_options ⇒ Object
94 95 96 |
# File 'lib/fastlane/plugin/retry/actions/multi_scan.rb', line 94 def self. ScanAction. end |