fastlane-plugin-test_center 3.9.1.b.1 → 3.10.0

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: 1046d5102edf4921dec9466f721da07edffa749f3f24fe597873f8542a37d52b
4
- data.tar.gz: f269d6a491a84575b7442c9a7642ee69dc3005b596c682a5aa30d19eb76a67d9
3
+ metadata.gz: e5adcd23e02c79f85550d8bb05a638eeffa1db8461d07c3a17901e12f0a7e7f3
4
+ data.tar.gz: '059db5183c79f5775d97cb6f38c534b1cb0b916315479ec68311fe953f624062'
5
5
  SHA512:
6
- metadata.gz: e1cf6be83ddcff5317cd8681aa44e36c3d24e061abdff7fad5c47ec883a91ec09d15ff24eb8727141dacdd04c88327f057bcbdb9ac3504a29b85b26608a6689b
7
- data.tar.gz: d8c2523c66da3b53c937720ac16d46d1c4b97953b3940db29a418eeab7a8f9342a72c4d0a1a4882928ac3a7c925806eed9c22c3f78baab49c0416360be96276b
6
+ metadata.gz: 17582ea3a4f1dbc6ed043fa54bc9949e167cd884b9bd24335b91164cc365b15c9bdaaa697c6c727a921b9ea15ea10f4a2b6d0bc02448e2b7064d05097e36bbdc
7
+ data.tar.gz: 73ae34df7f25fe36dae15fbf8c9ce8bccc1368194a4e03e086a2463440e9815f495a5f4073b30daac52ca0bb64da75d1403a3a4c7fe614fe486a01ef5a977724
@@ -17,17 +17,23 @@ module Fastlane
17
17
  scheme_filepaths.each do |scheme_filepath|
18
18
  is_dirty = false
19
19
  xcscheme = Xcodeproj::XCScheme.new(scheme_filepath)
20
- xcscheme.test_action.testables.each do |testable|
21
- buildable_name = File.basename(testable.buildable_references[0].buildable_name, '.xctest')
22
-
23
- tests_to_skip = all_tests_to_skip.select { |test| test.start_with?(buildable_name) }
24
- .map { |test| test.sub("#{buildable_name}/", '') }
25
-
26
- tests_to_skip.each do |test_to_skip|
27
- skipped_test = Xcodeproj::XCScheme::TestAction::TestableReference::SkippedTest.new
28
- skipped_test.identifier = test_to_skip
29
- testable.add_skipped_test(skipped_test)
30
- is_dirty = true
20
+ testplans = xcscheme.test_action.test_plans
21
+ unless testplans.nil?
22
+ container_directory = File.absolute_path(File.dirname(params[:xcodeproj] || params[:workspace]))
23
+ update_testplans(container_directory, testplans, all_tests_to_skip)
24
+ else
25
+ xcscheme.test_action.testables.each do |testable|
26
+ buildable_name = File.basename(testable.buildable_references[0].buildable_name, '.xctest')
27
+
28
+ tests_to_skip = all_tests_to_skip.select { |test| test.start_with?(buildable_name) }
29
+ .map { |test| test.sub("#{buildable_name}/", '') }
30
+
31
+ tests_to_skip.each do |test_to_skip|
32
+ skipped_test = Xcodeproj::XCScheme::TestAction::TestableReference::SkippedTest.new
33
+ skipped_test.identifier = test_to_skip
34
+ testable.add_skipped_test(skipped_test)
35
+ is_dirty = true
36
+ end
31
37
  end
32
38
  end
33
39
  xcscheme.save! if is_dirty
@@ -35,6 +41,24 @@ module Fastlane
35
41
  nil
36
42
  end
37
43
 
44
+ def self.update_testplans(container_directory, testplans, all_tests_to_skip)
45
+ testplans.each do |testplan_reference|
46
+ testplan_filename = testplan_reference.target_referenced_container.sub('container:', '')
47
+ testplan_filepath = File.join(container_directory, testplan_filename)
48
+ file = File.read(testplan_filepath)
49
+ testplan = JSON.parse(file)
50
+ testplan['testTargets'].each do |test_target|
51
+ buildable_name = test_target.dig('target', 'name')
52
+ tests_to_skip = all_tests_to_skip.select { |test| test.start_with?(buildable_name) }
53
+ .map { |test| test.sub("#{buildable_name}/", '') }
54
+ test_target['selectedTests'].reject! { |t| tests_to_skip.include?(t) }
55
+ end
56
+ File.open(testplan_filepath, 'w') do |f|
57
+ f.write(JSON.pretty_generate(testplan).gsub('/', '\/'))
58
+ end
59
+ end
60
+ end
61
+
38
62
  def self.schemes_from_project(project_path, scheme)
