fastlane-plugin-test_center 3.6.3.parallelizing.alpha.2 → 3.6.3.parallelizing.alpha.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
  SHA256:
3
- metadata.gz: 4ce72a79fa8ee214876b899076c621635f770dfab8f5ecefc9dbe229e2be7900
4
- data.tar.gz: cb4710721fe5eb0c0e41d69455ac55fdc24d227fd398add40ef0df1510d6d372
3
+ metadata.gz: 88969e78b0565ded016db040a16b08c6bb20e9c52fbb38c1c508075748e3524d
4
+ data.tar.gz: 6c10a5c1a520b59f569ed6a0c7d43043f80a575919ee1c08093be1fb0322f261
5
5
  SHA512:
6
- metadata.gz: aa787baa29ea8784912fe30976c155eb2b69a7bb490ac3da5fdd5d2556c71a5807ee3d17f2b036dd2307ee2b97d515bb4eedc1cdf0204e86b70b693a409bbd26
7
- data.tar.gz: '09c3acd8862555aea016955840f78808bf4936fda7f041afb5c17dcd64980ffd274d46d4d825249d11ceb36143a1a864505b4717180f5ddbb3aecd4bcf1dcdee'
6
+ metadata.gz: 736fe26642a106929a1289c08575c8ce8b5adfc00b9de2ddbd3675a41efae8fbb9aa6478eca203f7fb74f925d4f24f23e2ffd1690b9cf8ed94e9769c82fab0cd
7
+ data.tar.gz: 672f48b3f962871edd9b25b9ba283026c0d1ba58e0f1e99900a419681f64cfbf33cf4db93d91656da7d830ba1e28cc251423f9e3ddf48ff43d2564cf77b15707
@@ -15,11 +15,9 @@ module Fastlane
15
15
  title: "Summary for multi_scan (test_center v#{Fastlane::TestCenter::VERSION})"
16
16
  )
17
17
  end
18
- unless params[:test_without_building] || params[:skip_build]
19
- build_for_testing(
20
- params._values
21
- )
22
- end
18
+
19
+ prepare_for_testing(params._values)
20
+
23
21
  runner = ::TestCenter::Helper::MultiScanManager::Runner.new(params.values)
24
22
  tests_passed = runner.scan
25
23
  if params[:fail_build] && !tests_passed
@@ -85,28 +83,41 @@ module Fastlane
85
83
  }
86
84
  end
87
85
 
88
- def self.build_for_testing(scan_options)
89
- options_to_remove = %i[
90
- try_count
91
- batch_count
92
- output_files
93
- parallelize
94
- quit_simulators
95
- testrun_completed_block
96
- test_without_building
97
- output_types
98
- ]
99
- config = FastlaneCore::Configuration.create(
86
+ def self.prepare_for_testing(scan_options)
87
+ if scan_options[:test_without_building] || scan_options[:skip_build]
88
+ prepare_scan_config(scan_options)
89
+ else
90
+ build_for_testing(scan_options)
91
+ end
92
+ end
93
+
94
+ def self.prepare_scan_config(scan_options)
95
+ Scan.config ||= FastlaneCore::Configuration.create(
100
96
  Fastlane::Actions::ScanAction.available_options,
101
- scan_options.merge(build_for_testing: true).reject { |k, _| options_to_remove.include?(k) }
97
+ scan_options.select { |k,v| %i[project workspace scheme].include?(k) }
102
98
  )
103
- Fastlane::Actions::ScanAction.run(config)
104
- remove_build_report_files
99
+ end
100
+
101
+ def self.build_for_testing(scan_options)
102
+ valid_scan_keys = Fastlane::Actions::ScanAction.available_options.map(&:key)
103
+ scan_options = scan_options.select { |k,v| valid_scan_keys.include?(k) }
104
+
105
+ Scan.config = FastlaneCore::Configuration.create(
106
+ Fastlane::Actions::ScanAction.available_options,
107
+ scan_options.merge(build_for_testing: true)
108
+ )
109
+ values = Scan.config.values(ask: false)
110
+ values[:xcode_path] = File.expand_path("../..", FastlaneCore::Helper.xcode_path)
111
+ FastlaneCore::PrintTable.print_values(
112
+ config: values,
113
+ hide_keys: [:destination, :slack_url],
114
+ title: "Summary for scan #{Fastlane::VERSION}"
115
+ )
116
+ Scan::Runner.new.run
117
+ remove_build_report_files
105
118
 
106
- scan_options.merge!(
107
- test_without_building: true,
108
- derived_data_path: Scan.config[:derived_data_path]
109
- ).delete(:build_for_testing)
119
+ Scan.config._values.delete(:build_for_testing)
120
+ scan_options[:derived_data_path] = Scan.config[:derived_data_path]
110
121
  end
111
122
 
112
123
  def self.remove_build_report_files
@@ -1,15 +1,16 @@
1
1
  module Fastlane
2
2
  module Actions
3
- class RestartCoreSimulatorServiceAction < Action
3
+ class QuitCoreSimulatorServiceAction < Action
4
4
  def self.run(params)
5
5
  launchctl_list_count = 0
6
+ commands = []
6
7
  while Actions.sh('launchctl list | grep com.apple.CoreSimulator.CoreSimulatorService || true', log: false) != ''
7
8
  UI.crash!('Unable to quit com.apple.CoreSimulator.CoreSimulatorService after 10 tries') if (launchctl_list_count += 1) > 10
8
- commands << Actions.sh('launchctl stop com.apple.CoreSimulator.CoreSimulatorService &> /dev/null || true', log: false)
9
+ commands << Actions.sh('launchctl remove com.apple.CoreSimulator.CoreSimulatorService &> /dev/null || true', log: false)
9
10
  UI.verbose('Waiting for com.apple.CoreSimulator.CoreSimulatorService to quit')
10
- sleep(0.25)
11
+ sleep(0.5)
11
12
  end
12
- commands << Actions.sh('launchctl start com.apple.CoreSimulator.CoreSimulatorService &> /dev/null || true', log: false)
13
+ commands
13
14
  end
14
15
 
15
16
  #####################################################
@@ -17,12 +18,12 @@ module Fastlane
17
18
  #####################################################
18
19
 
19
20
  def self.description
20
- "Restarts the com.apple.CoreSimulator.CoreSimulatorService."
21
+ "Force-quits the com.apple.CoreSimulator.CoreSimulatorService."
21
22
  end
22
23
 
23
24
  def self.details
24
25
  "Sometimes the com.apple.CoreSimulator.CoreSimulatorService can hang. " \
25
- "Use this action to force-restart it."
26
+ "Use this action to force-quit it."
26
27
  end
27
28
 
28
29
  def self.authors
@@ -43,15 +43,16 @@ module TestCenter
43
43
  glob = "#{@source_reports_directory_glob}/#{@reportnamer.junit_fileglob}"
44
44
  report_files = sort_globbed_files(glob)
45
45
  if report_files.size > 1
46
+ collated_file = File.absolute_path(File.join(@output_directory, @reportnamer.junit_reportname(@suffix)))
46
47
  config = create_config(
47
48
  CollateJunitReportsAction,
48
49
  {
49
50
  reports: report_files,
50
- collated_report: File.absolute_path(File.join(@output_directory, @reportnamer.junit_reportname(@suffix)))
51
+ collated_report: collated_file
51
52
  }
52
53
  )
53
54
  CollateJunitReportsAction.run(config)
54
- delete_globbed_intermediatefiles("#{@source_reports_directory_glob}/#{@reportnamer.junit_numbered_fileglob}")
55
+ FileUtils.rm_rf(report_files - [collated_file])
55
56
  end
56
57
  end
57
58
 
@@ -60,15 +61,16 @@ module TestCenter
60
61
 
61
62
  report_files = sort_globbed_files("#{@source_reports_directory_glob}/#{@reportnamer.html_fileglob}")
62
63
  if report_files.size > 1
64
+ collated_file = File.absolute_path(File.join(@output_directory, @reportnamer.html_reportname(@suffix)))
63
65
  config = create_config(
64
66
  CollateJunitReportsAction,
65
67
  {
66
68
  reports: report_files,
67
- collated_report: File.absolute_path(File.join(@output_directory, @reportnamer.html_reportname(@suffix)))
69
+ collated_report: collated_file
68
70
  }
69
71
  )
70
72
  CollateHtmlReportsAction.run(config)
71
- delete_globbed_intermediatefiles("#{@source_reports_directory_glob}/#{@reportnamer.html_numbered_fileglob}")
73
+ FileUtils.rm_rf(report_files - [collated_file])
72
74
  end
73
75
  end
74
76
 
@@ -76,17 +78,17 @@ module TestCenter
76
78
  return unless @reportnamer.includes_json?
77
79
 
78
80
  report_files = sort_globbed_files("#{@source_reports_directory_glob}/#{@reportnamer.json_fileglob}")
79
-
80
81
  if report_files.size > 1
82
+ collated_file = File.absolute_path(File.join(@output_directory, @reportnamer.json_reportname(@suffix)))
81
83
  config = create_config(
82
84
  CollateJsonReportsAction,
83
85
  {
84
86
  reports: report_files,
85
- collated_report: File.absolute_path(File.join(@output_directory, @reportnamer.json_reportname(@suffix)))
87
+ collated_report: collated_file
86
88
  }
87
89
  )
88
90
  CollateJsonReportsAction.run(config)
89
- delete_globbed_intermediatefiles("#{@source_reports_directory_glob}/#{@reportnamer.json_numbered_fileglob}")
91
+ FileUtils.rm_rf(report_files - [collated_file])
90
92
  end
91
93
  end
92
94
 
@@ -94,17 +96,17 @@ module TestCenter
94
96
  return unless @result_bundle
95
97
 
96
98
  test_result_bundlepaths = sort_globbed_files("#{@source_reports_directory_glob}/#{@scheme}*.test_result")
97
-
98
99
  if test_result_bundlepaths.size > 1
100
+ collated_test_result_bundlepath = File.absolute_path("#{File.join(@output_directory, @scheme)}.test_result'")
99
101
  config = create_config(
100
102
  CollateTestResultBundlesAction,
101
103
  {
102
104
  bundles: test_result_bundlepaths,
103
- collated_bundle: "#{File.join(@output_directory, @scheme)}.test_result'"
105
+ collated_bundle: collated_test_result_bundlepath
104
106
  }
105
107
  )
106
108
  CollateTestResultBundlesAction.run(config)
107
- delete_globbed_intermediatefiles("#{@source_reports_directory_glob}/#{@scheme}-[1-9]*.test_result")
109
+ FileUtils.rm_rf(report_files - [collated_test_result_bundlepath])
108
110
  end
109
111
  end
110
112
  end
@@ -1,26 +1,14 @@
1
1
  module TestCenter
2
2
  module Helper
3
3
  module MultiScanManager
4
+
4
5
  class RetryingScan
5
6
  def initialize(options = {})
6
7
  @options = options
7
8
  @retrying_scan_helper = RetryingScanHelper.new(options)
8
9
  end
9
10
 
10
- def delete_xcresults
11
- derived_data_path = File.expand_path(scan_config[:derived_data_path])
12
- xcresults = Dir.glob("#{derived_data_path}/Logs/Test/*.xcresult")
13
- FastlaneCore::UI.message("Deleting xcresults: #{xcresults}")
14
- FileUtils.rm_rf(xcresults)
15
- end
16
-
17
11
  def scan_config
18
- if Scan.config.nil?
19
- Scan.config = FastlaneCore::Configuration.create(
20
- Fastlane::Actions::ScanAction.available_options,
21
- @options.select { |k,v| %i[project workspace scheme].include?(k) }
22
- )
23
- end
24
12
  Scan.config
25
13
  end
26
14
 
@@ -29,9 +17,8 @@ module TestCenter
29
17
  scan_options = @options.select { |k,v| valid_scan_keys.include?(k) }
30
18
  .merge(@retrying_scan_helper.scan_options)
31
19
 
32
- sc = scan_config
33
20
  scan_options.each do |k,v|
34
- sc.set(k,v) unless v.nil?
21
+ scan_config.set(k,v) unless v.nil?
35
22
  end
36
23
  end
37
24
 
@@ -41,7 +28,14 @@ module TestCenter
41
28
  # TODO move delete_xcresults to `before_testrun`
42
29
  @retrying_scan_helper.before_testrun
43
30
  update_scan_options
44
- delete_xcresults # has to be performed _after_ moving a *.test_result
31
+
32
+ values = scan_config.values(ask: false)
33
+ values[:xcode_path] = File.expand_path("../..", FastlaneCore::Helper.xcode_path)
34
+ FastlaneCore::PrintTable.print_values(
35
+ config: values,
36
+ hide_keys: [:destination, :slack_url],
37
+ title: "Summary for scan #{Fastlane::VERSION}"
38
+ ) unless FastlaneCore::Helper.test?
45
39
 
46
40
  Scan::Runner.new.run
47
41
  @retrying_scan_helper.after_testrun
@@ -13,20 +13,36 @@ module TestCenter
13
13
  @options = options
14
14
  @testrun_count = 0
15
15
  @xcpretty_json_file_output = ENV['XCPRETTY_JSON_FILE_OUTPUT']
16
-
17
16
  @reportnamer = ReportNameHelper.new(
18
- options[:output_types],
19
- options[:output_files],
20
- options[:custom_report_file_name]
17
+ @options[:output_types],
18
+ @options[:output_files],
19
+ @options[:custom_report_file_name]
21
20
  )
22
21
  end
23
22
 
24
23
  def before_testrun
25
24
  remove_preexisting_test_result_bundles
25
+ delete_xcresults # has to be performed _after_ moving a *.test_result
26
+
26
27
  set_json_env
27
28
  print_starting_scan_message
28
29
  end
29
30
 
31
+ def delete_xcresults
32
+ derived_data_path = File.expand_path(@options[:derived_data_path] || Scan.config[:derived_data_path])
33
+ xcresults = Dir.glob("#{derived_data_path}/Logs/Test/*.xcresult")
34
+ FastlaneCore::UI.message("Deleting xcresults: #{xcresults}")
35
+ FileUtils.rm_rf(xcresults)
36
+ end
37
+
38
+ def output_directory
39
+ absolute_output_directory = File.absolute_path(@options[:output_directory])
40
+ if @options[:batch]
41
+ absolute_output_directory = File.join(absolute_output_directory, "batch-#{@options[:batch]}")
42
+ end
43
+ absolute_output_directory
44
+ end
45
+
30
46
  def print_starting_scan_message
31
47
  scan_message = "Starting scan ##{@testrun_count + 1} with #{@options.fetch(:only_testing, []).size} tests"
32
48
  scan_message << " for batch ##{@options[:batch]}" unless @options[:batch].nil?
@@ -37,7 +53,7 @@ module TestCenter
37
53
  return unless @reportnamer.includes_json?
38
54
 
39
55
  ENV['XCPRETTY_JSON_FILE_OUTPUT'] = File.join(
40
- @options[:output_directory],
56
+ output_directory,
41
57
  @reportnamer.json_last_reportname
42
58
  )
43
59
  end
@@ -51,8 +67,7 @@ module TestCenter
51
67
  def remove_preexisting_test_result_bundles
52
68
  return unless @options[:result_bundle]
53
69
 
54
- absolute_output_directory = File.absolute_path(@options[:output_directory])
55
- glob_pattern = "#{absolute_output_directory}/*.test_result"
70
+ glob_pattern = "#{output_directory}/*.test_result"
56
71
  preexisting_test_result_bundles = Dir.glob(glob_pattern)
57
72
  FileUtils.rm_rf(preexisting_test_result_bundles)
58
73
  end
@@ -61,6 +76,7 @@ module TestCenter
61
76
  valid_scan_keys = Fastlane::Actions::ScanAction.available_options.map(&:key)
62
77
  @options.select { |k,v| valid_scan_keys.include?(k) }
63
78
  .merge(@reportnamer.scan_options)
79
+ .merge(output_directory: output_directory)
64
80
  end
65
81
 
66
82
  # after_testrun methods
@@ -74,25 +90,25 @@ module TestCenter
74
90
  else
75
91
  handle_success
76
92
  end
93
+ collate_reports
77
94
  end
78
95
 
79
96
  def handle_success
80
97
  send_callback_testrun_info
81
98
  move_test_result_bundle_for_next_run
82
99
  reset_json_env
83
- collate_reports
84
100
  end
85
101
 
86
102
  def collate_reports
87
- absolute_output_directory = File.absolute_path(@options[:output_directory])
88
103
 
89
- TestCenter::Helper::MultiScanManager::ReportCollator.new(
90
- source_reports_directory_glob: absolute_output_directory,
91
- output_directory: absolute_output_directory,
104
+ report_collator_options = {
105
+ source_reports_directory_glob: output_directory,
106
+ output_directory: output_directory,
92
107
  reportnamer: @reportnamer,
93
108
  scheme: @options[:scheme],
94
109
  result_bundle: @options[:result_bundle]
95
- ).collate
110
+ }
111
+ TestCenter::Helper::MultiScanManager::ReportCollator.new(report_collator_options).collate
96
112
  end
97
113
 
98
114
  def handle_test_failure
@@ -109,7 +125,7 @@ module TestCenter
109
125
  report_filepath = nil
110
126
  junit_results = {}
111
127
  unless additional_info.key?(:test_operation_failure)
112
- report_filepath = File.absolute_path(File.join(@options[:output_directory], @reportnamer.junit_last_reportname))
128
+ report_filepath = File.join(output_directory, @reportnamer.junit_last_reportname)
113
129
 
114
130
  config = FastlaneCore::Configuration.create(
115
131
  Fastlane::Actions::TestsFromJunitAction.available_options,
@@ -123,23 +139,23 @@ module TestCenter
123
139
  info = {
124
140
  failed: junit_results[:failed],
125
141
  passing: junit_results[:passing],
126
- batch: 1,
142
+ batch: @options[:batch] || 1,
127
143
  try_count: @testrun_count,
128
144
  report_filepath: report_filepath
129
145
  }.merge(additional_info)
130
146
 
131
147
  if @reportnamer.includes_html?
132
- html_report_filepath = File.join(@options[:output_directory], @reportnamer.html_last_reportname)
148
+ html_report_filepath = File.join(output_directory, @reportnamer.html_last_reportname)
133
149
  info[:html_report_filepath] = html_report_filepath
134
150
  end
135
151
  if @reportnamer.includes_json?
136
- json_report_filepath = File.join(@options[:output_directory], @reportnamer.json_last_reportname)
152
+ json_report_filepath = File.join(output_directory, @reportnamer.json_last_reportname)
137
153
  info[:json_report_filepath] = json_report_filepath
138
154
  end
139
155
  if @options[:result_bundle]
140
156
  test_result_suffix = '.test_result'
141
157
  test_result_suffix.prepend("-#{@reportnamer.report_count}") unless @reportnamer.report_count.zero?
142
- test_result_bundlepath = File.join(@options[:output_directory], @options[:scheme]) + test_result_suffix
158
+ test_result_bundlepath = File.join(output_directory, @options[:scheme]) + test_result_suffix
143
159
  info[:test_result_bundlepath] = test_result_bundlepath
144
160
  end
145
161
  @options[:testrun_completed_block].call(info)
@@ -157,7 +173,7 @@ module TestCenter
157
173
  end
158
174
 
159
175
  def update_only_testing
160
- report_filepath = File.join(@options[:output_directory], @reportnamer.junit_last_reportname)
176
+ report_filepath = File.join(output_directory, @reportnamer.junit_last_reportname)
161
177
  config = FastlaneCore::Configuration.create(
162
178
  Fastlane::Actions::TestsFromJunitAction.available_options,
163
179
  {
@@ -217,8 +233,7 @@ module TestCenter
217
233
  def move_test_result_bundle_for_next_run
218
234
  return unless @options[:result_bundle]
219
235
 
220
- absolute_output_directory = File.absolute_path(@options[:output_directory])
221
- glob_pattern = "#{absolute_output_directory}/*.test_result"
236
+ glob_pattern = "#{output_directory}/*.test_result"
222
237
  preexisting_test_result_bundles = Dir.glob(glob_pattern)
223
238
  unnumbered_test_result_bundles = preexisting_test_result_bundles.reject do |test_result|
224
239
  test_result =~ /.*-\d+\.test_result/
@@ -58,16 +58,10 @@ module TestCenter
58
58
  def scan
59
59
  all_tests_passed = true
60
60
  @testables_count = @test_collector.testables.size
61
+ FileUtils.rm_rf(Dir.glob("#{@output_directory}/**/*.{junit,html,xml,json}"))
61
62
  all_tests_passed = each_batch do |test_batch, current_batch_index|
62
63
  if ENV['USE_REFACTORED_PARALLELIZED_MULTI_SCAN']
63
- retrying_scan = TestCenter::Helper::MultiScanManager::RetryingScan.new(
64
- @scan_options.merge(
65
- only_testing: test_batch.map(&:shellsafe_testidentifier),
66
- output_directory: @output_directory,
67
- try_count: @try_count
68
- ).reject { |key| %i[device devices].include?(key) }
69
- )
70
- retrying_scan.run
64
+ run_test_batch_through_retrying_scan(test_batch, current_batch_index)
71
65
  else
72
66
  output_directory = testrun_output_directory(@output_directory, test_batch, current_batch_index)
73
67
  reset_for_new_testable(output_directory)
@@ -94,9 +88,45 @@ module TestCenter
94
88
  end
95
89
  testrun_passed && all_tests_passed
96
90
  end
91
+ if ENV['USE_REFACTORED_PARALLELIZED_MULTI_SCAN']
92
+ collate_batched_reports
93
+ end
97
94
  all_tests_passed
98
95
  end
99
96
 
97
+ def run_test_batch_through_retrying_scan(test_batch, current_batch_index)
98
+ FastlaneCore::UI.important("Investigate using rbspy for perf problems: https://github.com/rbspy/rbspy")
99
+ retrying_scan = TestCenter::Helper::MultiScanManager::RetryingScan.new(
100
+ @scan_options.merge(
101
+ only_testing: test_batch.map(&:shellsafe_testidentifier),
102
+ output_directory: @output_directory,
103
+ try_count: @try_count,
104
+ batch: current_batch_index + 1
105
+ ).reject { |key| %i[device devices].include?(key) }
106
+ )
107
+ retrying_scan.run
108
+ end
109
+
110
+ def collate_batched_reports
111
+ return unless @batch_count > 1
112
+
113
+ absolute_output_directory = File.absolute_path(@output_directory)
114
+ source_reports_directory_glob = File.join(absolute_output_directory, "batch-*")
115
+
116
+ TestCenter::Helper::MultiScanManager::ReportCollator.new(
117
+ source_reports_directory_glob: source_reports_directory_glob,
118
+ output_directory: absolute_output_directory,
119
+ reportnamer: @reportnamer = ReportNameHelper.new(
120
+ @given_output_types,
121
+ @given_output_files,
122
+ @given_custom_report_file_name
123
+ ),
124
+ scheme: @scan_options[:scheme],
125
+ result_bundle: @scan_options[:result_bundle]
126
+ ).collate
127
+ FileUtils.rm_rf(Dir.glob(source_reports_directory_glob))
128
+ end
129
+
100
130
  def each_batch
101
131
  tests_passed = true
102
132
  if @parallelize
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TestCenter
3
- VERSION = "3.6.3.parallelizing.alpha.2"
3
+ VERSION = "3.6.3.parallelizing.alpha.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-test_center
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.3.parallelizing.alpha.2
4
+ version: 3.6.3.parallelizing.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lyndsey Ferguson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-16 00:00:00.000000000 Z
11
+ date: 2019-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json