rspec_trunk_flaky_tests 0.16.0-x86_64-linux-gnu → 0.16.1.pre.beta.1-x86_64-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 +4 -4
- data/lib/rspec_trunk_flaky_tests/3.1/rspec_trunk_flaky_tests.so +0 -0
- data/lib/rspec_trunk_flaky_tests/3.2/rspec_trunk_flaky_tests.so +0 -0
- data/lib/rspec_trunk_flaky_tests/3.3/rspec_trunk_flaky_tests.so +0 -0
- data/lib/rspec_trunk_flaky_tests/3.4/rspec_trunk_flaky_tests.so +0 -0
- data/lib/rspec_trunk_flaky_tests/4.0/rspec_trunk_flaky_tests.so +0 -0
- data/lib/trunk_spec_helper.rb +68 -15
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: edc3377f870ba1220f46175a4ff60805876690e64d6d4cf6a7f0edf28ae0e3cd
|
|
4
|
+
data.tar.gz: 480eb3025ac401c2a91450f1b3a0443446a87903426291f77bb4c33a28f1caad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7949788d501fa9df38cf087f23d169a745eeef19e278a63280d4c56eec0fd2ed137bf66b8ef0f61b3541eb87037f9a9cd5529a7f57017b159570d82105bb40fa
|
|
7
|
+
data.tar.gz: 1d6fd2a9d9a4c58bdd66496be18a4c1801d1f05f6ce065977966b03779d29de33903677282cb7b3cc0167abd6005dfcc52c0011283dd72fc21dc9e49d8a04e48
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/trunk_spec_helper.rb
CHANGED
|
@@ -71,13 +71,25 @@ module RSpec
|
|
|
71
71
|
|
|
72
72
|
run = @current_run = Run.new
|
|
73
73
|
RSpec::Core::Example.prepend(ExampleExtension)
|
|
74
|
-
RSpec.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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.
|
|
411
|
-
finished_at = example.execution_result.finished_at.
|
|
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.
|
|
4
|
+
version: 0.16.1.pre.beta.1
|
|
5
5
|
platform: x86_64-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- Trunk Technologies, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec-core
|