fastlane-plugin-test_center 0.2.1 → 0.3.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f408456a45d4decc0519f804501acdb10da66e91
|
4
|
+
data.tar.gz: 771d1e7586c2a514aa1e0e4b7ee4b2230ad92bea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 624872099352f31744380b7020c1de125306173cd9f0744401db5cee69689abc232ed24fd5b5aa914befde120624459dc22cfeb5a24af166df97374ac6a54ebb
|
7
|
+
data.tar.gz: f1bea4edbc9ddc37bb9b98224a56f030cdab43e5f43fc0f61f7939ef8ea3a589761695ca71e305b4d4f005c9f734435001251bd4f228f5f896a6ded6d375e9b0
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
module SharedValues
|
4
|
+
SUPPRESS_TESTS_FROM_JUNIT_CUSTOM_VALUE = :SUPPRESS_TESTS_FROM_JUNIT_CUSTOM_VALUE
|
5
|
+
end
|
6
|
+
|
7
|
+
class SuppressTestsFromJunitAction < Action
|
8
|
+
def self.run(params)
|
9
|
+
project_path = params[:xcodeproj]
|
10
|
+
scheme = params[:scheme]
|
11
|
+
|
12
|
+
scheme_filepaths = Dir.glob("#{project_path}/{xcshareddata,xcuserdata}/**/xcschemes/#{scheme || '*'}.xcscheme")
|
13
|
+
if scheme_filepaths.length.zero?
|
14
|
+
UI.user_error!("Error: cannot find any scheme named #{scheme}") unless scheme.nil?
|
15
|
+
UI.user_error!("Error: cannot find any schemes in the Xcode project")
|
16
|
+
end
|
17
|
+
|
18
|
+
report_file = File.open(params[:junit]) { |f| REXML::Document.new(f) }
|
19
|
+
UI.user_error!("Malformed XML test report file given") if report_file.root.nil?
|
20
|
+
UI.user_error!("Valid XML file is not an Xcode test report") if report_file.get_elements('testsuites').empty?
|
21
|
+
|
22
|
+
if params[:suppress_type] == :failed
|
23
|
+
tests_per_target_to_suppress = failing_tests(report_file)
|
24
|
+
else
|
25
|
+
tests_per_target_to_suppress = passing_tests(report_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
scheme_filepaths.each do |scheme_filepath|
|
29
|
+
is_dirty = false
|
30
|
+
xcscheme = Xcodeproj::XCScheme.new(scheme_filepath)
|
31
|
+
|
32
|
+
xcscheme.test_action.testables.each do |testable|
|
33
|
+
buildable_name = testable.buildable_references[0].buildable_name
|
34
|
+
|
35
|
+
tests_per_target_to_suppress[buildable_name].each do |test_to_skip|
|
36
|
+
skipped_test = Xcodeproj::XCScheme::TestAction::TestableReference::SkippedTest.new
|
37
|
+
skipped_test.identifier = test_to_skip
|
38
|
+
testable.add_skipped_test(skipped_test)
|
39
|
+
is_dirty = true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
xcscheme.save! if is_dirty
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.failing_tests(report_file)
|
47
|
+
tests = Hash.new { |hash, key| hash[key] = [] }
|
48
|
+
|
49
|
+
report_file.elements.each('*/testsuite/testcase/failure') do |failure_element|
|
50
|
+
testcase = failure_element.parent
|
51
|
+
testsuite_element = testcase.parent
|
52
|
+
buildable_name = buildable_name_from_testcase(testcase)
|
53
|
+
|
54
|
+
tests[buildable_name] << xctest_identifier(testcase)
|
55
|
+
# Remove all the failures from this in-memory xml file to make
|
56
|
+
# it easier to find the passing tests below
|
57
|
+
testsuite_element.delete_element testcase
|
58
|
+
end
|
59
|
+
tests
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.passing_tests(report_file)
|
63
|
+
tests = Hash.new { |hash, key| hash[key] = [] }
|
64
|
+
|
65
|
+
report_file.elements.each('*/testsuite/testcase') do |testcase|
|
66
|
+
buildable_name = buildable_name_from_testcase(testcase)
|
67
|
+
|
68
|
+
tests[buildable_name] << xctest_identifier(testcase)
|
69
|
+
end
|
70
|
+
tests
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.buildable_name_from_testcase(testcase)
|
74
|
+
testsuite_element = testcase.parent
|
75
|
+
buildable_element = testsuite_element.parent
|
76
|
+
buildable_element.attributes['name']
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.xctest_identifier(testcase)
|
80
|
+
testcase_class = testcase.attributes['classname']
|
81
|
+
testcase_testmethod = testcase.attributes['name']
|
82
|
+
|
83
|
+
is_swift = testcase_class.include?('.')
|
84
|
+
testcase_class.gsub!(/.*\./, '')
|
85
|
+
testcase_testmethod << '()' if is_swift
|
86
|
+
"#{testcase_class}/#{testcase_testmethod}"
|
87
|
+
end
|
88
|
+
|
89
|
+
#####################################################
|
90
|
+
# @!group Documentation
|
91
|
+
#####################################################
|
92
|
+
|
93
|
+
def self.description
|
94
|
+
"Uses a junit xml report file to suppress either passing or failing tests in an Xcode Scheme"
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.details
|
98
|
+
"To be added"
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.available_options
|
102
|
+
[
|
103
|
+
FastlaneCore::ConfigItem.new(
|
104
|
+
key: :xcodeproj,
|
105
|
+
env_name: "FL_SUPPRESS_TESTS_FROM_JUNIT_XCODE_PROJECT", # The name of the environment variable
|
106
|
+
description: "The file path to the Xcode project file to modify", # a short description of this parameter
|
107
|
+
verify_block: proc do |path|
|
108
|
+
UI.user_error!("Error: Xcode project file path not given!") unless path and !path.empty?
|
109
|
+
UI.user_error!("Error: Xcode project '#{path}' not found!") unless Dir.exist?(path)
|
110
|
+
end
|
111
|
+
),
|
112
|
+
FastlaneCore::ConfigItem.new(
|
113
|
+
key: :junit,
|
114
|
+
env_name: "FL_SUPPRESS_TESTS_FROM_JUNIT_JUNIT_REPORT", # The name of the environment variable
|
115
|
+
description: "The junit xml report file from which to collect the tests to suppress",
|
116
|
+
verify_block: proc do |path|
|
117
|
+
UI.user_error!("Error: cannot find the junit xml report file '#{path}'") unless File.exist?(path)
|
118
|
+
end
|
119
|
+
),
|
120
|
+
FastlaneCore::ConfigItem.new(
|
121
|
+
key: :scheme,
|
122
|
+
optional: true,
|
123
|
+
env_name: "FL_SUPPRESS_TESTS_FROM_JUNIT_SCHEME_TO_UPDATE", # The name of the environment variable
|
124
|
+
description: "The Xcode scheme where the tests should be suppressed", # a short description of this parameter
|
125
|
+
verify_block: proc do |scheme_name|
|
126
|
+
UI.user_error!("Error: Xcode Scheme '#{scheme_name}' is not valid!") if scheme_name and scheme_name.empty?
|
127
|
+
end
|
128
|
+
),
|
129
|
+
FastlaneCore::ConfigItem.new(
|
130
|
+
key: :suppress_type,
|
131
|
+
type: Symbol,
|
132
|
+
env_name: "FL_SUPPRESS_TESTS_FROM_JUNIT_SUPPRESS_TYPE", # The name of the environment variable
|
133
|
+
description: "Tests to suppress are either :failed or :passing", # a short description of this parameter
|
134
|
+
verify_block: proc do |type|
|
135
|
+
UI.user_error!("Error: suppress type ':#{type}' is invalid! Only :failed or :passing are valid types") unless %i[failed passing].include?(type)
|
136
|
+
end
|
137
|
+
)
|
138
|
+
]
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.authors
|
142
|
+
["lyndsey-ferguson/@ldferguson"]
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.is_supported?(platform)
|
146
|
+
platform == :ios
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
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: 0.
|
4
|
+
version: 0.3.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: 2017-
|
11
|
+
date: 2017-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- README.md
|
133
133
|
- lib/fastlane/plugin/test_center.rb
|
134
134
|
- lib/fastlane/plugin/test_center/actions/suppress_tests.rb
|
135
|
+
- lib/fastlane/plugin/test_center/actions/suppress_tests_from_junit.rb
|
135
136
|
- lib/fastlane/plugin/test_center/actions/suppressed_tests.rb
|
136
137
|
- lib/fastlane/plugin/test_center/actions/test_center_action.rb
|
137
138
|
- lib/fastlane/plugin/test_center/helper/test_center_helper.rb
|