danger-xcode_summary 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba01bb92755852ab528ad3721b607d41ed61963d221d337a064fb8e54743871b
4
- data.tar.gz: 7378e516f2a5c98751997ac1e1fbdb2305805ff8a7d3bc6485a98a53e6a0deda
3
+ metadata.gz: 7f25343e3fe6e71f252e63e5874c5663ebf9b51ee797891a152cd7e2af4d1ebc
4
+ data.tar.gz: 22b537f085e5d3c7665b84de1b9eca6b1209fb718149470fd3cf7a1bf6a23bd9
5
5
  SHA512:
6
- metadata.gz: 1d48beaddc39c86f9393d1f276d55ec9293b86abb3261f47d148dedf3c46b6a706cd98b1e1ee3f3a67ef6a01206d1d9e58c1ce23952e303809a331813f62dda4
7
- data.tar.gz: ee27dafbd6f3915058dd04d0c5ec966ac0b6113fb61c4668e9c504a16a10eef0c418ce98ca10b8c3ff7e9f875ac25afec991eba54b984947c034f21127cc9d53
6
+ metadata.gz: 2110fe068bad96009dd912161fa6ef43eeda1e05ba47453ef81b07cc2821c4c0455b3b3d0ef91cb593fc3df166669e55a602a20a4bc6d34905f070571bae31d0
7
+ data.tar.gz: 071fcaecbf8488ce2b59efdc02eb778d2230283c97de53117155232c5ab8ad2f7bc0c14e4f749bd0d0f4648a8a115f3a4040ab28b2bebf83693ebc71be5d6bae
data/.rubocop.yml CHANGED
@@ -24,7 +24,7 @@ Style/ClassAndModuleChildren:
24
24
  Enabled: false
25
25
 
26
26
  Metrics/AbcSize:
27
- Max: 60
27
+ Max: 66
28
28
 
29
29
  # The %w might be confusing for new users
30
30
  Style/WordArray:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-xcode_summary (1.3.1)
4
+ danger-xcode_summary (1.4.0)
5
5
  danger-plugin-api (~> 1.0)
6
6
  xcresult (~> 0.2.2)
7
7
 
@@ -10,7 +10,8 @@ GEM
10
10
  specs:
11
11
  addressable (2.8.7)
12
12
  public_suffix (>= 2.0.2, < 7.0)
13
- ast (2.4.2)
13
+ ast (2.4.3)
14
+ base64 (0.3.0)
14
15
  claide (1.1.0)
15
16
  claide-plugins (0.9.2)
16
17
  cork
@@ -20,7 +21,8 @@ GEM
20
21
  colored2 (3.1.2)
21
22
  cork (0.3.0)
22
23
  colored2 (~> 3.1)
23
- danger (9.5.0)
24
+ danger (9.5.1)
25
+ base64 (~> 0.2)
24
26
  claide (~> 1.0)
25
27
  claide-plugins (>= 0.9.2)
26
28
  colored2 (~> 3.1)
@@ -31,28 +33,32 @@ GEM
31
33
  kramdown (~> 2.3)
32
34
  kramdown-parser-gfm (~> 1.0)
33
35
  octokit (>= 4.0)
36
+ pstore (~> 0.1)
34
37
  terminal-table (>= 1, < 4)
35
38
  danger-plugin-api (1.0.0)
36
39
  danger (> 2.0)
37
- diff-lcs (1.5.1)
38
- faraday (2.11.0)
39
- faraday-net_http (>= 2.0, < 3.4)
40
+ diff-lcs (1.6.2)
41
+ faraday (2.13.1)
42
+ faraday-net_http (>= 2.0, < 3.5)
43
+ json
40
44
  logger
41
45
  faraday-http-cache (2.5.1)
42
46
  faraday (>= 0.8)
43
- faraday-net_http (3.3.0)
44
- net-http
45
- ffi (1.17.0)
47
+ faraday-net_http (3.4.1)
48
+ net-http (>= 0.5.0)
49
+ ffi (1.17.2)
46
50
  formatador (1.1.0)
47
51
  git (1.19.1)
48
52
  addressable (~> 2.8)
49
53
  rchardet (~> 1.8)
50
- guard (2.18.1)
54
+ guard (2.19.1)
51
55
  formatador (>= 0.2.4)
52
56
  listen (>= 2.7, < 4.0)
57
+ logger (~> 1.6)
53
58
  lumberjack (>= 1.0.12, < 2.0)
54
59
  nenv (~> 0.1)
55
60
  notiffany (~> 0.0)
61
+ ostruct (~> 0.6)
56
62
  pry (>= 0.13.0)
57
63
  shellany (~> 0.0)
58
64
  thor (>= 0.18.1)
@@ -61,81 +67,88 @@ GEM
61
67
  guard (~> 2.1)
62
68
  guard-compat (~> 1.1)
63
69
  rspec (>= 2.99.0, < 4.0)
64
- json (2.7.2)
65
- kramdown (2.4.0)
66
- rexml
70
+ json (2.12.2)
71
+ kramdown (2.5.1)
72
+ rexml (>= 3.3.9)
67
73
  kramdown-parser-gfm (1.1.0)
68
74
  kramdown (~> 2.0)
69
- language_server-protocol (3.17.0.3)
75
+ language_server-protocol (3.17.0.5)
76
+ lint_roller (1.1.0)
70
77
  listen (3.9.0)
71
78
  rb-fsevent (~> 0.10, >= 0.10.3)
72
79
  rb-inotify (~> 0.9, >= 0.9.10)
73
- logger (1.6.1)
80
+ logger (1.7.0)
74
81
  lumberjack (1.2.10)
75
82
  method_source (1.1.0)
76
83
  nap (1.1.0)
77
84
  nenv (0.3.0)
78
- net-http (0.4.1)
85
+ net-http (0.6.0)
79
86
  uri
80
87
  notiffany (0.1.3)
81
88
  nenv (~> 0.1)
82
89
  shellany (~> 0.0)
83
- octokit (9.1.0)
90
+ octokit (10.0.0)
84
91
  faraday (>= 1, < 3)
85
92
  sawyer (~> 0.9)
86
93
  open4 (1.3.4)
87
- parallel (1.26.3)
88
- parser (3.3.5.0)
94
+ ostruct (0.6.1)
95
+ parallel (1.27.0)
96
+ parser (3.3.8.0)
89
97
  ast (~> 2.4.1)
90
98
  racc
91
- pry (0.14.2)
99
+ prism (1.4.0)
100
+ pry (0.15.2)
92
101
  coderay (~> 1.1)
93
102
  method_source (~> 1.0)
94
- public_suffix (6.0.1)
103
+ pstore (0.2.0)
104
+ public_suffix (6.0.2)
95
105
  racc (1.8.1)
96
106
  rainbow (3.1.1)
97
- rake (13.2.1)
107
+ rake (13.3.0)
98
108
  rb-fsevent (0.11.2)
99
109
  rb-inotify (0.11.1)
100
110
  ffi (~> 1.0)
101
- rchardet (1.8.0)
102
- regexp_parser (2.9.2)
103
- rexml (3.3.7)
104
- rspec (3.13.0)
111
+ rchardet (1.9.0)
112
+ regexp_parser (2.10.0)
113
+ rexml (3.4.1)
114
+ rspec (3.13.1)
105
115
  rspec-core (~> 3.13.0)
106
116
  rspec-expectations (~> 3.13.0)
107
117
  rspec-mocks (~> 3.13.0)
108
- rspec-core (3.13.1)
118
+ rspec-core (3.13.4)
109
119
  rspec-support (~> 3.13.0)
110
- rspec-expectations (3.13.2)
120
+ rspec-expectations (3.13.5)
111
121
  diff-lcs (>= 1.2.0, < 2.0)
112
122
  rspec-support (~> 3.13.0)
