fastlane-plugin-test_center 2.2.1 → 2.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: 4aa0a9fe29d653e795cea77a0bd9ebd3b5b7bd31
4
- data.tar.gz: 51e8b46c2f583e5671e4714b908af491536f255e
3
+ metadata.gz: a64f4a3e425bf54d6af1be29d1d469cf23583b1d
4
+ data.tar.gz: 317d1a0570db66453b52472d8579b7a32fb08c84
5
5
  SHA512:
6
- metadata.gz: 68701ec0319d7b57002072cff6417479983f51be0f9ab5d369c35caf64418807335116c005ae2b8f3598bf285038c716b33bac9cebd9da23013556edce804df7
7
- data.tar.gz: bbf9fe27feacb12076c1aed2315f9f7f5fdbf52dbb7af3d61defa56cc053ef2716b7bd446cb0b5079669638609f88539b1ee7655e46643c6dd20b5857930b8b2
6
+ metadata.gz: fd94cba9b112713bf4dc445a64b623081f4ebfd59f97e607c0240c4c771983acd78896dfb379314c9fecd62b07ac6320f61dab54eba8efaeade55eff27b6e848
7
+ data.tar.gz: 788604b0ddc8f88a3f00b83d2c03f0084e1efda670fdb4c0b46db3796487b5a9047411314767aaf82a488f98b644531f0d873ec7d7dae76e9f627f4938d57762
data/README.md CHANGED
@@ -23,6 +23,7 @@ This fastlane plugin includes the following actions:
23
23
  - `suppress_tests`: suppresses specific tests in a specific or all Xcode Schemes in a given project
24
24
  - `suppressed_tests`: retrieves a list of tests that are suppressed in a specific or all Xcode Schemes in a project
25
25
  - `tests_from_junit`: retrieves the failing and passing tests as reported in a junit xml file
26
+ - `collate_junit_reports`: collects and correctly organizes junit reports from multiple test passes
26
27
 
27
28
  ## Example
28
29
 
@@ -0,0 +1,134 @@
1
+ require 'pry-byebug'
2
+ module Fastlane
3
+ module Actions
4
+ class CollateJunitReportsAction < Action
5
+ def self.run(params)
6
+ report_filepaths = params[:reports]
7
+ if report_filepaths.size == 1
8
+ FileUtils.cp(report_filepaths[0], params[:collated_report])
9
+ else
10
+ reports = report_filepaths.map { |report_filepath| REXML::Document.new(File.new(report_filepath)) }
11
+
12
+ # copy any missing testsuites
13
+ target_report = reports.shift
14
+ reports.each do |report|
15
+ report.elements.each('//testsuite') do |testsuite|
16
+ testsuite_name = testsuite.attributes['name']
17
+
18
+ target_testsuite = REXML::XPath.first(target_report, "//testsuite[@name='#{testsuite_name}']")
19
+ if target_testsuite
20
+ testsuite.elements.each('testcase') do |testcase|
21
+ classname = testcase.attributes['classname']
22
+ name = testcase.attributes['name']
23
+ target_testcase = REXML::XPath.first(target_testsuite, "testcase[@name='#{name}' and @classname='#{classname}']")
24
+ # Replace target_testcase with testcase
25
+ if target_testcase
26
+ target_testcase.parent.insert_after(target_testcase, testcase)
27
+ target_testcase.parent.delete_element(target_testcase)
28
+ end
29
+ end
30
+ else
31
+ testable = REXML::XPath.first(target_report, "//testsuites")
32
+ testable << testsuite
33
+ end
34
+ end
35
+ end
36
+ target_report.elements.each('//testsuite') do |testsuite|
37
+ update_testsuite_counts(testsuite)
38
+ end
39
+ testable = REXML::XPath.first(target_report, 'testsuites')
40
+ update_testable_counts(testable)
41
+
42
+ FileUtils.mkdir_p(File.dirname(params[:collated_report]))
43
+ File.open(params[:collated_report], 'w') do |f|
44
+ target_report.write(f, 2)
45
+ end
46
+ end
47
+ end
48
+
49
+ def self.update_testable_counts(testable)
50
+ testsuites = REXML::XPath.match(testable, 'testsuite')
51
+ test_count = 0
52
+ failure_count = 0
53
+ testsuites.each do |testsuite|
54
+ test_count += testsuite.attributes['tests'].to_i
55
+ failure_count += testsuite.attributes['failures'].to_i
56
+ end
57
+ testable.attributes['tests'] = test_count.to_s
58
+ testable.attributes['failures'] = failure_count.to_s
59
+ end
60
+
61
+ def self.update_testsuite_counts(testsuite)
62
+ testcases = REXML::XPath.match(testsuite, 'testcase')
63
+ testsuite.attributes['tests'] = testcases.size.to_s
64
+ failure_count = testcases.reduce(0) do |count, testcase|
65
+ if REXML::XPath.first(testcase, 'failure')
66
+ count += 1
67
+ end
68
+ count
69
+ end
70
+ testsuite.attributes['failures'] = failure_count.to_s
71
+ end
72
+
73
+ def self.attribute_sum_string(node1, node2, attribute)
74
+ value1 = node1.attributes[attribute].to_i
75
+ value2 = node2.attributes[attribute].to_i
76
+ (value1 + value2).to_s
77
+ end
78
+
79
+ #####################################################
80
+ # @!group Documentation
81
+ #####################################################
82
+
83
+ def self.description
84
+ "Combines and combines tests from multiple junit report files"
85
+ end
86
+
87
+ def self.details
88
+ "The first junit report is used as the base report. Testcases " \
89
+ "from other reports are added if they do not already exist, or " \
90
+ "if the testcases already exist, they are replaced." \
91
+ "" \
92
+ "This is done because it is assumed that fragile tests, when " \
93
+ "re-run will often succeed due to less interference from other " \
94
+ "tests and the subsequent junit reports will have more passed tests." \
95
+ "" \
96
+ "Inspired by Derek Yang's fastlane-plugin-merge_junit_report"
97
+ end
98
+
99
+ def self.available_options
100
+ [
101
+ FastlaneCore::ConfigItem.new(
102
+ key: :reports,
103
+ env_name: 'COLLATE_JUNIT_REPORTS_REPORTS',
104
+ description: 'An array of junit reports to collate. The first report is used as the base into which other reports are merged in',
105
+ optional: false,
106
+ type: Array,
107
+ verify_block: proc do |reports|
108
+ UI.user_error!('No junit report files found') if reports.empty?
109
+ reports.each do |report|
110
+ UI.user_error!("Error: junit report not found: '#{report}'") unless File.exist?(report)
111
+ end
112
+ end
113
+ ),
114
+ FastlaneCore::ConfigItem.new(
115
+ key: :collated_report,
116
+ env_name: 'COLLATE_JUNIT_REPORTS_COLLATED_REPORT',
117
+ description: 'The final junit report file where all testcases will be merged into',
118
+ optional: true,
119
+ default_value: 'result.xml',
120
+ type: String
121
+ )
122
+ ]
123
+ end
124
+
125
+ def self.authors
126
+ ["lyndsey-ferguson/@lyndseydf"]
127
+ end
128
+
129
+ def self.is_supported?(platform)
130
+ platform == :ios
131
+ end
132
+ end
133
+ end
134
+ end
@@ -1,7 +1,6 @@
1
1
  module Fastlane
2
2
  module Actions
3
3
  require 'fastlane/actions/scan'
4
- require 'fastlane/plugin/merge_junit_report'
5
4
  require 'shellwords'
6
5
 
7
6
  class MultiScanAction < Action
@@ -53,9 +52,9 @@ module Fastlane
53
52
  if match
54
53
  final_report_name = "#{match[:filename]}#{extension}"
55
54
  end
56
- other_action.merge_junit_report(
57
- input_files: report_files.reverse,
58
- output_file: File.absolute_path(File.join(scan_options[:output_directory], final_report_name))
55
+ other_action.collate_junit_reports(
56
+ reports: report_files.reverse,
57
+ collated_report: File.absolute_path(File.join(scan_options[:output_directory], final_report_name))
59
58
  )
60
59
  end
61
60
  FileUtils.rm_f(Dir.glob("#{scan_options[:output_directory]}/*-[1-9]*#{extension}"))
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TestCenter
3
- VERSION = "2.2.1"
3
+ VERSION = "2.3.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: 2.2.1
4
+ version: 2.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: 2018-01-15 00:00:00.000000000 Z
11
+ date: 2018-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: fastlane-plugin-merge_junit_report
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +143,7 @@ description: |2
157
143
  3) suppress_tests: suppresses specific tests in a specific or all Xcode Schemes in a given project.
158
144
  4) suppressed_tests: retrieves a list of tests that are suppressed in a specific or all Xcode Schemes in a project.
159
145
  5) tests_from_junit: retrieves the failing and passing tests as reported in a junit xml file.
146
+ 6) collate_junit_reports: collects and correctly organizes junit reports from multiple test passes.
160
147
  email: ldf.public+github@outlook.com
161
148
  executables: []
162
149
  extensions: []
@@ -165,6 +152,7 @@ files:
165
152
  - LICENSE
166
153
  - README.md
167
154
  - lib/fastlane/plugin/test_center.rb
155
+ - lib/fastlane/plugin/test_center/actions/collate_junit_reports.rb
168
156
  - lib/fastlane/plugin/test_center/actions/multi_scan.rb
169
157
  - lib/fastlane/plugin/test_center/actions/suppress_tests.rb
170
158
  - lib/fastlane/plugin/test_center/actions/suppress_tests_from_junit.rb