fastlane-plugin-test_center 3.9.1.b.1 → 3.11.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: 1fe7c4581f1be17faf807466f1b9b82cf6ee917fef0695c861ef718417dc4c0d
4
+ data.tar.gz: e0b966985549a444bfcafafa4926eb4f4927f6f43b12b39aa0b025c935e6b185
5
5
  SHA512:
6
- metadata.gz: e1cf6be83ddcff5317cd8681aa44e36c3d24e061abdff7fad5c47ec883a91ec09d15ff24eb8727141dacdd04c88327f057bcbdb9ac3504a29b85b26608a6689b
7
- data.tar.gz: d8c2523c66da3b53c937720ac16d46d1c4b97953b3940db29a418eeab7a8f9342a72c4d0a1a4882928ac3a7c925806eed9c22c3f78baab49c0416360be96276b
6
+ metadata.gz: f412ba3da2f63443923a94dec51b9f8bd7ed792ab98b4e0c1076fad2520e2a22eed74d3214cab40b36266c2fe35ca136194f4fdcd0e6d42c9730c80237fa0dff
7
+ data.tar.gz: fc7cb57702c648d99079d092b03abf44726a7fe6ac229da7202d73fe745de3e7d33be40675d0b8f0ce2827fbb7cc314d335a2019163b6a675b4cd5177e5e711b
data/README.md CHANGED
@@ -91,6 +91,11 @@ For more information about how the `fastlane` plugin system works, check out the
91
91
 
92
92
  _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
93
93
 
94
+ ## Supporters
95
+
96
+ ![Владислав Давыдов](https://avatars1.githubusercontent.com/u/47553334?s=44&u=4691860dba898943b947180b3d28bb85851b0d7c&v=4)
97
+ [vdavydovHH](https://github.com/vdavydovHH)
98
+
94
99
  ## License
95
100
 
96
101
  MIT
@@ -14,6 +14,10 @@ module Fastlane
14
14
  class MultiScanAction < Action
15
15
  def self.run(params)
16
16
  params[:quit_simulators] = params._values[:force_quit_simulator] if params._values[:force_quit_simulator]
17
+ if params[:try_count] < 1
18
+ UI.important('multi_scan will not test any if :try_count < 0, setting to 1')
19
+ params[:try_count] = 1
20
+ end
17
21
 
18
22
  strip_leading_and_trailing_whitespace_from_output_types(params)
19
23
 
@@ -228,7 +232,7 @@ module Fastlane
228
232
  end
229
233
 
230
234
  def self.prepare_scan_options_for_build_for_testing(scan_options)
231
- build_options = scan_options.merge(build_for_testing: true).reject { |k| k == :test_without_building }
235
+ build_options = scan_options.merge(build_for_testing: true).reject { |k| %i[test_without_building, testplan].include?(k) }
232
236
  Scan.config = FastlaneCore::Configuration.create(
233
237
  Fastlane::Actions::ScanAction.available_options,
234
238
  ScanHelper.scan_options_from_multi_scan_options(build_options)
@@ -240,7 +244,11 @@ module Fastlane
240
244
  end
241
245
 
242
246
  def self.update_xctestrun_after_build(scan_options)
243
- xctestrun_files = Dir.glob("#{Scan.config[:derived_data_path]}/Build/Products/*.xctestrun")
247
+ glob_pattern = "#{Scan.config[:derived_data_path]}/Build/Products/*.xctestrun"
248
+ if scan_options[:testplan]
249
+ glob_pattern = "#{Scan.config[:derived_data_path]}/Build/Products/*#{scan_options[:testplan]}*.xctestrun"
250
+ end
251
+ xctestrun_files = Dir.glob(glob_pattern)
244
252
  UI.verbose("After building, found xctestrun files #{xctestrun_files} (choosing 1st)")
245
253
  scan_options[:xctestrun] = xctestrun_files.first
246
254
  end
@@ -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
@@ -0,0 +1,90 @@
1
+ require 'json'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class TestOptionsFromTestplanAction < Action
6
+ def self.run(params)
7
+ testplan_path = params[:testplan]
8
+
9
+ testplan = JSON.load(File.open(testplan_path))
10
+ only_testing = []
11
+ UI.verbose("Examining testplan JSON: #{testplan}")
12
+ testplan['testTargets'].each do |test_target|
13
+ testable = test_target.dig('target', 'name')
14
+ if test_target.key?('selectedTests')
15
+ UI.verbose(" Found selectedTests")
16
+ test_identifiers = test_target['selectedTests'].each do |selected_test|
17
+ UI.verbose(" Found test: '#{selected_test}'")
18
+ only_testing << "#{testable}/#{selected_test.sub('\/', '/')}"
19
+ end
20
+ else
21
+ UI.verbose(" No selected tests, using testable '#{testable}'")
22
+ only_testing << testable
23
+ end
24
+ end
25
+ {
26
+ code_coverage: testplan.dig('defaultOptions', 'codeCoverage'),
27
+ only_testing: only_testing
28
+ }
29
+ end
30
+
31
+ #####################################################
32
+ # @!group Documentation
33
+ #####################################################
34
+
35
+ def self.description
36
+ "☑️ Gets test info from a given test plan"
37
+ end
38
+
39
+ def self.details
40
+ "Gets tests info consisting of tests to run and whether or not code coverage is enabled"
41
+ end
42
+
43
+ def self.available_options
44
+ [
45
+ FastlaneCore::ConfigItem.new(
46
+ key: :testplan,
47
+ optional: true,
48
+ env_name: "FL_TEST_OPTIONS_FROM_TESTPLAN_TESTPLAN",
49
+ description: "The Xcode testplan to read the test info from",
50
+ verify_block: proc do |test_plan|
51
+ UI.user_error!("Error: Xcode Test Plan '#{test_plan}' is not valid!") if test_plan and test_plan.empty?
52
+ UI.user_error!("Error: Test Plan does not exist at path '#{test_plan}'") unless File.exist?(test_plan)
53
+ end
54
+ )
55
+ ]
56
+ end
57
+
58
+ def self.return_value
59
+ "Returns a Hash with keys :code_coverage and :only_testing for the given testplan"
60
+ end
61
+
62
+ def self.example_code
63
+ [
64
+ "
65
+ UI.important(
66
+ 'example: ' \\
67
+ 'get the tests and the test coverage configuration from a given testplan'
68
+ )
69
+ test_options = test_options_from_testplan(
70
+ testplan: 'AtomicBoy/AtomicBoy_2.xctestplan'
71
+ )
72
+ UI.message(\"The AtomicBoy_2 testplan has the following tests: \#{test_options[:only_testing]}\")
73
+ "
74
+ ]
75
+ end
76
+
77
+ def self.authors
78
+ ["lyndsey-ferguson/lyndseydf"]
79
+ end
80
+
81
+ def self.category
82
+ :testing
83
+ end
84
+
85
+ def self.is_supported?(platform)
86
+ %i[ios mac].include?(platform)
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,120 @@
1
+ module Fastlane
2
+ module Actions
3
+ class TestplansFromSchemeAction < Action
4
+ def self.run(params)
5
+ scheme = params[:scheme]
6
+ scheme_filepaths = schemes_from_project(params[:xcodeproj], scheme) || schemes_from_workspace(params[:workspace], scheme)
7
+ if scheme_filepaths.length.zero?
8
+ UI.user_error!("Error: cannot find any schemes in the Xcode project") if params[:xcodeproj]
9
+ UI.user_error!("Error: cannot find any schemes in the Xcode workspace") if params[:workspace]
10
+ end
11
+ testplan_paths = []
12
+ scheme_filepaths.each do |scheme_filepath|
13
+ UI.verbose("Looking in Scheme '#{scheme_filepath}' for any testplans")
14
+ xcscheme = Xcodeproj::XCScheme.new(scheme_filepath)
15
+ next if xcscheme.test_action.nil?
16
+ next if xcscheme.test_action.testables.to_a.empty?
17
+ next if xcscheme.test_action.testables[0].buildable_references.to_a.empty?
18
+ next if xcscheme.test_action.test_plans.to_a.empty?
19
+
20
+ xcodeproj = xcscheme.test_action.testables[0].buildable_references[0].target_referenced_container.sub('container:', '')
21
+ container_dir = scheme_filepath.sub(/#{xcodeproj}.*/, '')
22
+ xcscheme.test_action.test_plans.each do |testplan|
23
+ testplan_path = File.absolute_path(File.join(container_dir, testplan.target_referenced_container.sub('container:', '')))
24
+ UI.verbose(" found testplan '#{testplan_path}'")
25
+ testplan_paths << testplan_path
26
+ end
27
+ end
28
+ testplan_paths
29
+ end
30
+
31
+ def self.schemes_from_project(project_path, scheme)
32
+ return nil unless project_path
33
+
34
+ Dir.glob("#{project_path}/{xcshareddata,xcuserdata}/**/xcschemes/#{scheme || '*'}.xcscheme")
35
+ end
36
+
37
+ def self.schemes_from_workspace(workspace_path, scheme)
38
+ return nil unless workspace_path
39
+
40
+ xcworkspace = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
41
+ scheme_filepaths = []
42
+ xcworkspace.file_references.each do |file_reference|
43
+ next if file_reference.path.include?('Pods/Pods.xcodeproj')
44
+
45
+ project_path = file_reference.absolute_path(File.dirname(workspace_path))
46
+ scheme_filepaths.concat(schemes_from_project(project_path, scheme))
47
+ end
48
+ scheme_filepaths
49
+ end
50
+
51
+ def self.description
52
+ "☑️Gets all the testplans that a Scheme references"
53
+ end
54
+
55
+ def self.authors
56
+ ["lyndsey-ferguson/lyndseydf"]
57
+ end
58
+
59
+ def self.available_options
60
+ [
61
+ FastlaneCore::ConfigItem.new(
62
+ key: :xcodeproj,
63
+ env_name: "FL_TESTPLANS_FROM_SCHEME_XCODE_PROJECT",
64
+ optional: true,
65
+ description: "The file path to the Xcode project file that references the Scheme",
66
+ verify_block: proc do |path|
67
+ path = File.expand_path(path.to_s)
68
+ UI.user_error!("Error: Xcode project file path not given!") unless path and !path.empty?
69
+ UI.user_error!("Error: Xcode project '#{path}' not found!") unless Dir.exist?(path)
70
+ end
71
+ ),
72
+ FastlaneCore::ConfigItem.new(
73
+ key: :workspace,
74
+ env_name: "FL_TESTPLANS_FROM_SCHEME_XCODE_WORKSPACE",
75
+ optional: true,
76
+ description: "The file path to the Xcode workspace file that references the Scheme",
77
+ verify_block: proc do |value|
78
+ v = File.expand_path(value.to_s)
79
+ UI.user_error!("Error: Workspace file not found at path '#{v}'") unless Dir.exist?(v)
80
+ UI.user_error!("Error: Workspace file is not a workspace, must end with .xcworkspace") unless v.include?(".xcworkspace")
81
+ end
82
+ ),
83
+ FastlaneCore::ConfigItem.new(
84
+ key: :scheme,
85
+ optional: true,
86
+ env_name: "FL_TESTPLANS_FROM_SCHEME_XCODE_SCHEME",
87
+ description: "The Xcode scheme referencing the testplan",
88
+ verify_block: proc do |scheme_name|
89
+ UI.user_error!("Error: Xcode Scheme '#{scheme_name}' is not valid!") if scheme_name and scheme_name.empty?
90
+ end
91
+ )
92
+ ]
93
+ end
94
+
95
+ def self.example_code
96
+ [
97
+ "
98
+ UI.important(
99
+ 'example: ' \\
100
+ 'get all the testplans that an Xcode Scheme references'
101
+ )
102
+ testplans = testplans_from_scheme(
103
+ xcodeproj: 'AtomicBoy/AtomicBoy.xcodeproj',
104
+ scheme: 'AtomicBoy'
105
+ )
106
+ UI.message(\"The AtomicBoy uses the following testplans: \#{testplans}\")
107
+ "
108
+ ]
109
+ end
110
+
111
+ def self.category
112
+ :testing
113
+ end
114
+
115
+ def self.is_supported?(platform)
116
+ %i[ios mac].include?(platform)
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,82 @@
1
+ module Fastlane
2
+ module Actions
3
+ module SharedValues
4
+ TESTS_FROM_XCRESULT_CUSTOM_VALUE = :TESTS_FROM_XCRESULT_CUSTOM_VALUE
5
+ end
6
+
7
+ class TestsFromXcresultAction < Action
8
+ def self.run(params)
9
+ # fastlane will take care of reading in the parameter and fetching the environment variable:
10
+ UI.message "Parameter API Token: #{params[:api_token]}"
11
+
12
+ # sh "shellcommand ./path"
13
+
14
+ # Actions.lane_context[SharedValues::TESTS_FROM_XCRESULT_CUSTOM_VALUE] = "my_val"
15
+ end
16
+
17
+ #####################################################
18
+ # @!group Documentation
19
+ #####################################################
20
+
21
+ def self.description
22
+ "A short description with <= 80 characters of what this action does"
23
+ end
24
+
25
+ def self.details
26
+ # Optional:
27
+ # this is your chance to provide a more detailed description of this action
28
+ "You can use this action to do cool things..."
29
+ end
30
+
31
+ def self.available_options
32
+ # Define all options your action supports.
33
+
34
+ # Below a few examples
35
+ [
36
+ FastlaneCore::ConfigItem.new(key: :api_token,
37
+ env_name: "FL_TESTS_FROM_XCRESULT_API_TOKEN", # The name of the environment variable
38
+ description: "API Token for TestsFromXcresultAction", # a short description of this parameter
39
+ verify_block: proc do |value|
40
+ UI.user_error!("No API token for TestsFromXcresultAction given, pass using `api_token: 'token'`") unless (value and not value.empty?)
41
+ # UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
42
+ end),
43
+ FastlaneCore::ConfigItem.new(key: :development,
44
+ env_name: "FL_TESTS_FROM_XCRESULT_DEVELOPMENT",
45
+ description: "Create a development certificate instead of a distribution one",
46
+ is_string: false, # true: verifies the input is a string, false: every kind of value
47
+ default_value: false) # the default value if the user didn't provide one
48
+ ]
49
+ end
50
+
51
+ def self.output
52
+ # Define the shared values you are going to provide
53
+ # Example
54
+ [
55
+ ['TESTS_FROM_XCRESULT_CUSTOM_VALUE', 'A description of what this value contains']
56
+ ]
57
+ end
58
+
59
+ def self.return_value
60
+ # If your method provides a return value, you can describe here what it does
61
+ end
62
+
63
+ def self.authors
64
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
65
+ ["Your GitHub/Twitter Name"]
66
+ end
67
+
68
+ def self.is_supported?(platform)
69
+ # you can do things like
70
+ #
71
+ # true
72
+ #
73
+ # platform == :ios
74
+ #
75
+ # [:ios, :mac].include?(platform)
76
+ #
77
+
78
+ platform == :ios
79
+ end
80
+ end
81
+ end
82
+ 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')
@@ -1,3 +1,5 @@
1
+ require_relative 'reportname_helper'
2
+ require_relative 'test_collector'
1
3
  require_relative 'multi_scan_manager/device_manager'
2
4
  require_relative 'multi_scan_manager/report_collator'
3
5
  require_relative 'multi_scan_manager/retrying_scan_helper'
@@ -17,11 +17,18 @@ module TestCenter
17
17
  end
18
18
  # :nocov:
19
19
 
20
- def prepare_scan_config_for_destination
20
+ def prepare_scan_config
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
+ # this prevents double -resultBundlePath args to xcodebuild
27
+ if ReportNameHelper.includes_xcresult?(@options[:output_types])
28
+ scan_config._values.delete(:result_bundle)
29
+ ENV.delete('SCAN_RESULT_BUNDLE')
30
+ end
31
+ scan_config._values.delete(:skip_testing)
25
32
  scan_cache.clear
26
33
  end
27
34
 
@@ -30,12 +37,13 @@ module TestCenter
30
37
  scan_options = @options.select { |k,v| valid_scan_keys.include?(k) }
31
38
  .merge(@retrying_scan_helper.scan_options)
32
39
 
33
- prepare_scan_config_for_destination
40
+ prepare_scan_config
34
41
  scan_options[:build_for_testing] = false
42
+ scan_options.delete(:skip_testing)
35
43
  FastlaneCore::UI.verbose("retrying_scan #update_scan_options")
36
44
  scan_options.each do |k,v|
37
45
  next if v.nil?
38
-
46
+
39
47
  scan_config.set(k,v) unless v.nil?
40
48
  FastlaneCore::UI.verbose("\tSetting #{k.to_s} to #{v}")
41
49
  end
@@ -52,7 +60,7 @@ module TestCenter
52
60
  begin
53
61
  @retrying_scan_helper.before_testrun
54
62
  update_scan_options
55
-
63
+
56
64
  values = scan_config.values(ask: false)
57
65
  values[:xcode_path] = File.expand_path("../..", FastlaneCore::Helper.xcode_path)
58
66
  ScanHelper.print_scan_parameters(values)
@@ -93,6 +93,10 @@ module TestCenter
93
93
  FastlaneCore::UI.important(":xcargs, #{xcargs}, contained 'build-for-testing', removing it")
94
94
  xcargs.slice!('build-for-testing')
95
95
  end
96
+ if xcargs.include?('-quiet')
97
+ FastlaneCore::UI.important('Disabling -quiet as failing tests cannot be found with it enabled.')
98
+ xcargs.gsub!('-quiet', '')
99
+ end
96
100
  xcargs.gsub!(/-parallel-testing-enabled(=|\s+)(YES|NO)/, '')
97
101
  retrying_scan_options = @reportnamer.scan_options.merge(
98
102
  {
@@ -245,7 +249,7 @@ module TestCenter
245
249
  junit: File.absolute_path(report_filepath)
246
250
  }
247
251
  )
248
- @options[:only_testing] = @options[:only_testing] - Fastlane::Actions::TestsFromJunitAction.run(config).fetch(:passing, Hash.new).map(&:shellsafe_testidentifier)
252
+ @options[:only_testing] = (@options[:only_testing] || []) - Fastlane::Actions::TestsFromJunitAction.run(config).fetch(:passing, Hash.new).map(&:shellsafe_testidentifier)
249
253
  if @options[:invocation_based_tests]
250
254
  @options[:only_testing] = @options[:only_testing].map(&:strip_testcase).uniq
251
255
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module TestCenter
3
2
  module Helper
4
3
  module MultiScanManager
@@ -40,7 +39,8 @@ module TestCenter
40
39
  return if @options[:invocation_based_tests] && @options[:only_testing].nil?
41
40
  return if @test_collector
42
41
 
43
- @test_collector = TestCenter::Helper::TestCollector.new(@options)
42
+ @test_collector = TestCollector.new(@options)
43
+ @options.reject! { |key| %i[testplan].include?(key) }
44
44
  @batch_count = @test_collector.test_batches.size
45
45
  end
46
46
 
@@ -207,10 +207,44 @@ module TestCenter
207
207
  File.absolute_path(output_directory),
208
208
  @test_collector.testables.first
209
209
  )
210
+ merge_single_testable_xcresult_with_final_xcresult(report_files_dir, File.absolute_path(output_directory))
210
211
  FileUtils.cp_r("#{report_files_dir}/.", File.absolute_path(output_directory))
211
212
  FileUtils.rm_rf(report_files_dir)
212
213
  end
213
214
 
215
+ def merge_single_testable_xcresult_with_final_xcresult(testable_output_dir, final_output_dir)
216
+ reportnamer = ReportNameHelper.new(
217
+ @options[:output_types],
218
+ @options[:output_files],
219
+ @options[:custom_report_file_name]
220
+ )
221
+ return unless reportnamer.includes_xcresult?
222
+
223
+ xcresult_bundlename = reportnamer.xcresult_bundlename
224
+ src_xcresult_bundlepath = File.join(testable_output_dir, xcresult_bundlename)
225
+ dst_xcresult_bundlepath = File.join(final_output_dir, xcresult_bundlename)
226
+
227
+ # We do not need to merge if one of these do not exist
228
+ return unless File.exist?(src_xcresult_bundlepath) || File.exist?(dst_xcresult_bundlepath)
229
+
230
+ config = FastlaneCore::Configuration.create(
231
+ Fastlane::Actions::CollateXcresultsAction.available_options,
232
+ {
233
+ xcresults: [src_xcresult_bundlepath, dst_xcresult_bundlepath],
234
+ collated_xcresult: dst_xcresult_bundlepath
235
+ }
236
+ )
237
+ FastlaneCore::UI.verbose("Merging xcresult '#{src_xcresult_bundlepath}' to '#{dst_xcresult_bundlepath}'")
238
+ Fastlane::Actions::CollateXcresultsAction.run(config)
239
+ FileUtils.rm_rf(src_xcresult_bundlepath)
240
+ if @result_bundle_desired
241
+ xcresult_bundlename = reportnamer.xcresult_bundlename
242
+ test_result_bundlename = File.basename(xcresult_bundlename, '.*') + '.test_result'
243
+ test_result_bundlename_path = File.join(testable_output_dir, test_result_bundlename)
244
+ FileUtils.rm_rf(test_result_bundlename_path)
245
+ end
246
+ end
247
+
214
248
  def symlink_result_bundle_to_xcresult(output_dir, reportname_helper)
215
249
  return unless @result_bundle_desired && reportname_helper.includes_xcresult?
216
250
 
@@ -15,7 +15,7 @@ module TestCenter
15
15
  unless @xctestrun_path && File.exist?(@xctestrun_path)
16
16
  FastlaneCore::UI.user_error!("Error: cannot find xctestrun file '#{@xctestrun_path}'")
17
17
  end
18
- @only_testing = options[:only_testing]
18
+ @only_testing = options[:only_testing] || only_testing_from_testplan(options)
19
19
  if @only_testing.kind_of?(String)
20
20
  @only_testing = @only_testing.split(',')
21
21
  end
@@ -27,6 +27,36 @@ module TestCenter
27
27
  end
28
28
  end
29
29
 
30
+ def only_testing_from_testplan(options)
31
+ return unless options[:testplan] && options[:scheme]
32
+
33
+ config = FastlaneCore::Configuration.create(
34
+ Fastlane::Actions::TestplansFromSchemeAction.available_options,
35
+ {
36
+ workspace: options[:workspace],
37
+ xcodeproj: options[:project],
38
+ scheme: options[:scheme]
39
+ }
40
+ )
41
+ testplans = Fastlane::Actions::TestplansFromSchemeAction.run(config)
42
+ FastlaneCore::UI.verbose("TestCollector found testplans: #{testplans}")
43
+ testplan = testplans.find do |testplan_path|
44
+ %r{(.*/?#{ options[:testplan] })\.xctestplan}.match?(testplan_path)
45
+ end
46
+ FastlaneCore::UI.verbose(" using :testplan option, #{options[:testplan]}, using found one: #{testplan}")
47
+
48
+ return if testplan.nil?
49
+
50
+ config = FastlaneCore::Configuration.create(
51
+ Fastlane::Actions::TestOptionsFromTestplanAction.available_options,
52
+ {
53
+ testplan: testplan
54
+ }
55
+ )
56
+ test_options = Fastlane::Actions::TestOptionsFromTestplanAction.run(config)
57
+ return test_options[:only_testing]
58
+ end
59
+
30
60
  def default_derived_data_path(options)
31
61
  project_derived_data_path = Scan.project.build_settings(key: "BUILT_PRODUCTS_DIR")
32
62
  File.expand_path("../../..", project_derived_data_path)
@@ -42,9 +72,7 @@ module TestCenter
42
72
  if @only_testing
43
73
  @testables ||= only_testing_to_testables_tests.keys
44
74
  else
45
- @testables ||= Plist.parse_xml(@xctestrun_path).keys.reject do |key|
46
- key == '__xctestrun_metadata__'
47
- end
75
+ @testables = xctestrun_known_tests.keys
48
76
  end
49
77
  end
50
78
  @testables
@@ -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.11.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.11.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-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -267,7 +267,10 @@ files:
267
267
  - lib/fastlane/plugin/test_center/actions/suppress_tests.rb
268
268
  - lib/fastlane/plugin/test_center/actions/suppress_tests_from_junit.rb
269
269
  - lib/fastlane/plugin/test_center/actions/suppressed_tests.rb
270
+ - lib/fastlane/plugin/test_center/actions/test_options_from_testplan.rb
271
+ - lib/fastlane/plugin/test_center/actions/testplans_from_scheme.rb
270
272
  - lib/fastlane/plugin/test_center/actions/tests_from_junit.rb
273
+ - lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb
271
274
  - lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb
272
275
  - lib/fastlane/plugin/test_center/helper/html_test_report.rb
273
276
  - lib/fastlane/plugin/test_center/helper/junit_helper.rb
@@ -285,6 +288,7 @@ files:
285
288
  - lib/fastlane/plugin/test_center/helper/scan_helper.rb
286
289
  - lib/fastlane/plugin/test_center/helper/test_collector.rb
287
290
  - lib/fastlane/plugin/test_center/helper/xcodebuild_string.rb
291
+ - lib/fastlane/plugin/test_center/helper/xcodeproj/scheme/test_action.rb
288
292
  - lib/fastlane/plugin/test_center/helper/xctestrun_info.rb
289
293
  - lib/fastlane/plugin/test_center/version.rb
290
294
  homepage: https://github.com/lyndsey-ferguson/fastlane-plugin-test_center
@@ -302,9 +306,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
306
  version: '0'
303
307
  required_rubygems_version: !ruby/object:Gem::Requirement
304
308
  requirements:
305
- - - ">"
309
+ - - ">="
306
310
  - !ruby/object:Gem::Version
307
- version: 1.3.1
311
+ version: '0'
308
312
  requirements: []
309
313
  rubygems_version: 3.0.6
310
314
  signing_key: