fastlane-plugin-test_center 3.6.3.parallelizing.alpha.3 → 3.6.3.parallelizing.pre.alpha.pre.1

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: 88969e78b0565ded016db040a16b08c6bb20e9c52fbb38c1c508075748e3524d
4
- data.tar.gz: 6c10a5c1a520b59f569ed6a0c7d43043f80a575919ee1c08093be1fb0322f261
3
+ metadata.gz: 0b03566f2644f92ffde801c8d83a6bd009e59fd947437cf9b6ea26b737ae0996
4
+ data.tar.gz: 80d1d785126c154dfda7a2aee7ded8654bd58776746144550e7d37c863e126c4
5
5
  SHA512:
6
- metadata.gz: 736fe26642a106929a1289c08575c8ce8b5adfc00b9de2ddbd3675a41efae8fbb9aa6478eca203f7fb74f925d4f24f23e2ffd1690b9cf8ed94e9769c82fab0cd
7
- data.tar.gz: 672f48b3f962871edd9b25b9ba283026c0d1ba58e0f1e99900a419681f64cfbf33cf4db93d91656da7d830ba1e28cc251423f9e3ddf48ff43d2564cf77b15707
6
+ metadata.gz: 481326edd2420e6cc1f5347c434b0089b32dc526e0e09a1279fd8131855771711fb8676a3251e5d3003bb7a35dcd6ba2cb1b505d62b482395fe06ec3df4e5f3b
7
+ data.tar.gz: f4360d6b14dda570832bba2b9c86e127beea79f83a23fd3e4c0730e017b2f51e6216c5b0fa4ccd688fc0acd1d01d5d0376718cae53f13f402477f7aa8054ed8e
@@ -15,9 +15,11 @@ module Fastlane
15
15
  title: "Summary for multi_scan (test_center v#{Fastlane::TestCenter::VERSION})"
16
16
  )
17
17
  end
18
-
19
- prepare_for_testing(params._values)
20
-
18
+ unless params[:test_without_building] || params[:skip_build]
19
+ build_for_testing(
20
+ params._values
21
+ )
22
+ end
21
23
  runner = ::TestCenter::Helper::MultiScanManager::Runner.new(params.values)
22
24
  tests_passed = runner.scan
23
25
  if params[:fail_build] && !tests_passed
@@ -83,41 +85,28 @@ module Fastlane
83
85
  }
84
86
  end
85
87
 
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(
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(
96
100
  Fastlane::Actions::ScanAction.available_options,
97
- scan_options.select { |k,v| %i[project workspace scheme].include?(k) }
101
+ scan_options.merge(build_for_testing: true).reject { |k, _| options_to_remove.include?(k) }
98
102
  )
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
103
+ Fastlane::Actions::ScanAction.run(config)
104
+ remove_build_report_files
118
105
 
119
- Scan.config._values.delete(:build_for_testing)
120
- scan_options[:derived_data_path] = Scan.config[:derived_data_path]
106
+ scan_options.merge!(
107
+ test_without_building: true,
108
+ derived_data_path: Scan.config[:derived_data_path]
109
+ ).delete(:build_for_testing)
121
110
  end
122
111
 
123
112
  def self.remove_build_report_files
@@ -1,16 +1,15 @@
1
1
  module Fastlane
2
2
  module Actions
3
- class QuitCoreSimulatorServiceAction < Action
3
+ class RestartCoreSimulatorServiceAction < Action
4
4
  def self.run(params)
5
5
  launchctl_list_count = 0
6
- commands = []
7
6
  while Actions.sh('launchctl list | grep com.apple.CoreSimulator.CoreSimulatorService || true', log: false) != ''
8
7
  UI.crash!('Unable to quit com.apple.CoreSimulator.CoreSimulatorService after 10 tries') if (launchctl_list_count += 1) > 10
9
- commands << Actions.sh('launchctl remove com.apple.CoreSimulator.CoreSimulatorService &> /dev/null || true', log: false)
8
+ commands << Actions.sh('launchctl stop com.apple.CoreSimulator.CoreSimulatorService &> /dev/null || true', log: false)
10
9
  UI.verbose('Waiting for com.apple.CoreSimulator.CoreSimulatorService to quit')
11
- sleep(0.5)
10
+ sleep(0.25)
12
11
  end
13
- commands
12
+ commands << Actions.sh('launchctl start com.apple.CoreSimulator.CoreSimulatorService &> /dev/null || true', log: false)
14
13
  end
15
14
 
16
15
  #####################################################
@@ -18,12 +17,12 @@ module Fastlane
18
17
  #####################################################
19
18
 
20
19
  def self.description
21
- "Force-quits the com.apple.CoreSimulator.CoreSimulatorService."
20
+ "Restarts the com.apple.CoreSimulator.CoreSimulatorService."
22
21
  end
23
22
 
24
23
  def self.details
25
24
  "Sometimes the com.apple.CoreSimulator.CoreSimulatorService can hang. " \
26
- "Use this action to force-quit it."
25
+ "Use this action to force-restart it."
27
26
  end
28
27
 
29
28
  def self.authors
@@ -43,16 +43,15 @@ 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)))
47
46
  config = create_config(
48
47
  CollateJunitReportsAction,
49
48
  {
50
49
  reports: report_files,
51
- collated_report: collated_file
50
+ collated_report: File.absolute_path(File.join(@output_directory, @reportnamer.junit_reportname(@suffix)))
52
51
  }
53
52
  )
