fastlane-plugin-test_center 3.11.5 → 3.11.6

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: cf0d31d514743d1748cdbf8667ddf5975c330a628063b8309666fe04968eddc4
4
- data.tar.gz: dd66c49e0e92dd9582e78717f29910969ccdc2ae32c96f96f2872dba64c386cc
3
+ metadata.gz: a2fd204227fedab854294a870686d5f6fee7376233ebb40c3430af8b4c8ec1d0
4
+ data.tar.gz: 9019c35ad25ac2a73bdda24f8697e8ee0377a21baf257379a7989bb7526915a6
5
5
  SHA512:
6
- metadata.gz: 23a5978a4d537a3d72314e6e04a121c9a6638536038ad7c0c5f406755c2f01b9e66b2e9463df8d2350202d88ca1b4390d34890e0fc4827dbb62ee1f2aaa8b0d7
7
- data.tar.gz: '08957a8d60fb41ef49276ab0fa5fec1a01c74160d09bac10a3b7a683af47d73aceebbeaeb250bdf3f561513c22abb0b7eca413e0ecadaf8153a53bf589b8fa9c'
6
+ metadata.gz: 7f949e7b7dd7df3d576c9816b10f8ec46b478df909256675b093477c09ae4f49243d2d80962c379d6681ff71edf208fda1ba5992738439530fd89b97bbd100b8
7
+ data.tar.gz: 813c14d72c63448e8e25f5916029ee850d70185d7037c7634d4675c099fe274fb0a1ce9bbaf1fd287165ed5a351ff3cf25db4a12c5fd8c06212ae44e7c784446
@@ -170,8 +170,10 @@ module Fastlane
170
170
  reset_scan_config_to_defaults
171
171
  use_scanfile_to_override_settings(scan_options)
172
172
  turn_off_concurrent_workers(scan_options)
173
+ UI.important("Turning off :skip_build as it doesn't do anything with multi_scan") if scan_options[:skip_build]
174
+ scan_options.reject! { |k,v| k == :skip_build }
173
175
  ScanHelper.remove_preexisting_simulator_logs(scan_options)
174
- if scan_options[:test_without_building] || scan_options[:skip_build]
176
+ if scan_options[:test_without_building]
175
177
  UI.verbose("Preparing Scan config options for multi_scan testing")
176
178
  prepare_scan_config(scan_options)
177
179
  else
@@ -231,11 +233,31 @@ module Fastlane
231
233
  scan_options[:derived_data_path] = Scan.config[:derived_data_path]
232
234
  end
233
235
 
236
+ def self.remove_xcresult_from_build_options(build_options)
237
+ # convert the :output_types comma separated string of types into an array with no whitespace
238
+ output_types = build_options[:output_types].to_s.split(',').map(&:strip)
239
+ xcresult_index = output_types.index('xcresult')
240
+
241
+ unless xcresult_index.nil?
242
+ output_types.delete_at(xcresult_index)
243
+ # set :output_types value to comma separated string of remaining output types
244
+ build_options[:output_types] = output_types.join(',')
245
+
246
+ if build_options[:output_files] # not always set
247
+ output_files = build_options[:output_files].split(',').map(&:strip)
248
+ output_files.delete_at(xcresult_index)
249
+
250
+ build_options[:output_files] = output_files.join(',')
251
+ end
252
+ end
253
+ end
254
+
234
255
  def self.prepare_scan_options_for_build_for_testing(scan_options)
235
256
  build_options = scan_options.merge(build_for_testing: true).reject { |k| %i[test_without_building testplan include_simulator_logs].include?(k) }
257
+ remove_xcresult_from_build_options(build_options)
236
258
  Scan.config = FastlaneCore::Configuration.create(
237
259
  Fastlane::Actions::ScanAction.available_options,
238
- ScanHelper.scan_options_from_multi_scan_options(build_options)
260
+ ScanHelper.scan_options_from_multi_scan_options(build_options).merge(include_simulator_logs: false)
239
261
  )
240
262
  values = Scan.config.values(ask: false)
241
263
  values[:xcode_path] = File.expand_path("../..", FastlaneCore::Helper.xcode_path)
@@ -17,12 +17,14 @@ module Fastlane
17
17
  if xctestrun_version == 1
18
18
  xctestrun.each do |testable_name, test_target_config|
19
19
  next if ignoredTestables.include? testable_name
20
+ test_target_config['TestableName'] = testable_name
20
21
  test_targets << test_target_config
21
22
  end
22
23
  else
23
24
  test_configurations = xctestrun['TestConfigurations']
24
25
  test_configurations.each do |configuration|
25
26
  configuration['TestTargets'].each do |test_target|
27
+ test_target['TestableName'] = test_target['BlueprintName']
26
28
  test_targets << test_target
27
29
  end
28
30
  end
@@ -30,7 +32,7 @@ module Fastlane
30
32
 
31
33
  tests = Hash.new([])
32
34
  test_targets.each do |xctestrun_config|
33
- testable_name = xctestrun_config['ProductModuleName']
35
+ testable_name = xctestrun_config['TestableName']
34
36
  xctest_path = xctest_bundle_path(xctestrun_rootpath, xctestrun_config)
35
37
  test_identifiers = []
36
38
  if xctestrun_config.key?('OnlyTestIdentifiers')
@@ -0,0 +1,16 @@
1
+
2
+ module FixedCopyLogarchiveFastlaneSimulator
3
+ def self.included(base)
4
+ base.instance_eval do
5
+ def copy_logarchive(device, log_identity, logs_destination_dir)
6
+ require 'shellwords'
7
+ FastlaneCore::UI.verbose("> FixedCopyLogarchiveFastlaneSimulator.copy_logarchive")
8
+ logarchive_dst = File.join(logs_destination_dir, "system_logs-#{log_identity}.logarchive")
9
+ FileUtils.rm_rf(logarchive_dst)
10
+ FileUtils.mkdir_p(File.expand_path("..", logarchive_dst))
11
+ command = "xcrun simctl spawn #{device.udid} log collect --output #{logarchive_dst.shellescape} 2>/dev/null"
12
+ FastlaneCore::CommandExecutor.execute(command: command, print_all: false, print_command: true)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -181,11 +181,26 @@ module TestCenter
181
181
  end
182
182
 
183
183
  def remove_duplicate_testcases
184
- nonuniq_testcases = testcases
184
+ # Get a list of all the testcases in the report's testsuite
185
+ # and reverse the order so that we'll get the tests that
186
+ # passed _after_ they failed first. That way, when
187
+ # uniq is called, it will grab the first non-repeated test
188
+ # it finds; for duplicated tests (tests that were re-run), it will
189
+ # actually grab the last test that was run of that set.
190
+ #
191
+ # For example, if `testcases` is
192
+ # `['a(passing)', 'b(passing)', 'c(passing)', 'dup1(failing)', 'dup2(failing)', 'dup1(passing)', 'dup2(passing)' ]`
193
+ # then, testcases.reverse will be
194
+ # `['dup2(passing)', 'dup1(passing)', 'dup2(failing)', 'dup1(failing)', 'c(passing)', 'b(passing)', 'a(passing)']`
195
+ # then `uniq_testcases` will be
196
+ # `['dup2(passing)', 'dup1(passing)', 'c(passing)', 'b(passing)', 'a(passing)']`
197
+ nonuniq_testcases = testcases.reverse
185
198
  uniq_testcases = nonuniq_testcases.uniq { |tc| tc.title }
186
199
  (nonuniq_testcases - uniq_testcases).each do |tc|
200
+ # here, we would be deleting ['dup2(failing)', 'dup1(failing)']
187
201
  failure_details = tc.failure_details
188
- tc.root.parent.delete_element(failure_details)
202
+ # failure_details can be nil if this is a passing testcase
203
+ tc.root.parent.delete_element(failure_details) unless failure_details.nil?
189
204
  tc.root.parent.delete_element(tc.root)
190
205
  end
191
206
  end
@@ -19,11 +19,24 @@ module FastlaneCore
19
19
  end
20
20
 
21
21
  def boot