39
63
  return nil unless project_path
40
64
 
@@ -2,6 +2,7 @@ module Fastlane
2
2
  module Actions
3
3
  class SuppressedTestsAction < Action
4
4
  require 'set'
5
+ require 'json'
5
6
 
6
7
  def self.run(params)
7
8
  scheme = params[:scheme]
@@ -15,13 +16,19 @@ module Fastlane
15
16
  skipped_tests = Set.new
16
17
  scheme_filepaths.each do |scheme_filepath|
17
18
  xcscheme = Xcodeproj::XCScheme.new(scheme_filepath)
18
- xcscheme.test_action.testables.each do |testable|
19
- buildable_name = testable.buildable_references[0]
20
- .buildable_name
19
+ testplans = xcscheme.test_action.test_plans
20
+ unless testplans.nil?
21
+ UI.important("Error: unable to read suppressed tests from Xcode Scheme #{File.basename(scheme_filepath)}.")
22
+ UI.message("The scheme is using a testplan which does not list skipped tests.")
23
+ else
24
+ xcscheme.test_action.testables.each do |testable|
25
+ buildable_name = testable.buildable_references[0]
26
+ .buildable_name
21
27
 
22
- buildable_name = File.basename(buildable_name, '.xctest')
23
- testable.skipped_tests.map do |skipped_test|
24
- skipped_tests.add("#{buildable_name}/#{skipped_test.identifier}")
28
+ buildable_name = File.basename(buildable_name, '.xctest')
29
+ testable.skipped_tests.map do |skipped_test|
30
+ skipped_tests.add("#{buildable_name}/#{skipped_test.identifier}")
31
+ end
25
32
  end
26
33
  end
27
34
  end
@@ -11,10 +11,26 @@ module Fastlane
11
11
  def self.xctestrun_tests(xctestrun_path, invocation_based_tests)
12
12
  xctestrun = Plist.parse_xml(xctestrun_path)
13
13
  xctestrun_rootpath = File.dirname(xctestrun_path)
14
- tests = Hash.new([])
15
- xctestrun.each do |testable_name, xctestrun_config|
16
- next if ignoredTestables.include? testable_name
14
+ xctestrun_version = xctestrun.fetch('__xctestrun_metadata__', Hash.new).fetch('FormatVersion', 1)
17
15
 
16
+ test_targets = []
17
+ if xctestrun_version == 1
18
+ xctestrun.each do |testable_name, test_target_config|
19
+ next if ignoredTestables.include? testable_name
20
+ test_targets << test_target_config
21
+ end
22
+ else
23
+ test_configurations = xctestrun['TestConfigurations']
24
+ test_configurations.each do |configuration|
25
+ configuration['TestTargets'].each do |test_target|
26
+ test_targets << test_target
27
+ end
28
+ end
29
+ end
30
+
31
+ tests = Hash.new([])
32
+ test_targets.each do |xctestrun_config|
33
+ testable_name = xctestrun_config['ProductModuleName']
18
34
  xctest_path = xctest_bundle_path(xctestrun_rootpath, xctestrun_config)
19
35
  test_identifiers = []
20
36
  if xctestrun_config.key?('OnlyTestIdentifiers')
@@ -20,8 +20,13 @@ module TestCenter
20
20
  def prepare_scan_config_for_destination
21
21
  # this allows multi_scan's `destination` option to be picked up by `scan`
22
22
  scan_config._values.delete(:device)
23
+ ENV.delete('SCAN_DEVICE')
23
24
  scan_config._values.delete(:devices)
