rspec_trunk_flaky_tests 0.17.0.pre.beta.3-aarch64-linux-gnu → 1.0.0-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 +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 +78 -12
- 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: 65a02d3e88a7395f9d71e426249495f503a4f66fe9ebeb0689da6a7fb13b0337
|
|
4
|
+
data.tar.gz: a32d02b73d1bd1d2e7766b16a2777555e0b920af2b6288977d78c992284429ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c758a180c3bd48c8610c88783e9914c2f4520f78361705db06271fdc151404cebc59182bfb6e6396870c4c552220896b6951297cb3ef8352c828b94be96591b9
|
|
7
|
+
data.tar.gz: 7d3746d88776a41add1623291e70425ff02c22797b5291b4aecbcf17a8867996030e5311697ed8f466919ba3900eacb7af65f397c8378f9402d2adb25734d940
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/trunk_spec_helper.rb
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
#
|
|
8
8
|
# Required environment variables:
|
|
9
9
|
# TRUNK_ORG_URL_SLUG - Your organization's URL slug
|
|
10
|
-
# TRUNK_API_TOKEN -
|
|
10
|
+
# TRUNK_API_TOKEN - A Trunk v2 API key (trunk_v2_...) with the Upload test results permission,
|
|
11
|
+
# or a Trunk JWT that outlasts the run; the organization token is refused
|
|
12
|
+
# TRUNK_TEST_COLLECTION_ID - The ID of the test collection to upload to
|
|
11
13
|
#
|
|
12
14
|
# Optional environment variables for repository metadata:
|
|
13
15
|
# TRUNK_REPO_ROOT - Path to repository root
|
|
@@ -20,7 +22,6 @@
|
|
|
20
22
|
#
|
|
21
23
|
# Optional environment variables for configuration:
|
|
22
24
|
# TRUNK_CODEOWNERS_PATH - Path to CODEOWNERS file
|
|
23
|
-
# TRUNK_TEST_COLLECTION_ID - Optional 8 character alphanumeric ID for a test collection
|
|
24
25
|
# TRUNK_VARIANT - Variant name for test results (e.g., 'linux', 'pr-123')
|
|
25
26
|
# TRUNK_DISABLE_QUARANTINING - Set to 'true' to disable quarantining
|
|
26
27
|
# TRUNK_ALLOW_EMPTY_TEST_RESULTS - Set to 'true' to allow empty results
|
|
@@ -46,6 +47,18 @@ module RSpec
|
|
|
46
47
|
module Trunk
|
|
47
48
|
ANSI_ESCAPE_PATTERN = %r{(?:\e[@-Z\\-_]|\e\[[0-?]*[ -/]*[@-~])}
|
|
48
49
|
|
|
50
|
+
CORE_METHODS = {
|
|
51
|
+
name: [Module.instance_method(:name), String],
|
|
52
|
+
class: [Kernel.instance_method(:class), Module]
|
|
53
|
+
}.freeze
|
|
54
|
+
CLASS_SUPERCLASS = Class.instance_method(:superclass)
|
|
55
|
+
KERNEL_IS_A = Kernel.instance_method(:is_a?)
|
|
56
|
+
MODULE_TO_S = Module.instance_method(:to_s)
|
|
57
|
+
MEMORY_ADDRESS = /:0x\h+>/
|
|
58
|
+
|
|
59
|
+
# Raised when Trunk is configured to upload but can't: see .check_configuration!.
|
|
60
|
+
class ConfigurationError < StandardError; end
|
|
61
|
+
|
|
49
62
|
# Knapsack example detector instantiates all test cases in order to determine how to shard them
|
|
50
63
|
# These instantiations should not generate test bundles, so we
|
|
51
64
|
# disable the gem when running under knapsack_pro:rspec_test_example_detector
|
|
@@ -72,6 +85,7 @@ module RSpec
|
|
|
72
85
|
def setup
|
|
73
86
|
return if current_run || disabled?
|
|
74
87
|
|
|
88
|
+
check_configuration!
|
|
75
89
|
run = @current_run = Run.new
|
|
76
90
|
RSpec::Core::Example.prepend(ExampleExtension)
|
|
77
91
|
RSpec::Core::ExampleGroup.singleton_class.prepend(ExampleGroupExtension)
|
|
@@ -95,9 +109,28 @@ module RSpec
|
|
|
95
109
|
config.reporter.register_listener AnalyticsListener.new(run), :example_finished, :close
|
|
96
110
|
end
|
|
97
111
|
|
|
112
|
+
# An empty token counts as none: it is what a fork pull request's missing secret turns into.
|
|
98
113
|
def disabled?
|
|
99
114
|
knapsack_detector_mode? || ENV['DISABLE_RSPEC_TRUNK_FLAKY_TESTS'] == 'true' ||
|
|
100
|
-
ENV['TRUNK_ORG_URL_SLUG'].nil? || ENV
|
|
115
|
+
ENV['TRUNK_ORG_URL_SLUG'].nil? || ENV.fetch('TRUNK_API_TOKEN', '').strip.empty?
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# A run with a token and a slug means to upload, so one that can't is an error rather than a
|
|
119
|
+
# warning: a warning leaves the build green while uploads and quarantining stop, which is how
|
|
120
|
+
# a dependency bot's upgrade to 1.0.0 would merge unnoticed. Raised while spec_helper loads,
|
|
121
|
+
# so RSpec runs no examples and exits non-zero, as the CLI's `test` command does.
|
|
122
|
+
def check_configuration!
|
|
123
|
+
if ENV.fetch('TRUNK_TEST_COLLECTION_ID', '').strip.empty?
|
|
124
|
+
configuration_error!('this run names no test collection. Set TRUNK_TEST_COLLECTION_ID to upload its ' \
|
|
125
|
+
"test results; the ID is on the collection's page in Trunk.")
|
|
126
|
+
end
|
|
127
|
+
refusal = RSpec::Trunk.token_refusal(ENV.fetch('TRUNK_API_TOKEN'))
|
|
128
|
+
configuration_error!(refusal) if refusal
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def configuration_error!(reason)
|
|
132
|
+
raise ConfigurationError, "Trunk Flaky Tests: #{reason} To run without Trunk, set " \
|
|
133
|
+
'DISABLE_RSPEC_TRUNK_FLAKY_TESTS=true.'
|
|
101
134
|
end
|
|
102
135
|
|
|
103
136
|
def knapsack_detector_mode?
|
|
@@ -186,21 +219,51 @@ module RSpec
|
|
|
186
219
|
end
|
|
187
220
|
|
|
188
221
|
def description_arg(arg)
|
|
189
|
-
if
|
|
190
|
-
arg
|
|
222
|
+
if core_is_a?(arg, Module)
|
|
223
|
+
module_description(arg, arg.to_s)
|
|
191
224
|
elsif default_to_s?(arg)
|
|
192
|
-
|
|
225
|
+
klass = core_call(arg, :class)
|
|
226
|
+
"#<#{module_description(klass, MODULE_TO_S.bind_call(klass))}>"
|
|
193
227
|
else
|
|
194
228
|
arg.to_s
|
|
195
229
|
end
|
|
196
230
|
end
|
|
197
231
|
|
|
198
232
|
def anonymous_module_name(mod)
|
|
199
|
-
return '#<Module>' unless
|
|
233
|
+
return '#<Module>' unless core_is_a?(mod, Class)
|
|
234
|
+
|
|
235
|
+
superclass = CLASS_SUPERCLASS.bind_call(mod)
|
|
236
|
+
superclass = CLASS_SUPERCLASS.bind_call(superclass) while superclass && module_name(superclass).nil?
|
|
237
|
+
superclass ? "#<Class < #{module_name(superclass)}>" : '#<Class>'
|
|
238
|
+
end
|
|
200
239
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
240
|
+
# `described` is the module's #to_s, which is RSpec's (and so 0.16.1's) name for it,
|
|
241
|
+
# kept unless it has an address in it.
|
|
242
|
+
def module_description(mod, described)
|
|
243
|
+
return described unless MEMORY_ADDRESS.match?(described)
|
|
244
|
+
|
|
245
|
+
name = module_name(mod)
|
|
246
|
+
name.nil? || name.empty? ? anonymous_module_name(mod) : name
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def module_name(mod)
|
|
250
|
+
core_call(mod, :name)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# The arg's own method when it works as core's does, else core's: a class may define
|
|
254
|
+
# .name for something else (private, or taking arguments).
|
|
255
|
+
def core_call(obj, method_name)
|
|
256
|
+
core, type = CORE_METHODS.fetch(method_name)
|
|
257
|
+
value = obj.public_send(method_name)
|
|
258
|
+
value.is_a?(type) ? value : core.bind_call(obj)
|
|
259
|
+
rescue StandardError, NotImplementedError
|
|
260
|
+
core.bind_call(obj)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def core_is_a?(obj, type)
|
|
264
|
+
KERNEL_IS_A.bind_call(obj, type)
|
|
265
|
+
rescue TypeError # a BasicObject
|
|
266
|
+
false
|
|
204
267
|
end
|
|
205
268
|
|
|
206
269
|
# Kernel's method, so an object whose own #method means something else
|
|
@@ -295,13 +358,15 @@ module RSpec
|
|
|
295
358
|
if result.quarantine_lookup_failed
|
|
296
359
|
unless lookup_failed?
|
|
297
360
|
puts Colors.yellow('Failed to check quarantining status, no failures will be quarantined')
|
|
361
|
+
reason = report.quarantine_lookup_error
|
|
362
|
+
puts Colors.yellow(" Reason: #{reason}") if reason
|
|
298
363
|
@lookup_failed = true
|
|
299
364
|
end
|
|
300
365
|
abort_run(example, exception) if Trunk.quarantine_query_failure_exit?
|
|
301
366
|
false
|
|
302
367
|
elsif result.quarantining_disabled_for_repo
|
|
303
368
|
unless quarantining_disabled?
|
|
304
|
-
puts Colors.yellow('Quarantining is disabled for this
|
|
369
|
+
puts Colors.yellow('Quarantining is disabled for this test collection, no failures will be quarantined')
|
|
305
370
|
@quarantining_disabled = true
|
|
306
371
|
end
|
|
307
372
|
false
|
|
@@ -495,7 +560,8 @@ module RSpec
|
|
|
495
560
|
puts Colors.yellow('Note: TRUNK_DISABLE_QUARANTINING is set. Test failures were not quarantined.')
|
|
496
561
|
end
|
|
497
562
|
if @run.quarantining_disabled?
|
|
498
|
-
puts Colors.yellow('Note: Quarantining is disabled for this
|
|
563
|
+
puts Colors.yellow('Note: Quarantining is disabled for this test collection. ' \
|
|
564
|
+
'Test failures were not quarantined.')
|
|
499
565
|
end
|
|
500
566
|
if @run.lookup_failed?
|
|
501
567
|
puts Colors.yellow('Note: Failed to check quarantining status. Test failures were not 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.
|
|
4
|
+
version: 1.0.0
|
|
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-11-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec-core
|