fastlane-plugin-test_center 3.10.3 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/fastlane/plugin/test_center/actions/multi_scan.rb +6 -2
- data/lib/fastlane/plugin/test_center/actions/test_options_from_testplan.rb +90 -0
- data/lib/fastlane/plugin/test_center/actions/testplans_from_scheme.rb +120 -0
- data/lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb +82 -0
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager.rb +2 -0
- data/lib/fastlane/plugin/test_center/helper/multi_scan_manager/runner.rb +2 -2
- data/lib/fastlane/plugin/test_center/helper/test_collector.rb +31 -1
- data/lib/fastlane/plugin/test_center/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fe7c4581f1be17faf807466f1b9b82cf6ee917fef0695c861ef718417dc4c0d
|
4
|
+
data.tar.gz: e0b966985549a444bfcafafa4926eb4f4927f6f43b12b39aa0b025c935e6b185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f412ba3da2f63443923a94dec51b9f8bd7ed792ab98b4e0c1076fad2520e2a22eed74d3214cab40b36266c2fe35ca136194f4fdcd0e6d42c9730c80237fa0dff
|
7
|
+
data.tar.gz: fc7cb57702c648d99079d092b03abf44726a7fe6ac229da7202d73fe745de3e7d33be40675d0b8f0ce2827fbb7cc314d335a2019163b6a675b4cd5177e5e711b
|
data/README.md
CHANGED
@@ -91,9 +91,10 @@ 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
|
-
##
|
94
|
+
## Supporters
|
95
95
|
|
96
|
-
|
96
|
+
![Владислав Давыдов](https://avatars1.githubusercontent.com/u/47553334?s=44&u=4691860dba898943b947180b3d28bb85851b0d7c&v=4)
|
97
|
+
[vdavydovHH](https://github.com/vdavydovHH)
|
97
98
|
|
98
99
|
## License
|
99
100
|
|
@@ -232,7 +232,7 @@ module Fastlane
|
|
232
232
|
end
|
233
233
|
|
234
234
|
def self.prepare_scan_options_for_build_for_testing(scan_options)
|
235
|
-
build_options = scan_options.merge(build_for_testing: true).reject { |k| k
|
235
|
+
build_options = scan_options.merge(build_for_testing: true).reject { |k| %i[test_without_building, testplan].include?(k) }
|
236
236
|
Scan.config = FastlaneCore::Configuration.create(
|
237
237
|
Fastlane::Actions::ScanAction.available_options,
|
238
238
|
ScanHelper.scan_options_from_multi_scan_options(build_options)
|
@@ -244,7 +244,11 @@ module Fastlane
|
|
244
244
|
end
|
245
245
|
|
246
246
|
def self.update_xctestrun_after_build(scan_options)
|
247
|
-
|
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)
|
248
252
|
UI.verbose("After building, found xctestrun files #{xctestrun_files} (choosing 1st)")
|
249
253
|
scan_options[:xctestrun] = xctestrun_files.first
|
250
254
|
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
|
@@ -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 =
|
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
|
|
@@ -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)
|
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.
|
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-06-
|
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
|