rspec_trunk_flaky_tests 0.17.0.pre.beta.3-aarch64-linux-gnu → 1.0.0.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: 4fa77963313e0927476f449c412cf8490b09ca84af4de3aff5a8cf27ae53dc79
4
- data.tar.gz: 5989b9595303c2d421b08e3790d6f43f36391f3805c3883368c73e43dffca9ae
3
+ metadata.gz: 5801c989ff5e252d02c49d529861bc73aad8f59811db37b7fba9d84df4f74a31
4
+ data.tar.gz: 8711b633faf06c7bd36fbdece6eeb2bb12226ca22c82cd447b7d0a7d6e701920
5
5
  SHA512:
6
- metadata.gz: 7c72bb72b541d6768165fa0a648827b1f63a19c504021606f2e12de619ad687d77754a05aa05fc467ce1e23ccb0662db432dbf2e7999f2e4a756c8eb45b94467
7
- data.tar.gz: 632018e4f4484873b3e27b9cd967be0a66433a74b1690b15b9c3eab5c4a634160915a99b0b76dfc995a4bb41e0a4ad8c767df71ff88d035602d5c0496d42c6b8
6
+ metadata.gz: f354202a359c0f108ff70dd5f7be41b156eb79b3917ebaf84c1b9da3af62bbb2fe6626d9ee76b92bc42e879f7b89ea3cff825cb62af38e27f83fc01ebef88fb7
7
+ data.tar.gz: 6fbfd570803faa82461caae198e13f384c7ad508a613635f799b0079b60ce708c81756af8dab7ee7346acaf635ec850e9b8263e6291818bb360752ef548677b0
@@ -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 - Your API token for authentication
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['TRUNK_API_TOKEN'].nil?
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 arg.is_a?(Module)
190
- arg.name || anonymous_module_name(arg)
222
+ if core_is_a?(arg, Module)
223
+ module_description(arg, arg.to_s)
191
224
  elsif default_to_s?(arg)
192
- "#<#{arg.class.name || anonymous_module_name(arg.class)}>"
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 mod.is_a?(Class)
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
- superclass = mod.superclass
202
- superclass = superclass.superclass while superclass && superclass.name.nil?
203
- superclass ? "#<Class < #{superclass.name}>" : '#<Class>'
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 repo, no failures will be quarantined')
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 repo. Test failures were not quarantined.')
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.17.0.pre.beta.3
4
+ version: 1.0.0.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-11-09 00:00:00.000000000 Z
11
+ date: 2026-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core