fastlane-plugin-test_center 3.8.0.parallelizing.beta.8 → 3.8.0.parallelizing.beta.9

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
  SHA1:
3
- metadata.gz: 4e73880166b9ba845963df59878b80eba77ca64d
4
- data.tar.gz: 182b6aea7cbb03dfd121efc35dc832ca85a1bb6c
3
+ metadata.gz: f77fa973e751d52ce7fa63397e48ec3a2e9592d5
4
+ data.tar.gz: a0a0c9ea893833e04ddc526bc52bb7563d007d5d
5
5
  SHA512:
6
- metadata.gz: 8d6998f5f5f3515b8aaf10c75a2b804e32e192088be2323ff442208034c01568c013122a8db9c602856fce420f66983eeaf3b32769b7ddcbbb522ffdbb758d86
7
- data.tar.gz: cd1f2ff6cbe717c40564514dff042a747a082d5e82e33212cdab478c83899d788154f867d16f23964669e38a0e7231b9bc7cfee9e3c54b46ff7806fa75653cd4
6
+ metadata.gz: c1c924695fbd1e9f3f531266171c584c10012d7b5b4979b89383ad02b7ed3d19a7dc2f0e5a6e9cff7572d11608d2a56dcbb0879ce6b0f89ebdc68e7c8c5ff0d0
7
+ data.tar.gz: 5bfb8bbceee4dd66010437d77292f612efa78a2d2529edccb805faeff4ec4b5c72a12354d0349ad45ee31ab23f645329fb49ececa1bc298f713ea88069dbbdbc
@@ -21,13 +21,10 @@ module Fastlane
21
21
  runner_options = params.values.merge(platform: platform)
22
22
  runner = ::TestCenter::Helper::MultiScanManager::Runner.new(runner_options)
23
23
  tests_passed = runner.run
24
- if params[:fail_build] && !tests_passed
25
- raise UI.test_failure!('Tests have failed')
26
- end
27
24
 
28
25
  summary = run_summary(params, tests_passed, runner.retry_total_count)
29
26
  print_run_summary(summary)
30
-
27
+
31
28
  if params[:fail_build] && !tests_passed
32
29
  raise UI.test_failure!('Tests have failed')
33
30
  end
@@ -103,6 +100,9 @@ module Fastlane
103
100
  end
104
101
 
105
102
  def self.prepare_for_testing(scan_options)
103
+ reset_scan_config_to_defaults
104
+ use_scanfile_to_override_settings(scan_options)
105
+ ScanHelper.remove_preexisting_simulator_logs(scan_options)
106
106
  if scan_options[:test_without_building] || scan_options[:skip_build]
107
107
  UI.verbose("Preparing Scan config options for multi_scan testing")
108
108
  prepare_scan_config(scan_options)
@@ -112,10 +112,34 @@ module Fastlane
112
112
  end
113
113
  end
114
114
 
115
+ def self.reset_scan_config_to_defaults
116
+ return unless Scan.config
117
+
118
+ defaults = Hash[Fastlane::Actions::ScanAction.available_options.map { |i| [i.key, i.default_value] }]
119
+ FastlaneCore::UI.verbose("MultiScanAction resetting Scan config to defaults")
120
+
121
+ Scan.config._values.each do |k,v|
122
+ Scan.config.set(k, defaults[k]) if defaults.key?(k)
123
+ end
124
+ end
125
+
126
+ def self.use_scanfile_to_override_settings(scan_options)
127
+ overridden_options = ScanHelper.options_from_configuration_file(
128
+ ScanHelper.scan_options_from_multi_scan_options(scan_options)
129
+ )
130
+
131
+ unless overridden_options.empty?
132
+ FastlaneCore::UI.important("Scanfile found: overriding multi_scan options with it's values.")
133
+ overridden_options.each do |k,v|
134
+ scan_options[k] = v
135
+ end
136
+ end
137
+ end
138
+
115
139
  def self.prepare_scan_config(scan_options)
116
140
  Scan.config ||= FastlaneCore::Configuration.create(
117
141
  Fastlane::Actions::ScanAction.available_options,
118
- scan_options.select { |k,v| %i[project workspace scheme device devices].include?(k) }
142
+ ScanHelper.scan_options_from_multi_scan_options(scan_options)
119
143
  )
120
144
  end
121
145
 
@@ -133,12 +157,9 @@ module Fastlane
133
157
  end
134
158
 
135
159
  def self.prepare_scan_options_for_build_for_testing(scan_options)
