rspec_trunk_flaky_tests 0.12.1.pre.beta.0-arm64-darwin → 0.12.2-arm64-darwin

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: 39df0a9d51a78989f9511bd61b15e794b5df040876d4925a3d786020a943fed1
4
- data.tar.gz: 7c44e662347dc6076a79807c00ca1ec50875b617f5ec59a8985c99128e39d768
3
+ metadata.gz: 2c62705bcb40876e1a2701d3352835931d464577d23de9599589ee8e462c8d9a
4
+ data.tar.gz: 7490e115ee002688af7bf51a2a68b6942b2dae441362236a9327d76ec8d95844
5
5
  SHA512:
6
- metadata.gz: 31004f16af3e247022a16c5d702caaad610e6b121e28753364033f8ad3ea2d7380201d83a89b63799eafef5de1b51ee6f1e719a60e9f303dc8fc4371cd933fef
7
- data.tar.gz: cd652fb89ddb3dd7f370e479ba7cc4c82c5c5aa691e360d531def03529fad583ea15c0a9623566b12669decf97bc7f1fbd6986967bb869b86f97574ec63776e6
6
+ metadata.gz: dc6c6d2f2514e4a91e308ac11f781e768214595d55148187b7c51277080f15cbeeb1368e44073061d256f1c4c734d222612247d48808f1e4dc10fef3515b7653
7
+ data.tar.gz: bc66d9be93e8d213d6b93d56176877d3ef13d9cba6cba337e3cae248b68feb00e0e1e5afe039a3f5e5b761e5feb7642e79eee5dc7bc410d10b4de3d56713d888
@@ -25,6 +25,7 @@
25
25
  # TRUNK_DRY_RUN - Set to 'true' to save bundle locally instead of uploading
26
26
  # TRUNK_USE_UNCLONED_REPO - Set to 'true' for uncloned repo mode
27
27
  # TRUNK_LOCAL_UPLOAD_DIR - Directory to save test results locally (disables upload)
28
+ # TRUNK_QUARANTINED_TESTS_DISK_CACHE_TTL_SECS - Time to cache quarantined tests on disk (in seconds)
28
29
  # DISABLE_RSPEC_TRUNK_FLAKY_TESTS - Set to 'true' to completely disable Trunk
29
30
  #
30
31
  require 'rspec/core'
@@ -55,12 +56,26 @@ def escape(str)
55
56
  str.dump[1..-2]
56
57
  end
57
58
 
59
+ # Knapsack example detector instantiates all test cases in order to determine how to shard them
60
+ # These instantiations should not generate test bundles, so we
61
+ # disable the gem when running under knapsack_pro:rspec_test_example_detector
62
+ def knapsack_detector_mode?
63
+ knapsack_detector_command?
64
+ end
65
+
66
+ def knapsack_detector_command?
67
+ command_line = "#{$PROGRAM_NAME} #{ARGV.join(' ')}".strip
68
+ command_line.include?('knapsack_pro:rspec_test_example_detector')
69
+ end
70
+
58
71
  def trunk_disabled
59
- ENV['DISABLE_RSPEC_TRUNK_FLAKY_TESTS'] == 'true' || ENV['TRUNK_ORG_URL_SLUG'].nil? || ENV['TRUNK_API_TOKEN'].nil?
72
+ knapsack_detector_mode? || ENV['DISABLE_RSPEC_TRUNK_FLAKY_TESTS'] == 'true' ||
73
+ ENV['TRUNK_ORG_URL_SLUG'].nil? || ENV['TRUNK_API_TOKEN'].nil?
60
74
  end
61
75
 
62
- # we want to cache the test report so we can add to it as we go and reduce the number of API calls
76
+ # we want to cache the test report in memory so we can add to it as we go and reduce the number of API calls
63
77
  $test_report = TestReport.new('rspec', "#{$PROGRAM_NAME} #{ARGV.join(' ')}", nil)
78
+ $failure_encountered_and_quarantining_disabled = false
64
79
 
65
80
  module RSpec
66
81
  module Core
@@ -72,20 +87,34 @@ module RSpec
72
87
  # RSpec uses the existance of an exception to determine if the test failed
73
88
  # We need to override this to allow us to capture the exception and then
74
89
  # decide if we want to fail the test or not
75
- # trunk-ignore(rubocop/Metrics/AbcSize,rubocop/Metrics/MethodLength,rubocop/Naming/AccessorMethodName)
90
+ # trunk-ignore(rubocop/Naming/AccessorMethodName)
76
91
  def set_exception(exception)
77
92
  return set_exception_core(exception) if metadata[:pending]
78
93
  return set_exception_core(exception) if trunk_disabled
79
94
  return set_exception_core(exception) if metadata[:retry_attempts]&.positive?
80
95
 
96
+ handle_quarantine_check(exception)
97
+ end
98
+
99
+ # trunk-ignore(rubocop/Metrics/AbcSize,rubocop/Metrics/MethodLength)
100
+ def handle_quarantine_check(exception)
81
101
  id = generate_trunk_id
82
102
  name = full_description
83
103
  parent_name = example_group.metadata[:description]
84
104
  parent_name = parent_name.empty? ? 'rspec' : parent_name
85
105
  file = escape(metadata[:file_path])
86
106
  classname = file.sub(%r{\.[^/.]+\Z}, '').gsub('/', '.').gsub(/\A\.+|\.+\Z/, '')
87
- puts "Test failed, checking if it can be quarantined: `#{location}`".yellow
88
- if $test_report.is_quarantined(id, name, parent_name, classname, file)
107
+ unless $failure_encountered_and_quarantining_disabled
108
+ puts "Test failed, checking if it can be quarantined: `#{location}`".yellow
109
+ end
110
+ is_quarantined_result = $test_report.is_quarantined(id, name, parent_name, classname, file)
111
+ if is_quarantined_result.quarantining_disabled_for_repo
112
+ unless $failure_encountered_and_quarantining_disabled
113
+ puts 'Quarantining is disabled for this repo, no failures will be quarantined'.yellow
114
+ $failure_encountered_and_quarantining_disabled = true
115
+ end
116
+ set_exception_core(exception)
117
+ elsif is_quarantined_result.test_is_quarantined
89
118
  # monitor the override in the metadata
90
119
  metadata[:quarantined_exception] = exception
91
120
  puts "Test is quarantined, overriding exception: #{exception}".green
@@ -168,6 +197,9 @@ class TrunkAnalyticsListener
168
197
 
169
198
  # trunk-ignore(rubocop/Metrics/MethodLength)
170
199
  def close(_notification)
200
+ if $failure_encountered_and_quarantining_disabled
201
+ puts 'Note: Quarantining is disabled for this repo. Test failures were not quarantined.'.yellow
202
+ end
171
203
  if ENV['TRUNK_LOCAL_UPLOAD_DIR']
172
204
  saved = @testreport.try_save(ENV['TRUNK_LOCAL_UPLOAD_DIR'])
173
205
  if saved
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.12.1.pre.beta.0
4
+ version: 0.12.2
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Trunk Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-18 00:00:00.000000000 Z
11
+ date: 2026-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -52,6 +52,7 @@ files:
52
52
  - lib/rspec_trunk_flaky_tests/3.2/rspec_trunk_flaky_tests.bundle
53
53
  - lib/rspec_trunk_flaky_tests/3.3/rspec_trunk_flaky_tests.bundle
54
54
  - lib/rspec_trunk_flaky_tests/3.4/rspec_trunk_flaky_tests.bundle
55
+ - lib/rspec_trunk_flaky_tests/4.0/rspec_trunk_flaky_tests.bundle
55
56
  - lib/trunk_spec_helper.rb
56
57
  homepage: https://docs.trunk.io/flaky-tests/get-started/frameworks/rspec
57
58
  licenses:
@@ -68,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
69
  version: '3.0'
69
70
  - - "<"
70
71
  - !ruby/object:Gem::Version
71
- version: 3.5.dev
72
+ version: 4.1.dev
72
73
  required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  requirements:
74
75
  - - ">="