22
- `xcrun simctl boot #{self.udid}`
22
+ return unless is_simulator
23
+ return unless os_type == "iOS"
24
+ return if self.state == 'Booted'
25
+
26
+ UI.message("Booting #{self}")
27
+
28
+ `xcrun simctl boot #{self.udid} 2>/dev/null`
29
+ self.state = 'Booted'
23
30
  end
24
31
 
25
32
  def shutdown
26
- `xcrun simctl shutdown #{self.udid}` unless self.state == "Shutdown"
33
+ return unless is_simulator
34
+ return unless os_type == "iOS"
35
+ return if self.state == 'Shutdown'
36
+
37
+ UI.message("Shutting down #{self.udid}")
38
+ `xcrun simctl shutdown #{self.udid} 2>/dev/null`
39
+ self.state = 'Shutdown'
27
40
  end
28
41
  end
29
42
  end
@@ -29,7 +29,7 @@ module TestCenter
29
29
  return unless @options[:quit_simulators]
30
30
 
31
31
  @options.fetch(:destination).each do |destination|
32
- if /id=(?<udid>\w+),?/ =~ destination
32
+ if /id=(?<udid>[^,$]+)/ =~ destination
33
33
  FastlaneCore::UI.verbose("Restarting Simulator #{udid}")
34
34
  `xcrun simctl shutdown #{udid} 2>/dev/null`
35
35
  `xcrun simctl boot #{udid} 2>/dev/null`
@@ -345,7 +345,7 @@ module TestCenter
345
345
  new_logname = "#{batch_prefix}try-#{testrun_count}-#{File.basename(log_filepath)}"
346
346
  new_log_filepath = "#{File.dirname(log_filepath)}/#{new_logname}"
347
347
  FastlaneCore::UI.verbose("Moving simulator log '#{log_filepath}' to '#{new_log_filepath}'")
348
- File.rename(log_filepath, new_log_filepath)
348
+ FileUtils.mv(log_filepath, new_log_filepath, force: true)
349
349
  end
350
350
  end
351
351
 
@@ -6,6 +6,7 @@ module TestCenter
6
6
  require 'json'
7
7
  require 'shellwords'
8
8
  require 'snapshot/reset_simulators'
9
+ require_relative '../fastlane_core/device_manager/simulator_extensions'
9
10
 
10
11
  class Runner
11
12
  attr_reader :retry_total_count
@@ -21,6 +22,8 @@ module TestCenter
21
22
  end
22
23
  @batch_count = 1 # default count. Will be updated by setup_testcollector
23
24
  setup_testcollector
25
+ setup_logcollection
26
+ FastlaneCore::UI.verbose("< done in TestCenter::Helper::MultiScanManager.initialize")
24
27
  end
25
28
 
26
29
  def update_options_to_use_xcresult_output
@@ -35,6 +38,27 @@ module TestCenter
35
38
  @options.reject! { |k,_| k == :result_bundle }
36
39
  end
37
40
 
41
+ def setup_logcollection
42
+ FastlaneCore::UI.verbose("> setup_logcollection")
43
+ return unless @options[:include_simulator_logs]
44
+ return if Scan::Runner.method_defined?(:prelaunch_simulators)
45
+
46
+ # We need to prelaunch the simulators so xcodebuild
47
+ # doesn't shut it down before we have a chance to get
48
+ # the logs.
49
+ FastlaneCore::UI.verbose("\t collecting devices to boot for log collection")
50
+ devices_to_shutdown = []
51
+ Scan.devices.each do |device|
52
+ devices_to_shutdown << device if device.state == "Shutdown"
53
+ device.boot
54
+ end
55
+ at_exit do
56
+ devices_to_shutdown.each(&:shutdown)
57
+ end
58
+ FastlaneCore::UI.verbose("\t fixing FastlaneCore::Simulator.copy_logarchive")
59
+ FastlaneCore::Simulator.send(:include, FixedCopyLogarchiveFastlaneSimulator)
60
+ end
61
+
38
62
  def setup_testcollector
39
63
  return if @options[:invocation_based_tests] && @options[:only_testing].nil?
40
64
  return if @test_collector
@@ -42,6 +66,10 @@ module TestCenter
42
66
  @test_collector = TestCollector.new(@options)
43
67
  @options.reject! { |key| %i[testplan].include?(key) }
44
68
  @batch_count = @test_collector.test_batches.size
69
+ if @test_collector.test_batches.flatten.size < @options[:parallel_testrun_count].to_i
70
+ FastlaneCore::UI.important(":parallel_testrun_count greater than the number of tests (#{@test_collector.only_testing.size}). Reducing to that number.")
71
+ @options[:parallel_testrun_count] = @test_collector.only_testing.size
72
+ end
45
73
  end
46
74
 
47
75
  def output_directory(batch_index = 0, test_batch = [])
@@ -73,9 +101,7 @@ module TestCenter
73
101
  end
74
102
 
75
103
  def should_run_tests_through_single_try?
76
- should_run_for_invocation_tests = @options[:invocation_based_tests] && @options[:only_testing].nil?
77
- should_run_for_skip_build = @options[:skip_build]
78
- (should_run_for_invocation_tests || should_run_for_skip_build)
104
+ @options[:invocation_based_tests] && @options[:only_testing].nil?
79
105
  end
80
106
 
81
107
 
@@ -182,11 +208,21 @@ module TestCenter
182
208
  end
183
209
 
184
210
  def scan_options_for_worker(test_batch, batch_index)
211
+ if @test_collector.test_batches.size > 1
212
+ # If there are more than 1 batch, then we want each batch result
213
+ # sent to a "batch index" output folder to be collated later
214
+ # into the requested output_folder.
215
+ # Otherwise, send the results from the one and only one batch
216
+ # to the requested output_folder
217
+ batch_index += 1
218
+ batch = batch_index
219
+ end
220
+
185
221
  {
186
222
  only_testing: test_batch.map(&:shellsafe_testidentifier),
187
- output_directory: output_directory(batch_index + 1, test_batch),
223
+ output_directory: output_directory(batch_index, test_batch),
188
224
  try_count: @options[:try_count],
189
- batch: batch_index + 1
225
+ batch: batch
190
226
  }
191
227
  end
192
228
 
@@ -286,7 +322,7 @@ module TestCenter
286
322
  ).collate
287
323
  logs_glog_pattern = "#{source_reports_directory_glob}/*system_logs-*.{log,logarchive}"
288
324
  logs = Dir.glob(logs_glog_pattern)
289
- FileUtils.mv(logs, absolute_output_directory)
325
+ FileUtils.mv(logs, absolute_output_directory, force: true)
290
326
  FileUtils.rm_rf(Dir.glob(source_reports_directory_glob))
291
327
  symlink_result_bundle_to_xcresult(absolute_output_directory, report_name_helper)
292
328
  true
@@ -13,7 +13,7 @@ module TestCenter
13
13
  )
14
14
  # :nocov:
15
15
  end
16
-
16
+
17
17
  def self.remove_preexisting_simulator_logs(params)
18
18
  return unless params[:include_simulator_logs]
19
19
 
@@ -6,6 +6,7 @@ module TestCenter
6
6
 
7
7
  class TestCollector
8
8
  attr_reader :xctestrun_path
9
+ attr_reader :only_testing
9
10
 
10
11
  def initialize(options)
11
12
  unless options[:xctestrun] || options[:derived_data_path]
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TestCenter
3
- VERSION = "3.11.5"
3
+ VERSION = "3.11.6"
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.11.5
4
+ version: 3.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lyndsey Ferguson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-30 00:00:00.000000000 Z
11
+ date: 2020-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -271,6 +271,7 @@ files:
271
271
  - lib/fastlane/plugin/test_center/actions/testplans_from_scheme.rb
272
272
  - lib/fastlane/plugin/test_center/actions/tests_from_junit.rb
273
273
  - lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb
274
+ - lib/fastlane/plugin/test_center/helper/fastlane_core/device_manager/simulator_extensions.rb
274
275
  - lib/fastlane/plugin/test_center/helper/html_test_report.rb
275
276
  - lib/fastlane/plugin/test_center/helper/junit_helper.rb
276
277
  - lib/fastlane/plugin/test_center/helper/multi_scan_manager.rb