113
- rspec-mocks (3.13.1)
123
+ rspec-mocks (3.13.5)
114
124
  diff-lcs (>= 1.2.0, < 2.0)
115
125
  rspec-support (~> 3.13.0)
116
- rspec-support (3.13.1)
117
- rubocop (1.66.1)
126
+ rspec-support (3.13.4)
127
+ rubocop (1.76.1)
118
128
  json (~> 2.3)
119
- language_server-protocol (>= 3.17.0)
129
+ language_server-protocol (~> 3.17.0.2)
130
+ lint_roller (~> 1.1.0)
120
131
  parallel (~> 1.10)
121
132
  parser (>= 3.3.0.2)
122
133
  rainbow (>= 2.2.2, < 4.0)
123
- regexp_parser (>= 2.4, < 3.0)
124
- rubocop-ast (>= 1.32.2, < 2.0)
134
+ regexp_parser (>= 2.9.3, < 3.0)
135
+ rubocop-ast (>= 1.45.0, < 2.0)
125
136
  ruby-progressbar (~> 1.7)
126
- unicode-display_width (>= 2.4.0, < 3.0)
127
- rubocop-ast (1.32.2)
128
- parser (>= 3.3.1.0)
137
+ unicode-display_width (>= 2.4.0, < 4.0)
138
+ rubocop-ast (1.45.1)
139
+ parser (>= 3.3.7.2)
140
+ prism (~> 1.4)
129
141
  ruby-progressbar (1.13.0)
130
142
  sawyer (0.9.2)
131
143
  addressable (>= 2.3.5)
132
144
  faraday (>= 0.17.3, < 3)
133
145
  shellany (0.0.1)
134
- terminal-table (3.0.2)
135
- unicode-display_width (>= 1.1.1, < 3)
146
+ terminal-table (1.6.0)
136
147
  thor (1.3.2)
137
- unicode-display_width (2.5.0)
138
- uri (0.13.1)
148
+ unicode-display_width (3.1.4)
149
+ unicode-emoji (~> 4.0, >= 4.0.4)
150
+ unicode-emoji (4.0.4)
151
+ uri (1.0.3)
139
152
  xcresult (0.2.2)
140
153
  yard (0.9.37)
141
154
 
data/README.md CHANGED
@@ -107,6 +107,10 @@ xcode_summary.ignored_results { |result|
107
107
  }
108
108
 
109
109
  xcode_summary.report 'MyApp.xcresult'
110
+
111
+ # When `true`, collapses parallelized test runs of the same target into one line.
112
+ # Defaults to `false`.
113
+ xcode_summary.collapse_parallelized_tests = true
110
114
  ```
111
115
 
112
116
  You can use `ignores_warnings` to supress warnings and shows only errors.
@@ -3,7 +3,7 @@
3
3
  lib = File.expand_path('lib', __dir__)
4
4
 
5
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
- require 'xcode_summary/gem_version.rb'
6
+ require 'xcode_summary/gem_version'
7
7
 
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = 'danger-xcode_summary'
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.required_ruby_version = ">= 2.4.0"
24
+ spec.required_ruby_version = '>= 2.4.0'
25
25
 
26
+ spec.add_dependency 'danger-plugin-api', '~> 1.0'
26
27
  spec.add_dependency 'xcresult', '~> 0.2.2'
27
- spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
28
28
 
29
29
  # General ruby development
30
30
  spec.add_development_dependency 'bundler', '>= 2.2.10'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XcodeSummary
4
- VERSION = '1.3.1'
4
+ VERSION = '1.4.0'
5
5
  end
@@ -82,6 +82,12 @@ module Danger
82
82
  # @return [Boolean]
83
83
  attr_accessor :strict
84
84
 
85
+ # Defines if parallelized test runs from the same target should be collapsed into one message.
86
+ # Defaults to `false`
87
+ # @param [Boolean] value
88
+ # @return [Boolean]
89
+ attr_accessor :collapse_parallelized_tests
90
+
85
91
  # rubocop:disable Lint/DuplicateMethods
86
92
  def project_root
87
93
  root = @project_root || Dir.pwd
@@ -106,7 +112,7 @@ module Danger
106
112
  end
107
113
 
108
114
  def test_summary
109
- @test_summary.nil? ? true : @test_summary
115
+ @test_summary.nil? || @test_summary
110
116
  end
111
117
 
112
118
  def inline_mode
@@ -118,7 +124,11 @@ module Danger
118
124
  end
119
125
 
120
126
  def strict
121
- @strict.nil? ? true : @strict
127
+ @strict.nil? || @strict
128
+ end
129
+
130
+ def collapse_parallelized_tests
131
+ @collapse_parallelized_tests || false
122
132
  end
123
133
 
124
134
  # Pick a Dangerfile plugin for a chosen request_source and cache it
@@ -211,26 +221,63 @@ module Danger
211
221
 
212
222
  def messages(xcode_summary)
213
223
  if test_summary
214
- test_messages = xcode_summary.action_test_plan_summaries.map do |test_plan_summaries|
224
+ test_runs = xcode_summary.action_test_plan_summaries.map do |test_plan_summaries|
215
225
  test_plan_summaries.summaries.map do |summary|
216
226
  summary.testable_summaries.map do |test_summary|
217
227
  test_summary.tests.filter_map do |action_test_object|
218
228
  if action_test_object.instance_of? XCResult::ActionTestSummaryGroup
219
229
  subtests = action_test_object.all_subtests
220
230
  subtests_duration = subtests.map(&:duration).sum
221
- test_text_infix = subtests.count == 1 ? 'test' : 'tests'
231
+
222
232
  failed_tests_count = subtests.reject { |test| test.test_status == 'Success' }.count
223
233
  expected_failed_tests_count = subtests.select { |test| test.test_status == 'Expected Failure' }.count
224
234
 
225
- "#{test_summary.target_name}: Executed #{subtests.count} #{test_text_infix}, " \
226
- "with #{failed_tests_count} failures (#{expected_failed_tests_count} expected) in " \
227
- "#{subtests_duration.round(3)} (#{action_test_object.duration.round(3)}) seconds"
235
+ {
236
+ target_name: test_summary.target_name,
237
+ test_count: subtests.count,
238
+ failed_tests_count: failed_tests_count,
239
+ expected_failed_tests_count: expected_failed_tests_count,
240
+ tests_duration: subtests_duration,
241
+ action_duration: action_test_object.duration
242
+ }
228
243
  end
229
244
  end
230
245
  end
231
246
  end
232
247
  end
233
- test_messages.flatten.uniq.compact.map(&:strip)
248
+
249
+ flattened_test_runs = test_runs.flatten.uniq.compact
250
+
251
+ if collapse_parallelized_tests
252
+ test_runs_by_target = flattened_test_runs.group_by { |test_run| test_run[:target_name] }
253
+ flattened_test_runs = test_runs_by_target.map do |target_name, test_runs|
254
+ test_runs.reduce do |acc, test_run|
255
+ acc.merge(
256
+ test_count: acc[:test_count] + test_run[:test_count],
257
+ failed_tests_count: acc[:failed_tests_count] + test_run[:failed_tests_count],
258
+ expected_failed_tests_count: acc[:expected_failed_tests_count] + test_run[:expected_failed_tests_count],
259
+ tests_duration: acc[:tests_duration] + test_run[:tests_duration],
260
+ action_duration: acc[:action_duration] + test_run[:action_duration]
261
+ )
262
+ end
263
+ end
264
+ end
265
+
266
+ test_messages = flattened_test_runs.map do |test_run|
267
+ target_name = test_run[:target_name]
268
+ test_count = test_run[:test_count]
269
+ failed_tests_count = test_run[:failed_tests_count]
270
+ expected_failed_tests_count = test_run[:expected_failed_tests_count]
271
+ subtests_duration = test_run[:tests_duration]
272
+ action_duration = test_run[:action_duration]
273
+ test_text_infix = test_count == 1 ? 'test' : 'tests'
274
+
275
+ "#{target_name}: Executed #{test_count} #{test_text_infix}, " \
276
+ "with #{failed_tests_count} failures (#{expected_failed_tests_count} expected) in " \
277
+ "#{subtests_duration.round(3)} (#{action_duration.round(3)}) seconds"
278
+ end
279
+
280
+ test_messages.map(&:strip)
234
281
  else
235
282
  []
236
283
  end
data/spec/spec_helper.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'pathname'
4
4
  ROOT = Pathname.new(File.expand_path('..', __dir__))
5
- $LOAD_PATH.unshift("#{ROOT}lib".to_s)
6
- $LOAD_PATH.unshift("#{ROOT}spec".to_s)
5
+ $LOAD_PATH.unshift("#{ROOT}lib")
6
+ $LOAD_PATH.unshift("#{ROOT}spec")
7
7
 
8
8
  require 'bundler/setup'
9
9
  require 'pry'
@@ -257,6 +257,60 @@ module Danger
257
257
  expect(result).to eq '{"warnings":21,"errors":3}'
258
258
  end
259
259
  end
260
+
261
+ context 'with collapse_parallelized_tests' do
262
+ context 'enabled' do
263
+ before do
264
+ @xcode_summary.collapse_parallelized_tests = true
265
+ end
266
+
267
+ it 'collapses test runs from the same target' do
268
+ # Allow for message receiving testing
269
+ allow(@xcode_summary).to receive(:message).and_call_original
270
+ @xcode_summary.report('spec/fixtures/swiftlint.xcresult')
271
+
272
+ # Ensure that the plugin received a call to message with the combined test results
273
+ expect(@xcode_summary).to have_received(:message).with(/SwiftLintFrameworkTests: Executed .* tests/m, sticky: false)
274
+
275
+ # The standard test case should only show one message per target, even with parallelized tests
276
+ expect(@dangerfile.status_report[:messages].length).to eq(1)
277
+ end
278
+ end
279
+
280
+ context 'disabled' do
281
+ before do
282
+ @xcode_summary.collapse_parallelized_tests = false
283
+ end
284
+
285
+ it 'shows individual test runs for each target' do
286
+ @xcode_summary.report('spec/fixtures/swiftlint.xcresult')
287
+
288
+ # We know from the existing tests that the standard behavior should match
289
+ # the test in the "summary" context, with one test run per message
290
+ expect(@dangerfile.status_report[:messages]).to eq [
291
+ 'SwiftLintFrameworkTests: Executed 540 tests, with 1 failures (0 expected) in 114.029 (27.922) seconds'
292
+ ]
293
+ end
294
+ end
295
+
296
+ context 'with default value' do
297
+ it 'defaults to disabled behavior' do
298
+ # Don't set collapse_parallelized_tests to test the default
299
+ # Reset any test_summary setting to ensure clean state
300
+ @xcode_summary.test_summary = true
301
+
302
+ @xcode_summary.report('spec/fixtures/swiftlint.xcresult')
303
+
304
+ # Default should match the disabled behavior
305
+ expect(@dangerfile.status_report[:messages]).to eq [
306
+ 'SwiftLintFrameworkTests: Executed 540 tests, with 1 failures (0 expected) in 114.029 (27.922) seconds'
307
+ ]
308
+
309
+ # Verify the default value is false
310
+ expect(@xcode_summary.collapse_parallelized_tests).to eq(false)
311
+ end
312
+ end
313
+ end
260
314
  end
261
315
  end
262
316
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-xcode_summary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diogo Tridapalli
@@ -9,36 +9,36 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-09-04 00:00:00.000000000 Z
12
+ date: 2025-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: xcresult
15
+ name: danger-plugin-api
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.2.2
20
+ version: '1.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.2.2
27
+ version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: danger-plugin-api
29
+ name: xcresult
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.0'
34
+ version: 0.2.2
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.0'
41
+ version: 0.2.2
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement