rspec_trunk_flaky_tests 0.16.0.pre.beta.1-aarch64-linux-gnu → 0.16.1.pre.beta.1-aarch64-linux-gnu

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: a5f133098512cc3194e22a64fc7cc1f9ede5dff0d77ac4d87d21ffc510595b6e
4
- data.tar.gz: 06b7a82db3158859bfb427adbd0b17faf91754141af707472bef339ed9952357
3
+ metadata.gz: c908033e645bb9359d694008af63e683defe687b2e98db9085089579368f8136
4
+ data.tar.gz: 0b1fcd78b0f285a8b70c0ffb873d961fb5ad10a716242aaf25ab16b4a25c257d
5
5
  SHA512:
6
- metadata.gz: 83913fec5f942c24f941b57cedef4310db8aa777b8f6cee6f2388835858563d6d6ef3da7028f9aab18fe652ea70ef8879399dbdd4b178d1a4d4158445f777bd9
7
- data.tar.gz: 954bb6e52a4d7febc2be0715e50e93ea17a0fceb01feb2eca103238f8a59b96c90e9ebd68f60de6b520f0b1187109f6957419a1ae09136e59a8727761279d1bd
6
+ metadata.gz: c6f550e480b3628e14b0397a97fdf699856fd5be0b59d6ef9b1f7e0441055eac65af5ae39199f55e135feeb06b5c90dbeaa0fbd5a5ed0234df6acef8580dbe1b
7
+ data.tar.gz: f973afc84095e8007d0e08b961691f1a78491c6ff966652c25473ded4e00be9faa0d2e2aa3fb6c2454e85b78b51d3b99a2859892524a3661f8d2306eaae80ddd
@@ -71,13 +71,25 @@ module RSpec
71
71
 
72
72
  run = @current_run = Run.new
73
73
  RSpec::Core::Example.prepend(ExampleExtension)
74
- RSpec.configure do |config|
75
- config.before(:example) do
76
- skip('Quarantine lookup failed, skipping test run') if run.abort_remaining?
77
- end
78
- config.around(:each) { |example| Trunk.run_counting_attempts(example) }
79
- config.reporter.register_listener AnalyticsListener.new(run), :example_finished, :close
74
+ RSpec::Core::ExampleGroup.singleton_class.prepend(ExampleGroupExtension)
75
+ RSpec.configure { |config| install(config, run) }
76
+ end
77
+
78
+ def install(config, run)
79
+ # prepend_before, to also run ahead of before hooks configured before this file was required.
80
+ config.prepend_before(:example) do |example|
81
+ run.start_attempt(example)
82
+ next unless run.abort_remaining?
83
+
84
+ # RSpec starts no new examples once it wants to quit, so this is an in-place
85
+ # re-run (e.g. rspec-retry), where a skip would hide the failure.
86
+ failure = run.abort_failure(example)
87
+ raise failure if failure
88
+
89
+ skip('Quarantine lookup failed, skipping test run')
80
90
  end
91
+ config.around(:each) { |example| Trunk.run_counting_attempts(example) }
92
+ config.reporter.register_listener AnalyticsListener.new(run), :example_finished, :close
81
93
  end
82
94
 
83
95
  def disabled?
@@ -163,6 +175,8 @@ module RSpec
163
175
  @report = report
164
176
  @quarantining_disabled = false
165
177
  @lookup_failed = false
178
+ @abort_failures = {}.compare_by_identity
179
+ @quarantined_failures = {}.compare_by_identity
166
180
  end
167
181
 
168
182
  def quarantining_disabled?
@@ -177,9 +191,20 @@ module RSpec
177
191
  lookup_failed? && Trunk.quarantine_query_failure_exit?
178
192
  end
179
193
 
194
+ def abort_failure(example)
195
+ @abort_failures[example]
196
+ end
197
+
198
+ def start_attempt(example)
199
+ @quarantined_failures.delete(example)
200
+ end
201
+
180
202
  # Whether a failure of `example` with `exception` is quarantined. If the
181
203
  # quarantine machinery itself blows up, the failure must stand.
182
204
  def quarantine?(example, exception)
205
+ # A replayed abort failure didn't happen on this attempt, so it can't be quarantined.
206
+ return false if abort_failure(example).equal?(exception)
207
+
183
208
  check_quarantine(example, exception)
184
209
  rescue StandardError => e
185
210
  puts Colors.yellow("Quarantine check errored (#{e.class}: #{e.message}), treating test as not quarantined")
@@ -202,10 +227,7 @@ module RSpec
202
227
  puts Colors.yellow('Failed to check quarantining status, no failures will be quarantined')
203
228
  @lookup_failed = true
204
229
  end
205
- if Trunk.quarantine_query_failure_exit?
206
- puts Colors.red('Quarantine lookup failed, exiting early')
207
- RSpec.world.wants_to_quit = true
208
- end
230
+ abort_run(example, exception) if Trunk.quarantine_query_failure_exit?
209
231
  false
210
232
  elsif result.quarantining_disabled_for_repo
211
233
  unless quarantining_disabled?
@@ -214,8 +236,7 @@ module RSpec
214
236
  end
215
237
  false
216
238
  elsif result.test_is_quarantined
217
- # monitor the override in the metadata
218
- Trunk.write_metadata(example.metadata, :trunk_quarantined_exception, exception)
239
+ record_quarantined(example, exception)
219
240
  puts Colors.green("Test is quarantined, overriding exception: #{exception}")
220
241
  true
221
242
  else
@@ -223,6 +244,19 @@ module RSpec
223
244
  false
224
245
  end
225
246
  end
247
+
248
+ def abort_run(example, exception)
249
+ puts Colors.red('Quarantine lookup failed, exiting early')
250
+ # The first: a replay's after hooks raise their own errors again anyway.
251
+ @abort_failures[example] ||= exception
252
+ RSpec.world.wants_to_quit = true
253
+ end
254
+
255
+ def record_quarantined(example, exception)
256
+ failures = (@quarantined_failures[example] ||= []) << exception
257
+ recorded = failures.one? ? exception : RSpec::Core::MultipleExceptionError.new(*failures)
258
+ Trunk.write_metadata(example.metadata, :trunk_quarantined_exception, recorded)
259
+ end
226
260
  end
227
261
 
228
262
  # Prepended to RSpec::Core::Example. RSpec uses the existence of an exception
@@ -268,6 +302,22 @@ module RSpec
268
302
  end
269
303
  end
270
304
 
305
+ # RSpec fails the run when a before(:context) hook raises, even if every example's failure was
306
+ # quarantined. A green status alone isn't enough: a pending example hides the error in its
307
+ # pending_exception and still ends up :passed.
308
+ module ExampleGroupExtension
309
+ def run(reporter = RSpec::Core::NullReporter)
310
+ passed = super
311
+ return passed unless passed == false && Trunk.current_run
312
+
313
+ examples = descendant_filtered_examples
314
+ examples.any? && examples.all? do |example|
315
+ example.metadata[:trunk_quarantined_exception] &&
316
+ %i[passed pending].include?(example.execution_result.status)
317
+ end
318
+ end
319
+ end
320
+
271
321
  # Formats failures for the report as plain text suitable for storage and the web UI.
272
322
  module FailureFormatter
273
323
  # A no-op colorizer passed to RSpec's ExceptionPresenter.
@@ -362,12 +412,15 @@ module RSpec
362
412
  @run = run
363
413
  end
364
414
 
415
+ # --dry-run reports every example as passed without running it.
365
416
  def example_finished(notification)
366
- add_test_case(notification.example)
417
+ add_test_case(notification.example) unless RSpec.configuration.dry_run?
367
418
  end
368
419
 
369
420
  # trunk-ignore(rubocop/Metrics/MethodLength,rubocop/Metrics/AbcSize)
370
421
  def close(_notification)
422
+ return if RSpec.configuration.dry_run?
423
+
371
424
  if @run.quarantining_disabled?
372
425
  puts Colors.yellow('Note: Quarantining is disabled for this repo. Test failures were not quarantined.')
373
426
  end
@@ -407,8 +460,8 @@ module RSpec
407
460
  name = example.full_description
408
461
  file, classname = Trunk.file_and_classname(example)
409
462
  line = example.metadata[:line_number]
410
- started_at = example.execution_result.started_at.to_i
411
- finished_at = example.execution_result.finished_at.to_i
463
+ started_at = example.execution_result.started_at.to_f
464
+ finished_at = example.execution_result.finished_at.to_f
412
465
 
413
466
  attempt_number = example.metadata[:retry_attempts] || example.metadata[:trunk_attempt_number] || 0
414
467
  # set the status to failure, but mark it as quarantined
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_trunk_flaky_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0.pre.beta.1
4
+ version: 0.16.1.pre.beta.1
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - Trunk Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-28 00:00:00.000000000 Z
11
+ date: 2026-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core