54
53
  CollateJunitReportsAction.run(config)
55
- FileUtils.rm_rf(report_files - [collated_file])
54
+ delete_globbed_intermediatefiles("#{@source_reports_directory_glob}/#{@reportnamer.junit_numbered_fileglob}")
56
55
  end
57
56
  end
58
57
 
@@ -61,16 +60,15 @@ module TestCenter
61
60
 
62
61
  report_files = sort_globbed_files("#{@source_reports_directory_glob}/#{@reportnamer.html_fileglob}")
63
62
  if report_files.size > 1
64
- collated_file = File.absolute_path(File.join(@output_directory, @reportnamer.html_reportname(@suffix)))
65
63
  config = create_config(
66
64
  CollateJunitReportsAction,
67
65
  {
68
66
  reports: report_files,
69
- collated_report: collated_file
67
+ collated_report: File.absolute_path(File.join(@output_directory, @reportnamer.html_reportname(@suffix)))
70
68
  }
71
69
  )
72
70
  CollateHtmlReportsAction.run(config)
73
- FileUtils.rm_rf(report_files - [collated_file])
71
+ delete_globbed_intermediatefiles("#{@source_reports_directory_glob}/#{@reportnamer.html_numbered_fileglob}")
74
72
  end
75
73
  end
76
74
 
@@ -78,17 +76,17 @@ module TestCenter
78
76
  return unless @reportnamer.includes_json?
79
77
 
80
78
  report_files = sort_globbed_files("#{@source_reports_directory_glob}/#{@reportnamer.json_fileglob}")
79
+
81
80
  if report_files.size > 1
82
- collated_file = File.absolute_path(File.join(@output_directory, @reportnamer.json_reportname(@suffix)))
83
81
  config = create_config(
84
82
  CollateJsonReportsAction,
85
83
  {
86
84
  reports: report_files,
87
- collated_report: collated_file
85
+ collated_report: File.absolute_path(File.join(@output_directory, @reportnamer.json_reportname(@suffix)))
88
86
  }
89
87
  )
90
88
  CollateJsonReportsAction.run(config)
91
- FileUtils.rm_rf(report_files - [collated_file])
89
+ delete_globbed_intermediatefiles("#{@source_reports_directory_glob}/#{@reportnamer.json_numbered_fileglob}")
92
90
  end
93
91
  end
94
92
 
@@ -96,17 +94,17 @@ module TestCenter
96
94
  return unless @result_bundle
97
95
 
98
96
  test_result_bundlepaths = sort_globbed_files("#{@source_reports_directory_glob}/#{@scheme}*.test_result")
97
+
99
98
  if test_result_bundlepaths.size > 1
100
- collated_test_result_bundlepath = File.absolute_path("#{File.join(@output_directory, @scheme)}.test_result'")
101
99
  config = create_config(
102
100
  CollateTestResultBundlesAction,
103
101
  {
104
102
  bundles: test_result_bundlepaths,
105
- collated_bundle: collated_test_result_bundlepath
103
+ collated_bundle: "#{File.join(@output_directory, @scheme)}.test_result'"
106
104
  }
107
105
  )
108
106
  CollateTestResultBundlesAction.run(config)
109
- FileUtils.rm_rf(report_files - [collated_test_result_bundlepath])
107
+ delete_globbed_intermediatefiles("#{@source_reports_directory_glob}/#{@scheme}-[1-9]*.test_result")
110
108
  end
111
109
  end
112
110
  end
@@ -1,14 +1,26 @@
1
1
  module TestCenter
2
2
  module Helper
3
3
  module MultiScanManager
4
-
5
4
  class RetryingScan
6
5
  def initialize(options = {})
7
6
  @options = options
8
7
  @retrying_scan_helper = RetryingScanHelper.new(options)
9
8
  end
10
9
 
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
+
11
17
  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
12
24
  Scan.config
13
25
  end
14
26
 
@@ -17,26 +29,38 @@ module TestCenter
17
29
  scan_options = @options.select { |k,v| valid_scan_keys.include?(k) }
18
30
  .merge(@retrying_scan_helper.scan_options)
19
31
 
32
+ sc = scan_config
20
33
  scan_options.each do |k,v|
21
- scan_config.set(k,v) unless v.nil?
34
+ sc.set(k,v) unless v.nil?
22
35
  end
23
36
  end
24
37
 
25
38
  def run
39
+ update_scan_options
40
+ delete_xcresults
41
+
26
42
  try_count = @options[:try_count] || 1
27
43
  begin
28
- # TODO move delete_xcresults to `before_testrun`
29
44
  @retrying_scan_helper.before_testrun
30
- update_scan_options
45
+
31
46
 
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?
39
47
 
48
+ # TODO: Investigate the following error:
49
+ """
50
+ 2019-05-09 13:32:40.707 xcodebuild[78535:1944070] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks_Fall2018/IDEFrameworks-14460.46/IDEFoundation/ProjectModel/ActionRecords/IDESchemeActionTestAttachment.m:186
51
+ Details: Error writing attachment data to file /Users/lyndsey.ferguson/Library/Developer/Xcode/DerivedData/AtomicBoy-flqqvvvzbouqymbyffgdbtjoiufr/Logs/Test/Test-Transient Testing-2019.05.09_13-32-08--0400.xcresult/1_Test/Attachments/Screenshot_E0AE7940-E7F4-4CA8-BB2B-8822D730D10F.jpg: Error Domain=NSCocoaErrorDomain Code=4 \"The folder “Screenshot_E0AE7940-E7F4-4CA8-BB2B-8822D730D10F.jpg” doesn’t exist.\" UserInfo={NSFilePath=/Users/lyndsey.ferguson/Library/Developer/Xcode/DerivedData/AtomicBoy-flqqvvvzbouqymbyffgdbtjoiufr/Logs/Test/Test-Transient Testing-2019.05.09_13-32-08--0400.xcresult/1_Test/Attachments/Screenshot_E0AE7940-E7F4-4CA8-BB2B-8822D730D10F.jpg, NSUserStringVariant=Folder, NSUnderlyingError=0x7fa6ef34ef90 {Error Domain=NSPOSIXErrorDomain Code=2 \"No such file or directory\"}}
52
+ Object: <IDESchemeActionTestAttachment: 0x7fa6ef22d270>
53
+ Method: -_savePayload:
54
+ Thread: <NSThread: 0x7fa6ea516110>{number = 1, name = main}
55
+ Please file a bug at https://bugreport.apple.com with this warning message and any useful information you can provide.
56
+
57
+ It may be due to:
58
+ 2019-05-09 14:17:30.933 xcodebuild[86893:2045058] IDETestOperationsObserverDebug: Failed to move logarchive from /Users/lyndsey.ferguson/Library/Developer/CoreSimulator/Devices/0D312041-2D60-4221-94CC-3B0040154D74/data/tmp/test-session-systemlogs-2019.05.09_14-17-04--0400.logarchive to diagnostics location /Users/lyndsey.ferguson/Library/Developer/Xcode/DerivedData/AtomicBoy-flqqvvvzbouqymbyffgdbtjoiufr/Logs/Test/Test-Transient Testing-2019.05.09_14-17-04--0400.xcresult/1_Test/Diagnostics/iPhone 5s_0D312041-2D60-4221-94CC-3B0040154D74/test-session-systemlogs-2019.05.09_14-17-04--0400.logarchive: Error Domain=NSCocoaErrorDomain Code=4 \"“test-session-systemlogs-2019.05.09_14-17-04--0400.logarchive” couldn’t be moved to “iPhone 5s_0D312041-2D60-4221-94CC-3B0040154D74” because either the former doesn’t exist, or the folder containing the latter doesn’t exist.\" UserInfo={NSSourceFilePathErrorKey=/Users/lyndsey.ferguson/Library/Developer/CoreSimulator/Devices/0D312041-2D60-4221-94CC-3B0040154D74/data/tmp/test-session-systemlogs-2019.05.09_14-17-04--0400.logarchive, NSUserStringVariant=(
59
+ Move
60
+ ), NSDestinationFilePath=/Users/lyndsey.ferguson/Library/Developer/Xcode/DerivedData/AtomicBoy-flqqvvvzbouqymbyffgdbtjoiufr/Logs/Test/Test-Transient Testing-2019.05.09_14-17-04--0400.xcresult/1_Test/Diagnostics/iPhone 5s_0D312041-2D60-4221-94CC-3B0040154D74/test-session-systemlogs-2019.05.09_14-17-04--0400.logarchive, NSFilePath=/Users/lyndsey.ferguson/Library/Developer/CoreSimulator/Devices/0D312041-2D60-4221-94CC-3B0040154D74/data/tmp/test-session-systemlogs-2019.05.09_14-17-04--0400.logarchive, NSUnderlyingError=0x7fdf96c6de90 {Error Domain=NSPOSIXErrorDomain Code=2 \"No such file or directory\"}}
61
+
62
+ """
63
+ update_scan_options
40
64
  Scan::Runner.new.run
41
65
  @retrying_scan_helper.after_testrun
42
66
  true
@@ -54,3 +78,16 @@ module TestCenter
54
78
  end
55
79
  end
56
80
  end
81
+ # Ug. How do I name this class?
82
+ # I want a class that retries a scan
83
+ # I want a class that controls or manages the class that retries the scan and the set up for that
84
+ # etc.
85
+ # So, the class or the realm could be:
86
+ # MultiScanManager
87
+ # MultiScanController
88
+ # ScanManager
89
+ # ScanMaster
90
+ # MultiScanMaster
91
+ # MasterScanManser
92
+ # MasterMultiScan
93
+ # I like MultiScanManager
@@ -13,36 +13,20 @@ module TestCenter
13
13
  @options = options
14
14
  @testrun_count = 0
15
15
  @xcpretty_json_file_output = ENV['XCPRETTY_JSON_FILE_OUTPUT']
16
+
16
17
  @reportnamer = ReportNameHelper.new(
17
- @options[:output_types],
18
- @options[:output_files],
19
- @options[:custom_report_file_name]
18
+ options[:output_types],
19
+ options[:output_files],
20
+ options[:custom_report_file_name]
20
21
  )
21
22
  end
22
23
 
23
24
  def before_testrun
24
25
  remove_preexisting_test_result_bundles
25
- delete_xcresults # has to be performed _after_ moving a *.test_result
26
-
27
26
  set_json_env
28
27
  print_starting_scan_message
29
28
  end
30
29
 
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
-
46
30
  def print_starting_scan_message
47
31
  scan_message = "Starting scan ##{@testrun_count + 1} with #{@options.fetch(:only_testing, []).size} tests"
48
32
  scan_message << " for batch ##{@options[:batch]}" unless @options[:batch].nil?
@@ -53,7 +37,7 @@ module TestCenter
53
37
  return unless @reportnamer.includes_json?
54
38
 
55
39
  ENV['XCPRETTY_JSON_FILE_OUTPUT'] = File.join(
56
- output_directory,
40
+ @options[:output_directory],
57
41
  @reportnamer.json_last_reportname
58
42
  )
59
43
  end
@@ -67,7 +51,8 @@ module TestCenter
67
51
  def remove_preexisting_test_result_bundles
68
52
  return unless @options[:result_bundle]
69
53
 
70
- glob_pattern = "#{output_directory}/*.test_result"
54
+ absolute_output_directory = File.absolute_path(@options[:output_directory])
55
+ glob_pattern = "#{absolute_output_directory}/*.test_result"
71
56
  preexisting_test_result_bundles = Dir.glob(glob_pattern)
72
57
  FileUtils.rm_rf(preexisting_test_result_bundles)
73
58
  end
@@ -76,7 +61,6 @@ module TestCenter
76
61
  valid_scan_keys = Fastlane::Actions::ScanAction.available_options.map(&:key)
77
62
  @options.select { |k,v| valid_scan_keys.include?(k) }
78
63
  .merge(@reportnamer.scan_options)
79
- .merge(output_directory: output_directory)
80
64
  end
81
65
 
82
66
  # after_testrun methods
@@ -90,25 +74,25 @@ module TestCenter
90
74
  else
91
75
  handle_success
92
76
  end
93
- collate_reports
94
77
  end
95
78
 
96
79
  def handle_success
97
80
  send_callback_testrun_info
98
81
  move_test_result_bundle_for_next_run
99
82
  reset_json_env
83
+ collate_reports
100
84
  end
101
85
 
102
86
  def collate_reports
87
+ absolute_output_directory = File.absolute_path(@options[:output_directory])
103
88
 
104
- report_collator_options = {
105
- source_reports_directory_glob: output_directory,
106
- output_directory: output_directory,
89
+ TestCenter::Helper::MultiScanManager::ReportCollator.new(
90
+ source_reports_directory_glob: absolute_output_directory,
91
+ output_directory: absolute_output_directory,
107
92
  reportnamer: @reportnamer,
108
93
  scheme: @options[:scheme],
109
94
  result_bundle: @options[:result_bundle]
110
- }
111
- TestCenter::Helper::MultiScanManager::ReportCollator.new(report_collator_options).collate
95
+ ).collate
112
96
  end
113
97
 
114
98
  def handle_test_failure
@@ -125,7 +109,7 @@ module TestCenter
125
109
  report_filepath = nil
126
110
  junit_results = {}
127
111
  unless additional_info.key?(:test_operation_failure)
128
- report_filepath = File.join(output_directory, @reportnamer.junit_last_reportname)
112
+ report_filepath = File.absolute_path(File.join(@options[:output_directory], @reportnamer.junit_last_reportname))
129
113
 
130
114
  config = FastlaneCore::Configuration.create(
131
115
  Fastlane::Actions::TestsFromJunitAction.available_options,
@@ -139,23 +123,23 @@ module TestCenter
139
123
  info = {
140
124
  failed: junit_results[:failed],
141
125
  passing: junit_results[:passing],
142
- batch: @options[:batch] || 1,
126
+ batch: 1,
143
127
  try_count: @testrun_count,
144
128
  report_filepath: report_filepath
145
129
  }.merge(additional_info)
146
130
 
147
131
  if @reportnamer.includes_html?
148
- html_report_filepath = File.join(output_directory, @reportnamer.html_last_reportname)
132
+ html_report_filepath = File.join(@options[:output_directory], @reportnamer.html_last_reportname)
149
133
  info[:html_report_filepath] = html_report_filepath
150
134
  end
151
135
  if @reportnamer.includes_json?
152
- json_report_filepath = File.join(output_directory, @reportnamer.json_last_reportname)
136
+ json_report_filepath = File.join(@options[:output_directory], @reportnamer.json_last_reportname)
153
137
  info[:json_report_filepath] = json_report_filepath
154
138
  end
155
139
  if @options[:result_bundle]
156
140
  test_result_suffix = '.test_result'
157
141
  test_result_suffix.prepend("-#{@reportnamer.report_count}") unless @reportnamer.report_count.zero?
158
- test_result_bundlepath = File.join(output_directory, @options[:scheme]) + test_result_suffix
142
+ test_result_bundlepath = File.join(@options[:output_directory], @options[:scheme]) + test_result_suffix
159
143
  info[:test_result_bundlepath] = test_result_bundlepath
160
144
  end
161
145
  @options[:testrun_completed_block].call(info)
@@ -173,7 +157,7 @@ module TestCenter
173
157
  end
174
158
 
175
159
  def update_only_testing
176
- report_filepath = File.join(output_directory, @reportnamer.junit_last_reportname)
160
+ report_filepath = File.join(@options[:output_directory], @reportnamer.junit_last_reportname)
177
161
  config = FastlaneCore::Configuration.create(
178
162
  Fastlane::Actions::TestsFromJunitAction.available_options,
179
163
  {
@@ -233,7 +217,8 @@ module TestCenter
233
217
  def move_test_result_bundle_for_next_run
234
218
  return unless @options[:result_bundle]
235
219
 
236
- glob_pattern = "#{output_directory}/*.test_result"
220
+ absolute_output_directory = File.absolute_path(@options[:output_directory])
221
+ glob_pattern = "#{absolute_output_directory}/*.test_result"
237
222
  preexisting_test_result_bundles = Dir.glob(glob_pattern)
238
223
  unnumbered_test_result_bundles = preexisting_test_result_bundles.reject do |test_result|
239
224
  test_result =~ /.*-\d+\.test_result/
@@ -24,26 +24,22 @@ module TestCenter
24
24
  @given_output_files = multi_scan_options[:output_files]
25
25
  @parallelize = multi_scan_options[:parallelize]
26
26
  @test_collector = TestCenter::Helper::TestCollector.new(multi_scan_options)
27
- if ENV['USE_REFACTORED_PARALLELIZED_MULTI_SCAN']
28
- @scan_options = multi_scan_options
29
- else
30
- @scan_options = multi_scan_options.reject do |option, _|
31
- %i[
32
- output_directory
33
- only_testing
34
- skip_testing
35
- clean
36
- try_count
37
- batch_count
38
- custom_report_file_name
39
- fail_build
40
- testrun_completed_block
41
- output_types
42
- output_files
43
- parallelize
44
- quit_simulators
45
- ].include?(option)
46
- end
27
+ @scan_options = multi_scan_options.reject do |option, _|
28
+ %i[
29
+ output_directory
30
+ only_testing
31
+ skip_testing
32
+ clean
33
+ try_count
34
+ batch_count
35
+ custom_report_file_name
36
+ fail_build
37
+ testrun_completed_block
38
+ output_types
39
+ output_files
40
+ parallelize
41
+ quit_simulators
42
+ ].include?(option)
47
43
  end
48
44
  @scan_options[:clean] = false
49
45
  @scan_options[:disable_concurrent_testing] = true
@@ -58,10 +54,56 @@ module TestCenter
58
54
  def scan
59
55
  all_tests_passed = true
60
56
  @testables_count = @test_collector.testables.size
61
- FileUtils.rm_rf(Dir.glob("#{@output_directory}/**/*.{junit,html,xml,json}"))
62
57
  all_tests_passed = each_batch do |test_batch, current_batch_index|
63
58
  if ENV['USE_REFACTORED_PARALLELIZED_MULTI_SCAN']
64
- run_test_batch_through_retrying_scan(test_batch, current_batch_index)
59
+ # destination = @parallelizer&.destination_for_batch(current_batch_index) || Scan&.config&.fetch(:destination)
60
+ # if destination.nil?
61
+ # app_infoplist ||= XCTestrunInfo.new(@scan_options[:xctestrun])
62
+
63
+ # batch_deploymentversions = @test_collector.test_batches.map do |test_batch|
64
+ # testable = test_batch.first.split('/').first.gsub('\\', '')
65
+ # # TODO: investigate the reason for this call that doesn't seem to do
66
+ # # anything other than query for and then discard MinimumOSVersion
67
+ # app_infoplist.app_plist_for_testable(testable)['MinimumOSVersion']
68
+ # end
69
+
70
+ # device_description = @scan_options[:device]
71
+ # device_name = 'iPhone 5s'
72
+ # device_version = batch_deploymentversions[current_batch_index]
73
+ # unless device_description.nil?
74
+ # /(?<device_name>.*)\s+\((?<device_version>.*)\)/ =~ device_description
75
+ # end
76
+ # # TODO: check for an existing simulator that can serve
77
+ # all_runtimes = ::Snapshot::ResetSimulators.runtimes
78
+
79
+ # all_ios_runtimes = all_runtimes.select { |v, id| v[/^iOS/] }
80
+ # ios_runtimes_greater_than_equal = all_ios_runtimes.select do |versionstr, _|
81
+ # _, version = versionstr.split(' ')
82
+ # Gem::Version.new(device_version) <= Gem::Version.new(version)
83
+ # end
84
+ # ios_runtimes_greater_than_equal.sort! do |a, b|
85
+ # version_a = a.first.split(' ').last
86
+ # version_b = b.first.split(' ').last
87
+ # Gem::Version.new(version_a) <=> Gem::Version.new(version_b)
88
+ # end
89
+
90
+ # runtime = ios_runtimes_greater_than_equal.first.last
91
+ # device_type = `xcrun simctl list devicetypes`.scan(/(.*)\s\((.*)\)/)
92
+ # .find { |name, device_id| name == device_name }
93
+
94
+ # command = "xcrun simctl create '#{device_name}' #{device_type.last} #{runtime}"
95
+ # UI.command(command) if ::FastlaneCore::Globals.verbose?
96
+ # udid = `#{command}`.chomp
97
+ # destination = "platform=iOS Simulator,id=#{udid}"
98
+ # end
99
+ retrying_scan = TestCenter::Helper::MultiScanManager::RetryingScan.new(
100
+ @scan_options.merge(
101
+ # destination: destination,
102
+ only_testing: test_batch.map(&:shellsafe_testidentifier),
103
+ output_directory: @output_directory
104
+ ).reject { |key| %i[device devices].include?(key) }
105
+ )
106
+ retrying_scan.run
65
107
  else
66
108
  output_directory = testrun_output_directory(@output_directory, test_batch, current_batch_index)
67
109
  reset_for_new_testable(output_directory)
@@ -88,45 +130,9 @@ module TestCenter
88
130
  end
89
131
  testrun_passed && all_tests_passed
90
132
  end
91
- if ENV['USE_REFACTORED_PARALLELIZED_MULTI_SCAN']
92
- collate_batched_reports
93
- end
94
133
  all_tests_passed
95
134
  end
96
135
 
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
-
130
136
  def each_batch
131
137
  tests_passed = true
132
138
  if @parallelize
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TestCenter
3
- VERSION = "3.6.3.parallelizing.alpha.3"
3
+ VERSION = "3.6.3.parallelizing-alpha-1"
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.3
4
+ version: 3.6.3.parallelizing.pre.alpha.pre.1
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-22 00:00:00.000000000 Z
11
+ date: 2019-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json