fastlane-plugin-test_center 3.6.3.parallelizing.pre.alpha.pre.1 → 3.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/test_center.rb +1 -1
- data/lib/fastlane/plugin/test_center/actions/collate_test_result_bundles.rb +1 -1
- data/lib/fastlane/plugin/test_center/actions/multi_scan.rb +4 -48
- data/lib/fastlane/plugin/test_center/helper/correcting_scan_helper.rb +293 -0
- data/lib/fastlane/plugin/test_center/helper/reportname_helper.rb +6 -15
- data/lib/fastlane/plugin/test_center/helper/test_collector.rb +3 -47
- data/lib/fastlane/plugin/test_center/version.rb +1 -1
- metadata +10 -20
- data/lib/fastlane/plugin/test_center/actions/restart_core_simulator_service.rb +0 -37
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager.rb +0 -5
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/device_manager.rb +0 -26
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/interstitial.rb +0 -143
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/report_collator.rb +0 -113
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan.rb +0 -93
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/retrying_scan_helper.rb +0 -236
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/runner.rb +0 -313
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/simulator_helper.rb +0 -59
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/simulator_manager.rb +0 -317
- data/lib/fastlane/plugin/test_center/helper/xctestrun_info.rb +0 -42
@@ -1,59 +0,0 @@
|
|
1
|
-
module TestCenter
|
2
|
-
module Helper
|
3
|
-
module MultiScanManager
|
4
|
-
class SimulatorHelper
|
5
|
-
def initialize(options)
|
6
|
-
@options = options
|
7
|
-
end
|
8
|
-
|
9
|
-
def setup
|
10
|
-
if @options[:parallelize]
|
11
|
-
setup_scan_config
|
12
|
-
delete_multi_scan_cloned_simulators
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def setup_scan_config
|
17
|
-
unless ::Scan.config&._values.has_key?(:destination)
|
18
|
-
scan_option_keys = Scan.config.all_keys
|
19
|
-
::Scan.config = FastlaneCore::Configuration.create(
|
20
|
-
Fastlane::Actions::ScanAction.available_options,
|
21
|
-
@options.select{ |k| scan_option_keys.include?(k) }
|
22
|
-
)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def clone_destination_simulators
|
27
|
-
cloned_simulators = []
|
28
|
-
|
29
|
-
batch_count = @options[:batch_count] || 0
|
30
|
-
destination_simulator_ids = Scan.config[:destination].map do |destination|
|
31
|
-
destination.split(',id=').last
|
32
|
-
end
|
33
|
-
original_simulators = FastlaneCore::DeviceManager.simulators('iOS').find_all do |simulator|
|
34
|
-
destination_simulator_ids.include?(simulator.udid)
|
35
|
-
end
|
36
|
-
(0...batch_count).each do |batch_index|
|
37
|
-
cloned_simulators << []
|
38
|
-
original_simulators.each do |simulator|
|
39
|
-
FastlaneCore::UI.verbose("Cloning simulator")
|
40
|
-
cloned_simulator = simulator.clone
|
41
|
-
new_first_name = simulator.name.sub(/( ?\(.*| ?$)/, " Clone #{batch_index}")
|
42
|
-
new_last_name = "#{self.class.name}<#{self.object_id}>"
|
43
|
-
cloned_simulator.rename("#{new_first_name} #{new_last_name}")
|
44
|
-
|
45
|
-
cloned_simulators.last << cloned_simulator
|
46
|
-
end
|
47
|
-
end
|
48
|
-
cloned_simulators
|
49
|
-
end
|
50
|
-
|
51
|
-
def delete_multi_scan_cloned_simulators
|
52
|
-
FastlaneCore::DeviceManager.simulators('iOS').each do |simulator|
|
53
|
-
simulator.delete if /#{self.class.name}<\d+>/ =~ simulator.name
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,317 +0,0 @@
|
|
1
|
-
module TestCenter
|
2
|
-
module Helper
|
3
|
-
module MultiScanManager
|
4
|
-
require 'scan'
|
5
|
-
require 'colorize'
|
6
|
-
require_relative './device_manager'
|
7
|
-
|
8
|
-
class Parallelization
|
9
|
-
def initialize(batch_count, output_directory, testrun_completed_block)
|
10
|
-
@batch_count = batch_count
|
11
|
-
@output_directory = output_directory
|
12
|
-
@testrun_completed_block = testrun_completed_block
|
13
|
-
|
14
|
-
@simulators ||= []
|
15
|
-
|
16
|
-
if ENV['USE_REFACTORED_PARALLELIZED_MULTI_SCAN']
|
17
|
-
@simhelper = SimulatorHelper.new(
|
18
|
-
parallelize: true,
|
19
|
-
batch_count: batch_count
|
20
|
-
)
|
21
|
-
@simhelper.setup
|
22
|
-
end
|
23
|
-
if @batch_count < 1
|
24
|
-
raise FastlaneCore::FastlaneCrash.new({}), "batch_count (#{@batch_count}) < 1, this should never happen"
|
25
|
-
end
|
26
|
-
ObjectSpace.define_finalizer(self, self.class.finalize)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.finalize
|
30
|
-
proc { cleanup_simulators }
|
31
|
-
end
|
32
|
-
|
33
|
-
def setup_simulators(devices, batch_deploymentversions)
|
34
|
-
if ENV['USE_REFACTORED_PARALLELIZED_MULTI_SCAN']
|
35
|
-
@simulators = @simhelper.clone_destination_simulators
|
36
|
-
else
|
37
|
-
FastlaneCore::DeviceManager.simulators('iOS').each do |simulator|
|
38
|
-
simulator.delete if /-batchclone-/ =~ simulator.name
|
39
|
-
end
|
40
|
-
|
41
|
-
(0...@batch_count).each do |batch_index|
|
42
|
-
found_simulator_devices = []
|
43
|
-
if devices.count > 0
|
44
|
-
found_simulator_devices = detect_simulator(devices, batch_deploymentversions[batch_index])
|
45
|
-
else
|
46
|
-
found_simulator_devices = Scan::DetectValues.detect_simulator(devices, 'iOS', 'IPHONEOS_DEPLOYMENT_TARGET', 'iPhone 5s', nil)
|
47
|
-
end
|
48
|
-
@simulators[batch_index] ||= []
|
49
|
-
found_simulator_devices.each do |found_simulator_device|
|
50
|
-
device_for_batch = found_simulator_device.clone
|
51
|
-
new_name = "#{found_simulator_device.name.gsub(/[^a-zA-Z\d]/,'')}-batchclone-#{batch_index + 1}"
|
52
|
-
device_for_batch.rename(new_name)
|
53
|
-
device_for_batch.boot
|
54
|
-
@simulators[batch_index] << device_for_batch
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def detect_simulator(devices, deployment_target_version)
|
61
|
-
require 'set'
|
62
|
-
|
63
|
-
simulators = Scan::DetectValues.filter_simulators(
|
64
|
-
FastlaneCore::DeviceManager.simulators('iOS').tap do |array|
|
65
|
-
if array.empty?
|
66
|
-
FastlaneCore::UI.user_error!(['No', simulator_type_descriptor, 'simulators found on local machine'].reject(&:nil?).join(' '))
|
67
|
-
end
|
68
|
-
end,
|
69
|
-
:greater_than_or_equal,
|
70
|
-
deployment_target_version
|
71
|
-
).tap do |sims|
|
72
|
-
if sims.empty?
|
73
|
-
FastlaneCore::UI.error("No simulators found that are greater than or equal to the version of deployment target (#{deployment_target_version})")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# At this point we have all simulators for the given deployment target (or higher)
|
78
|
-
|
79
|
-
# We create 2 lambdas, which we iterate over later on
|
80
|
-
# If the first lambda `matches` found a simulator to use
|
81
|
-
# we'll never call the second one
|
82
|
-
|
83
|
-
matches = lambda do
|
84
|
-
set_of_simulators = devices.inject(
|
85
|
-
Set.new # of simulators
|
86
|
-
) do |set, device_string|
|
87
|
-
pieces = device_string.split(/\s(?=\([\d\.]+\)$)/)
|
88
|
-
|
89
|
-
selector = ->(sim) { pieces.count > 0 && sim.name == pieces.first }
|
90
|
-
|
91
|
-
set + (
|
92
|
-
if pieces.count == 0
|
93
|
-
[] # empty array
|
94
|
-
elsif pieces.count == 1
|
95
|
-
simulators
|
96
|
-
.select(&selector)
|
97
|
-
.reverse # more efficient, because `simctl` prints higher versions first
|
98
|
-
.sort_by! { |sim| Gem::Version.new(sim.os_version) }
|
99
|
-
.pop(1)
|
100
|
-
else # pieces.count == 2 -- mathematically, because of the 'end of line' part of our regular expression
|
101
|
-
version = pieces[1].tr('()', '')
|
102
|
-
potential_emptiness_error = lambda do |sims|
|
103
|
-
if sims.empty?
|
104
|
-
FastlaneCore::UI.error("No simulators found that are equal to the version " \
|
105
|
-
"of specifier (#{version}) and greater than or equal to the version " \
|
106
|
-
"of deployment target (#{deployment_target_version})")
|
107
|
-
end
|
108
|
-
end
|
109
|
-
Scan::DetectValues.filter_simulators(simulators, :equal, version).tap(&potential_emptiness_error).select(&selector)
|
110
|
-
end
|
111
|
-
).tap do |array|
|
112
|
-
FastlaneCore::UI.error("Ignoring '#{device_string}', couldn't find matching simulator") if array.empty?
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
set_of_simulators.to_a
|
117
|
-
end
|
118
|
-
|
119
|
-
default = lambda do
|
120
|
-
FastlaneCore::UI.error("Couldn't find any matching simulators for '#{devices}' - falling back to default simulator") if (devices || []).count > 0
|
121
|
-
|
122
|
-
result = Array(
|
123
|
-
simulators
|
124
|
-
.select { |sim| sim.name == default_device_name }
|
125
|
-
.reverse # more efficient, because `simctl` prints higher versions first
|
126
|
-
.sort_by! { |sim| Gem::Version.new(sim.os_version) }
|
127
|
-
.last || simulators.first
|
128
|
-
)
|
129
|
-
|
130
|
-
FastlaneCore::UI.message("Found simulator \"#{result.first.name} (#{result.first.os_version})\"") if result.first
|
131
|
-
|
132
|
-
result
|
133
|
-
end
|
134
|
-
|
135
|
-
[matches, default].lazy.map { |x|
|
136
|
-
arr = x.call
|
137
|
-
arr unless arr.empty?
|
138
|
-
}.reject(&:nil?).first
|
139
|
-
end
|
140
|
-
|
141
|
-
def cleanup_simulators
|
142
|
-
@simulators.flatten.each(&:delete)
|
143
|
-
@simulators = []
|
144
|
-
end
|
145
|
-
|
146
|
-
def destination_for_batch(batch_index)
|
147
|
-
@simulators[batch_index]
|
148
|
-
end
|
149
|
-
|
150
|
-
def devices(batch_index)
|
151
|
-
if batch_index > @batch_count
|
152
|
-
simulator_count = [@batch_count, @simulators.count].max
|
153
|
-
raise "Error: impossible to request devices for batch #{batch_index}, there are only #{simulator_count} set(s) of simulators"
|
154
|
-
end
|
155
|
-
|
156
|
-
if @simulators.count > 0
|
157
|
-
@simulators[batch_index - 1].map do |simulator|
|
158
|
-
"#{simulator.name} (#{simulator.os_version})"
|
159
|
-
end
|
160
|
-
else
|
161
|
-
@scan_options[:devices] || Array(@scan_options[:device])
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def ensure_conflict_free_scanlogging(scan_options, batch_index)
|
166
|
-
scan_options[:buildlog_path] = scan_options[:buildlog_path] + "-#{batch_index}"
|
167
|
-
end
|
168
|
-
|
169
|
-
def ensure_devices_cloned_for_testrun_are_used(scan_options, batch_index)
|
170
|
-
scan_options.delete(:device)
|
171
|
-
scan_options[:devices] = devices(batch_index)
|
172
|
-
end
|
173
|
-
|
174
|
-
def setup_scan_options_for_testrun(scan_options, batch_index)
|
175
|
-
ensure_conflict_free_scanlogging(scan_options, batch_index)
|
176
|
-
ensure_devices_cloned_for_testrun_are_used(scan_options, batch_index)
|
177
|
-
end
|
178
|
-
|
179
|
-
def setup_pipes_for_fork
|
180
|
-
@pipe_endpoints = []
|
181
|
-
(0...@batch_count).each do
|
182
|
-
@pipe_endpoints << IO.pipe
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def connect_subprocess_endpoint(batch_index)
|
187
|
-
mainprocess_reader, = @pipe_endpoints[batch_index]
|
188
|
-
mainprocess_reader.close # we are now in the subprocess
|
189
|
-
FileUtils.mkdir_p(@output_directory)
|
190
|
-
subprocess_output_dir = Dir.mktmpdir
|
191
|
-
subprocess_logfilepath = File.join(subprocess_output_dir, "batchscan_#{batch_index}.log")
|
192
|
-
$subprocess_logfile = File.open(subprocess_logfilepath, 'w')
|
193
|
-
$subprocess_logfile.sync = true
|
194
|
-
$old_stdout = $stdout.dup
|
195
|
-
$old_stderr = $stderr.dup
|
196
|
-
$stdout.reopen($subprocess_logfile)
|
197
|
-
$stderr.reopen($subprocess_logfile)
|
198
|
-
end
|
199
|
-
|
200
|
-
def disconnect_subprocess_endpoints
|
201
|
-
# This is done from the parent process to close the pipe from its end so
|
202
|
-
# that its reading of the pipe doesn't block waiting for more IO on the
|
203
|
-
# writer.
|
204
|
-
# This has to be done after the fork, because we don't want the subprocess
|
205
|
-
# to receive its endpoint already closed.
|
206
|
-
@pipe_endpoints.each { |_, subprocess_writer| subprocess_writer.close }
|
207
|
-
end
|
208
|
-
|
209
|
-
def send_subprocess_tryinfo(info)
|
210
|
-
puts "in send_subprocess_tryinfo"
|
211
|
-
_, subprocess_writer = @pipe_endpoints[batch_index]
|
212
|
-
subprocess_output = {
|
213
|
-
'message_type' => 'tryinfo',
|
214
|
-
'batch_index' => batch_index,
|
215
|
-
'tryinfo' => info
|
216
|
-
}
|
217
|
-
subprocess_writer.puts subprocess_output.to_json
|
218
|
-
end
|
219
|
-
|
220
|
-
def send_subprocess_result(batch_index, result)
|
221
|
-
$stdout = $old_stdout.dup
|
222
|
-
$stderr = $old_stderr.dup
|
223
|
-
_, subprocess_writer = @pipe_endpoints[batch_index]
|
224
|
-
|
225
|
-
subprocess_output = {
|
226
|
-
'message_type' => 'completed',
|
227
|
-
'batch_index' => batch_index,
|
228
|
-
'subprocess_logfilepath' => $subprocess_logfile.path,
|
229
|
-
'tests_passed' => result
|
230
|
-
}
|
231
|
-
subprocess_writer.puts subprocess_output.to_json
|
232
|
-
subprocess_writer.close
|
233
|
-
$subprocess_logfile.close
|
234
|
-
end
|
235
|
-
|
236
|
-
def parse_subprocess_results(subprocess_index, subprocess_output)
|
237
|
-
subprocess_result = {
|
238
|
-
'tests_passed' => false
|
239
|
-
}
|
240
|
-
if subprocess_output.empty?
|
241
|
-
FastlaneCore::UI.error("Something went terribly wrong: no output from parallelized batch #{subprocess_index}!")
|
242
|
-
else
|
243
|
-
subprocess_result = JSON.parse(subprocess_output)
|
244
|
-
end
|
245
|
-
subprocess_result
|
246
|
-
end
|
247
|
-
|
248
|
-
def stream_subprocess_result_to_console(index, subprocess_logfilepath)
|
249
|
-
puts '-' * 80
|
250
|
-
if File.exist?(subprocess_logfilepath)
|
251
|
-
simulator_prefix = "[Sim-#{index}]"
|
252
|
-
unless ENV['FASTLANE_DISABLE_COLORS']
|
253
|
-
colors = String.colors - [:default, :black, :white]
|
254
|
-
color = colors.sample
|
255
|
-
simulator_prefix = simulator_prefix.colorize(color)
|
256
|
-
end
|
257
|
-
File.foreach(subprocess_logfilepath) do |line|
|
258
|
-
print simulator_prefix, line
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
def handle_subprocesses
|
264
|
-
# disconnect_subprocess_endpoints # to ensure no blocking on pipe
|
265
|
-
FastlaneCore::Helper.show_loading_indicator("Scanning in #{@batch_count} batches")
|
266
|
-
loop do
|
267
|
-
break if @pipe_endpoints.size.zero?
|
268
|
-
|
269
|
-
remaining_pipe_endpoints = @pipe_endpoints.map(&:first).reject { |pe| pe.closed? }
|
270
|
-
puts "there are #{remaining_pipe_endpoints.size} endpoints remaining".yellow
|
271
|
-
read_array, _, error_array = IO.select(remaining_pipe_endpoints)
|
272
|
-
read_array.each do |pipe_reader|
|
273
|
-
endpoint_index = @pipe_endpoints.find_index { |pe| pe.first == pipe_reader }
|
274
|
-
child_message_size = pipe_reader.stat.size
|
275
|
-
child_message = pipe_reader.read_nonblock(child_message_size)
|
276
|
-
subprocess_result = parse_subprocess_results(0, child_message)
|
277
|
-
if subprocess_result['message_type'] == 'completed'
|
278
|
-
stream_subprocess_result_to_console(subprocess_result['batch_index'], subprocess_result['subprocess_logfilepath'])
|
279
|
-
pipe_reader.close
|
280
|
-
@pipe_endpoints.delete_at(endpoint_index)
|
281
|
-
elsif subprocess_result['message_type'] == 'tryinfo'
|
282
|
-
puts "in simulator_manager, about to call @testrun_completed_block witth #{subprocess_result['tryinfo']}"
|
283
|
-
@testrun_completed_block && @testrun_completed_block.call(subprocess_result['tryinfo'])
|
284
|
-
end
|
285
|
-
end
|
286
|
-
error_array.each { |e| puts e }
|
287
|
-
break if error_array.size > 0
|
288
|
-
break if read_array.size.zero?
|
289
|
-
end
|
290
|
-
FastlaneCore::Helper.hide_loading_indicator
|
291
|
-
end
|
292
|
-
|
293
|
-
def wait_for_subprocesses
|
294
|
-
disconnect_subprocess_endpoints # to ensure no blocking on the pipe
|
295
|
-
FastlaneCore::Helper.show_loading_indicator("Scanning in #{@batch_count} batches")
|
296
|
-
Process.waitall
|
297
|
-
FastlaneCore::Helper.hide_loading_indicator
|
298
|
-
end
|
299
|
-
|
300
|
-
def handle_subprocesses_results
|
301
|
-
tests_passed = false
|
302
|
-
FastlaneCore::UI.header("Output from parallelized batch run")
|
303
|
-
@pipe_endpoints.each_with_index do |endpoints, index|
|
304
|
-
mainprocess_reader, = endpoints
|
305
|
-
subprocess_result = parse_subprocess_results(index, mainprocess_reader.read)
|
306
|
-
mainprocess_reader.close
|
307
|
-
stream_subprocess_result_to_console(index, subprocess_result['subprocess_logfilepath'])
|
308
|
-
tests_passed = subprocess_result['tests_passed']
|
309
|
-
end
|
310
|
-
puts '=' * 80
|
311
|
-
tests_passed
|
312
|
-
true
|
313
|
-
end
|
314
|
-
end
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module TestCenter
|
2
|
-
module Helper
|
3
|
-
require 'plist'
|
4
|
-
|
5
|
-
class XCTestrunInfo
|
6
|
-
def initialize(xctestrun_filepath)
|
7
|
-
raise Errno::ENOENT, xctestrun_filepath unless File.exist?(xctestrun_filepath)
|
8
|
-
|
9
|
-
@xctestrun = Plist.parse_xml(xctestrun_filepath)
|
10
|
-
@xctestrun_rootpath = File.dirname(xctestrun_filepath)
|
11
|
-
end
|
12
|
-
|
13
|
-
def app_path_for_testable(testable)
|
14
|
-
@xctestrun[testable].fetch('UITargetAppPath') do |_|
|
15
|
-
@xctestrun[testable]['TestHostPath']
|
16
|
-
end.sub('__TESTROOT__', @xctestrun_rootpath)
|
17
|
-
end
|
18
|
-
|
19
|
-
def app_plist_for_testable(testable)
|
20
|
-
binary_plistfile = File.join(app_path_for_testable(testable), 'Info.plist')
|
21
|
-
|
22
|
-
Plist.parse_binary_xml(binary_plistfile)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
require 'plist'
|
29
|
-
|
30
|
-
class Hash
|
31
|
-
def save_binary_plist(filename, options = {})
|
32
|
-
Plist::Emit.save_plist(self, filename)
|
33
|
-
`plutil -convert binary1 \"#{filename}\"`
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
module Plist
|
38
|
-
def self.parse_binary_xml(filename)
|
39
|
-
`plutil -convert xml1 \"#{filename}\"`
|
40
|
-
Plist.parse_xml(filename)
|
41
|
-
end
|
42
|
-
end
|