136
- valid_scan_keys = Fastlane::Actions::ScanAction.available_options.map(&:key)
137
- scan_options = scan_options.select { |k,v| %i[project workspace scheme device devices].include?(k) }
138
-
139
160
  Scan.config = FastlaneCore::Configuration.create(
140
161
  Fastlane::Actions::ScanAction.available_options,
141
- scan_options.merge(build_for_testing: true)
162
+ ScanHelper.scan_options_from_multi_scan_options(scan_options.merge(build_for_testing: true))
142
163
  )
143
164
  values = Scan.config.values(ask: false)
144
165
  values[:xcode_path] = File.expand_path("../..", FastlaneCore::Helper.xcode_path)
@@ -18,10 +18,12 @@ module Fastlane
18
18
  xctest_path = xctest_bundle_path(xctestrun_rootpath, xctestrun_config)
19
19
  test_identifiers = XCTestList.tests(xctest_path)
20
20
  UI.verbose("Found the following tests: #{test_identifiers.join("\n\t")}")
21
+
21
22
  if xctestrun_config.key?('SkipTestIdentifiers')
22
- skipped_tests = xctestrun_config['SkipTestIdentifiers']
23
- UI.verbose("Removing skipped tests: #{skipped_tests.join("\n\t")}")
24
- test_identifiers.reject! { |test_identifier| skipped_tests.include?(test_identifier) }
23
+ test_identifiers = subtract_skipped_tests_from_test_identifiers(
24
+ test_identifiers,
25
+ xctestrun_config['SkipTestIdentifiers']
26
+ )
25
27
  end
26
28
  if test_identifiers.empty? && !invocation_based_tests
27
29
  UI.error("No tests found in '#{xctest_path}'!")
@@ -34,6 +36,27 @@ module Fastlane
34
36
  tests
35
37
  end
36
38
 
39
+ def self.subtract_skipped_tests_from_test_identifiers(test_identifiers, skipped_test_identifiers)
40
+ skipped_tests_identifiers = []
41
+ skipped_testsuites = []
42
+ skipped_test_identifiers.each do |skipped_test|
43
+ if skipped_test.split('/').size > 1
44
+ skipped_tests_identifiers << skipped_test
45
+ else
46
+ skipped_testsuites << skipped_test
47
+ end
48
+ end
49
+ skipped_testsuites.each do |skipped_testsuite|
50
+ derived_skipped_tests = test_identifiers.select do |test_identifier|
51
+ test_identifier.start_with?(skipped_testsuite)
52
+ end
53
+ skipped_tests_identifiers.concat(derived_skipped_tests)
54
+ end
55
+
56
+ UI.verbose("Removing skipped tests: #{skipped_tests_identifiers.join("\n\t")}")
57
+ test_identifiers.reject { |test_identifier| skipped_tests_identifiers.include?(test_identifier) }
58
+ end
59
+
37
60
  def self.xctest_bundle_path(xctestrun_rootpath, xctestrun_config)
38
61
  xctest_host_path = xctestrun_config['TestHostPath'].sub('__TESTROOT__', xctestrun_rootpath)
39
62
  xctestrun_config['TestBundlePath'].sub('__TESTHOST__', xctest_host_path).sub('__TESTROOT__', xctestrun_rootpath)
@@ -34,7 +34,8 @@ module TestCenter
34
34
  print line
35
35
  end
36
36
  state = :ready_to_work
37
- @options[:test_batch_results] << (@reader.gets == 'true')
37
+
38
+ @options[:test_batch_results] << (@reader.gets.chomp.to_s == 'true')
38
39
  end
39
40
 
40
41
  def run(run_options)
@@ -50,6 +51,7 @@ module TestCenter
50
51
  puts e.message
51
52
  puts e.backtrace.inspect
52
53
  ensure
54
+ print_final_results(tests_passed)
53
55
  handle_child_process_results(tests_passed)
54
56
  exit!
55
57
  end
@@ -57,6 +59,10 @@ module TestCenter
57
59
  close_parent_process_writer
58
60
  end
59
61
 
62
+ def print_final_results(tests_passed)
63
+ FastlaneCore::UI.verbose("All tests passed for batch #{@options[:batch_index] + 1}? #{tests_passed}")
64
+ end
65
+
60
66
  def open_interprocess_communication
61
67
  # This is performed in the Parent process in preparation to setup
62
68
  # the STDOUT and STDOUT for printing messages from the Child process
@@ -94,6 +94,8 @@ module TestCenter
94
94
  # after_testrun methods
95
95
 
96
96
  def after_testrun(exception = nil)
97
+ move_simulator_logs_for_next_run
98
+
97
99
  @testrun_count = @testrun_count + 1
98
100
  if exception.kind_of?(FastlaneCore::Interface::FastlaneTestFailure)
99
101
  after_testrun_message = "Scan found failing tests"
@@ -267,6 +269,19 @@ module TestCenter
267
269
  test_session_last_messages = test_session.read
268
270
  end
269
271
 
272
+ def move_simulator_logs_for_next_run
273
+ return unless @options[:include_simulator_logs]
274
+
275
+ glob_pattern = "#{output_directory}/system_logs-*.{log,logarchive}"
276
+ logs = Dir.glob(glob_pattern)
277
+ logs.each do |log_filepath|
278
+ new_logname = "try-#{testrun_count}-#{File.basename(log_filepath)}"
279
+ new_log_filepath = "#{File.dirname(log_filepath)}/#{new_logname}"
280
+ FastlaneCore::UI.verbose("Moving simulator log '#{log_filepath}' to '#{new_log_filepath}'")
281
+ File.rename(log_filepath, new_log_filepath)
282
+ end
283
+ end
284
+
270
285
  def move_test_result_bundle_for_next_run
271
286
  return unless @options[:result_bundle]
272
287
 
@@ -279,6 +294,7 @@ module TestCenter
279
294
  dst_test_bundle_parent_dir = File.dirname(src_test_bundle)
280
295
  dst_test_bundle_basename = File.basename(src_test_bundle, '.test_result')
281
296
  dst_test_bundle = "#{dst_test_bundle_parent_dir}/#{dst_test_bundle_basename}-#{@testrun_count}.test_result"
297
+ FastlaneCore::UI.verbose("Moving test_result '#{src_test_bundle}' to '#{dst_test_bundle}'")
282
298
  File.rename(src_test_bundle, dst_test_bundle)
283
299
  end
284
300
  end
@@ -40,19 +40,28 @@ module TestCenter
40
40
  end
41
41
 
42
42
  def run
43
+ ScanHelper.remove_preexisting_simulator_logs(@options)
43
44
  remove_preexisting_test_result_bundles
44
45
 
45
46
  tests_passed = false
46
- if @options[:invocation_based_tests] && @options[:only_testing].nil?
47
- tests_passed = run_first_run_of_invocation_based_tests
47
+ if should_run_tests_through_single_try?
48
+ tests_passed = run_tests_through_single_try
48
49
  end
49
50
 
50
51
  unless tests_passed || @options[:try_count] < 1
51
52
  setup_testcollector
52
- run_test_batches
53
+ tests_passed = run_test_batches
53
54
  end
55
+ tests_passed
54
56
  end
55
57
 
58
+ def should_run_tests_through_single_try?
59
+ should_run_for_invocation_tests = @options[:invocation_based_tests] && @options[:only_testing].nil?
60
+ should_run_for_skip_build = @options[:skip_build]
61
+ (should_run_for_invocation_tests || should_run_for_skip_build)
62
+ end
63
+
64
+
56
65
  def remove_preexisting_test_result_bundles
57
66
  return unless @options[:result_bundle]
58
67
 
@@ -67,9 +76,11 @@ module TestCenter
67
76
  end
68
77
  end
69
78
 
70
- def run_first_run_of_invocation_based_tests
79
+ def run_tests_through_single_try
71
80
  FastlaneCore::UI.verbose("Running invocation tests")
72
- @options[:skip_testing] = @options[:skip_testing]&.map(&:strip_testcase)&.uniq
81
+ if @options[:invocation_based_tests]
82
+ @options[:skip_testing] = @options[:skip_testing]&.map(&:strip_testcase)&.uniq
83
+ end
73
84
  @options[:output_directory] = output_directory
74
85
  @options[:destination] = Scan.config[:destination]
75
86
 
@@ -94,13 +105,13 @@ module TestCenter
94
105
  junit: File.absolute_path(report_filepath)
95
106
  }
96
107
  )
97
- @options[:only_testing] = retrieve_failed_invocation_tests[:failed]
108
+ @options[:only_testing] = retrieve_failed_single_try_tests
98
109
  @options[:only_testing] = @options[:only_testing].map(&:strip_testcase).uniq
99
110
 
100
111
  tests_passed
101
112
  end
102
113
 
103
- def retrieve_failed_invocation_tests
114
+ def retrieve_failed_single_try_tests
104
115
  reportnamer = ReportNameHelper.new(
105
116
  @options[:output_types],
106
117
  @options[:output_files],
@@ -113,7 +124,7 @@ module TestCenter
113
124
  junit: File.absolute_path(report_filepath)
114
125
  }
115
126
  )
116
- Fastlane::Actions::TestsFromJunitAction.run(config)
127
+ Fastlane::Actions::TestsFromJunitAction.run(config)[:failed]
117
128
  end
118
129
 
119
130
  def run_test_batches
@@ -133,7 +144,8 @@ module TestCenter
133
144
  end
134
145
  pool.wait_for_all_workers
135
146
  collate_batched_reports
136
- test_batch_results.reduce(true) { |a, t| a && t }
147
+ FastlaneCore::UI.verbose("Results for each test run: #{test_batch_results}")
148
+ test_batch_results.all?
137
149
  end
138
150
 
139
151
  def scan_options_for_worker(test_batch, batch_index)
@@ -15,8 +15,10 @@ module TestCenter
15
15
 
16
16
  def run(run_options)
17
17
  self.state = :working
18
- @options[:test_batch_results] << RetryingScan.run(@options.merge(run_options))
18
+ test_batch_worker_final_result = RetryingScan.run(@options.merge(run_options))
19
+ @options[:test_batch_results] << test_batch_worker_final_result
19
20
  self.state = :ready_to_work
21
+ test_batch_worker_final_result
20
22
  end
21
23
  end
22
24
  end
@@ -10,4 +10,40 @@ module ScanHelper
10
10
  )
11
11
  # :nocov:
12
12
  end
13
- end
13
+
14
+ def self.remove_preexisting_simulator_logs(params)
15
+ return unless params[:include_simulator_logs]
16
+
17
+ output_directory = File.absolute_path(params.fetch(:output_directory, 'test_results'))
18
+
19
+ glob_pattern = "#{output_directory}/**/system_logs-*.{log,logarchive}"
20
+ logs = Dir.glob(glob_pattern)
21
+ FileUtils.rm_rf(logs)
22
+ end
23
+
24
+ def self.scan_options_from_multi_scan_options(params)
25
+ valid_scan_keys = Fastlane::Actions::ScanAction.available_options.map(&:key)
26
+ params.select { |k,v| valid_scan_keys.include?(k) }
27
+ end
28
+
29
+ def self.options_from_configuration_file(params)
30
+ config = FastlaneCore::Configuration.create(
31
+ Fastlane::Actions::ScanAction.available_options,
32
+ params
33
+ )
34
+ config_file = config.load_configuration_file(Scan.scanfile_name, nil, true)
35
+
36
+ overridden_options = config_file ? config_file.options : {}
37
+
38
+ FastlaneCore::Project.detect_projects(config)
39
+ project = FastlaneCore::Project.new(config)
40
+
41
+ imported_path = File.expand_path(Scan.scanfile_name)
42
+ Dir.chdir(File.expand_path("..", project.path)) do
43
+ config_file = config.load_configuration_file(Scan.scanfile_name, nil, true) unless File.expand_path(Scan.scanfile_name) == imported_path
44
+ overridden_options.merge!(config_file.options) if config_file
45
+ end
46
+ overridden_options
47
+ end
48
+ end
49
+
@@ -16,6 +16,9 @@ module TestCenter
16
16
  FastlaneCore::UI.user_error!("Error: cannot find xctestrun file '#{@xctestrun_path}'")
17
17
  end
18
18
  @only_testing = options[:only_testing]
19
+ if @only_testing.kind_of?(String)
20
+ @only_testing = @only_testing.split(',')
21
+ end
19
22
  @skip_testing = options[:skip_testing]
20
23
  @invocation_based_tests = options[:invocation_based_tests]
21
24
  @batch_count = options[:batch_count]
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TestCenter
3
- VERSION = "3.8.0.parallelizing.beta.8"
3
+ VERSION = "3.8.0.parallelizing.beta.9"
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.8.0.parallelizing.beta.8
4
+ version: 3.8.0.parallelizing.beta.9
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-07-11 00:00:00.000000000 Z
11
+ date: 2019-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.7
61
+ version: 1.1.8
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.1.7
68
+ version: 1.1.8
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: colorize
71
71
  requirement: !ruby/object:Gem::Requirement