24
- scan_config._values.delete(:result_bundle) if ReportNameHelper.includes_xcresult?(@options[:output_types])
25
+ ENV.delete('SCAN_DEVICES')
26
+ if ReportNameHelper.includes_xcresult?(@options[:output_types])
27
+ scan_config._values.delete(:result_bundle)
28
+ ENV.delete('SCAN_RESULT_BUNDLE')
29
+ end
25
30
  scan_cache.clear
26
31
  end
27
32
 
@@ -35,7 +40,7 @@ module TestCenter
35
40
  FastlaneCore::UI.verbose("retrying_scan #update_scan_options")
36
41
  scan_options.each do |k,v|
37
42
  next if v.nil?
38
-
43
+
39
44
  scan_config.set(k,v) unless v.nil?
40
45
  FastlaneCore::UI.verbose("\tSetting #{k.to_s} to #{v}")
41
46
  end
@@ -52,7 +57,7 @@ module TestCenter
52
57
  begin
53
58
  @retrying_scan_helper.before_testrun
54
59
  update_scan_options
55
-
60
+
56
61
  values = scan_config.values(ask: false)
57
62
  values[:xcode_path] = File.expand_path("../..", FastlaneCore::Helper.xcode_path)
58
63
  ScanHelper.print_scan_parameters(values)
@@ -288,25 +288,6 @@ module TestCenter
288
288
  end
289
289
 
290
290
  def retrieve_test_operation_failure(test_session_last_messages)
291
- if FastlaneCore::Helper.xcode_at_least?(11)
292
- retrieve_test_operation_failure_post_xcode11(test_session_last_messages)
293
- else
294
- retrieve_test_operation_failure_pre_xcode11(test_session_last_messages)
295
- end
296
- end
297
-
298
- def retrieve_test_operation_failure_post_xcode11(test_session_last_messages)
299
- if /Connection peer refused channel request/ =~ test_session_last_messages
300
- test_operation_failure = 'Lost connection to testmanagerd'
301
- elsif /Please unlock your device and reattach/ =~ test_session_last_messages
302
- test_operation_failure = 'Test device locked'
303
- elsif /Test runner exited before starting test execution/ =~ test_session_last_messages
304
- test_operation_failure = 'Test runner exited before starting test execution'
305
- end
306
- test_operation_failure
307
- end
308
-
309
- def retrieve_test_operation_failure_pre_xcode11(test_session_last_messages)
310
291
  test_operation_failure_match = /Test operation failure: (?<test_operation_failure>.*)$/ =~ test_session_last_messages
311
292
  if test_operation_failure_match.nil?
312
293
  test_operation_failure = 'Unknown test operation failure'
@@ -7,7 +7,7 @@ module TestCenter
7
7
  require 'json'
8
8
  require 'shellwords'
9
9
  require 'snapshot/reset_simulators'
10
-
10
+
11
11
  class Runner
12
12
  attr_reader :retry_total_count
13
13
 
@@ -66,12 +66,12 @@ module TestCenter
66
66
  end
67
67
 
68
68
  unless tests_passed || @options[:try_count] < 1
69
- setup_testcollector
69
+ setup_testcollector
70
70
  tests_passed = run_test_batches
71
71
  end
72
72
  tests_passed
73
73
  end
74
-
74
+
75
75
  def should_run_tests_through_single_try?
76
76
  should_run_for_invocation_tests = @options[:invocation_based_tests] && @options[:only_testing].nil?
77
77
  should_run_for_skip_build = @options[:skip_build]
@@ -114,16 +114,16 @@ module TestCenter
114
114
  end
115
115
  @options[:output_directory] = output_directory
116
116
  @options[:destination] = Scan.config[:destination]
117
-
117
+
118
118
  # We do not want Scan.config to _not_ have :device :devices, we want to
119
119
  # use :destination. We remove :force_quit_simulator as we do not want
120
120
  # Scan to handle it as multi_scan takes care of it in its own way
121
121
  options = @options.reject { |key| %i[device devices force_quit_simulator].include?(key) }
122
122
  options[:try_count] = 1
123
-
123
+
124
124
  tests_passed = RetryingScan.run(options)
125
125
  @options[:try_count] -= 1
126
-
126
+
127
127
  reportnamer = ReportNameHelper.new(
128
128
  @options[:output_types],
129
129
  @options[:output_files],
@@ -138,12 +138,12 @@ module TestCenter
138
138
  )
139
139
  @options[:only_testing] = retrieve_failed_single_try_tests
140
140
  @options[:only_testing] = @options[:only_testing].map(&:strip_testcase).uniq
141
-
141
+
142
142
  symlink_result_bundle_to_xcresult(output_directory, reportnamer)
143
143
 
144
144
  tests_passed
145
145
  end
146
-
146
+
147
147
  def retrieve_failed_single_try_tests
148
148
  reportnamer = ReportNameHelper.new(
149
149
  @options[:output_types],
@@ -168,10 +168,10 @@ module TestCenter
168
168
 
169
169
  pool = TestBatchWorkerPool.new(pool_options)
170
170
  pool.setup_workers
171
-
171
+
172
172
  remaining_test_batches = @test_collector.test_batches.clone
173
173
  remaining_test_batches.each_with_index do |test_batch, current_batch_index|
174
- worker = pool.wait_for_worker
174
+ worker = pool.wait_for_worker
175
175
  FastlaneCore::UI.message("Starting test run #{current_batch_index + 1}")
176
176
  worker.run(scan_options_for_worker(test_batch, current_batch_index))
177
177
  end
@@ -189,7 +189,7 @@ module TestCenter
189
189
  batch: batch_index + 1
190
190
  }
191
191
  end
192
-
192
+
193
193
  def collate_batched_reports
194
194
  return unless @batch_count > 1
195
195
  return unless @options[:collate_reports]
@@ -80,7 +80,7 @@ module TestCenter
80
80
  known_tests += xctestrun_known_tests[testable]
81
81
  test_components = test.split('/')
82
82
  testsuite = test_components.size == 1 ? test_components[0] : test_components[1]
83
- @testables_tests[testable][index] = known_tests.select { |known_test| known_test.include?(testsuite) }
83
+ @testables_tests[testable][index] = known_tests.select { |known_test| known_test.include?(testsuite) }
84
84
  end
85
85
  end
86
86
  @testables_tests[testable].flatten!
@@ -106,7 +106,7 @@ module TestCenter
106
106
  end
107
107
  end
108
108
  end
109
-
109
+
110
110
  @testables_tests
111
111
  end
112
112
 
@@ -0,0 +1,25 @@
1
+ module Xcodeproj
2
+ class XCScheme
3
+ class TestAction < AbstractSchemeAction
4
+ def test_plans
5
+ return [] unless @xml_element.elements['TestPlans']
6
+
7
+ @xml_element.elements['TestPlans'].get_elements('TestPlanReference').map do |node|
8
+ TestPlanReference.new(node)
9
+ end
10
+ end
11
+ end
12
+
13
+ class TestPlanReference < XMLElementWrapper
14
+ def initialize(node)
15
+ create_xml_element_with_fallback(node, 'TestPlanReference') do
16
+ end
17
+ end
18
+
19
+ def target_referenced_container
20
+ @xml_element.attributes['reference']
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TestCenter
3
- VERSION = "3.9.1.b.1"
3
+ VERSION = "3.10.0"
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.9.1.b.1
4
+ version: 3.10.0
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-03-24 00:00:00.000000000 Z
11
+ date: 2020-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -285,6 +285,7 @@ files:
285
285
  - lib/fastlane/plugin/test_center/helper/scan_helper.rb
286
286
  - lib/fastlane/plugin/test_center/helper/test_collector.rb
287
287
  - lib/fastlane/plugin/test_center/helper/xcodebuild_string.rb
288
+ - lib/fastlane/plugin/test_center/helper/xcodeproj/scheme/test_action.rb
288
289
  - lib/fastlane/plugin/test_center/helper/xctestrun_info.rb
289
290
  - lib/fastlane/plugin/test_center/version.rb
290
291
  homepage: https://github.com/lyndsey-ferguson/fastlane-plugin-test_center
@@ -302,9 +303,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
303
  version: '0'
303
304
  required_rubygems_version: !ruby/object:Gem::Requirement
304
305
  requirements:
305
- - - ">"
306
+ - - ">="
306
307
  - !ruby/object:Gem::Version
307
- version: 1.3.1
308
+ version: '0'
308
309
  requirements: []
309
310
  rubygems_version: 3.0.6
310
311
  signing_key: