minitest-retry 0.2.5 → 0.3.0

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: 7d8360dd61c3f71e79586334e48d4eea9faaaf7a9c796b20c299615f9b6a38e9
4
- data.tar.gz: 553974451059c548716c961245ee9698a18d9720db28a37d60ddf8def070e0dd
3
+ metadata.gz: e8d4d665c0afb4fe2ae9548c66ef1a7beb4158615b0d0f8e9ae193124b6c3c50
4
+ data.tar.gz: b475f7d149b3d6365ae8718884ea830cdf561a0c09e1e4b01eee5e82bb23c71d
5
5
  SHA512:
6
- metadata.gz: e414e49f1c49c41c615ffea9c5950a2900c5036d2dfcd505a634d333544ef8f37c33318e6b12963abc2e0c5d0fc77635d59483f00a28b2ca6d14fd7a1bc786be
7
- data.tar.gz: 0e39b05be22d6d7c2768a02dbce7c705b9dfc7cacdcdd5545bb023aa5bf76ed74a757954ab3634e84bbd2332852af9f9ff4eac0d9923ea05ad4543fe1be01f84
6
+ metadata.gz: 282ba68c650f2062afcd0acf9ac0fffab2c2fc5eed52744e24f87495edc8ea8624825e3bbb8e6d3869512481ed1932874af1ddb1cb5c0b7c0458393965014ebf
7
+ data.tar.gz: 87a04ad51d02b17181ca6c40b38c25c604de260222358a6ffcfba9d2757e4d3843939d140179e8825c28a4c1f4809cbceec381e8f5d4d8449d5fe48ef3cf9a0a
@@ -0,0 +1,33 @@
1
+ name: Push Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ push:
13
+ if: github.repository == 'y-yagi/minitest-retry'
14
+ runs-on: ubuntu-latest
15
+
16
+ permissions:
17
+ contents: write
18
+ id-token: write
19
+
20
+ steps:
21
+ - name: Harden Runner
22
+ uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
23
+ with:
24
+ egress-policy: audit
25
+
26
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27
+ - name: Set up Ruby
28
+ uses: ruby/setup-ruby@2e007403fc1ec238429ecaa57af6f22f019cc135 # v1.234.0
29
+ with:
30
+ bundler-cache: true
31
+ ruby-version: ruby
32
+
33
+ - uses: rubygems/release-gem@9e85cb11501bebc2ae661c1500176316d3987059 # v1.1.0
@@ -18,7 +18,7 @@ jobs:
18
18
  pull-requests: write
19
19
 
20
20
  steps:
21
- - uses: actions/stale@v9
21
+ - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
22
22
  with:
23
23
  repo-token: ${{ secrets.GITHUB_TOKEN }}
24
24
  stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
@@ -3,18 +3,36 @@ name: CI
3
3
  on: [push]
4
4
 
5
5
  jobs:
6
- build:
6
+ minitest-5:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
10
  ruby: [ '3.4', '3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4', '2.3' ]
11
+ env:
12
+ BUNDLE_GEMFILE: gemfiles/minitest_5.gemfile
11
13
  steps:
12
- - uses: actions/checkout@v4
13
- - uses: ruby/setup-ruby@v1
14
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
15
+ - uses: ruby/setup-ruby@a25f1e45f0e65a92fcb1e95e8847f78fb0a7197a # v1.273.0
14
16
  with:
15
17
  ruby-version: ${{ matrix.ruby }}
16
18
  - name: Install dependencies
17
- run: |
18
- bundle install
19
+ run: bundle install
20
+ - name: Run test
21
+ run: bundle exec rake
22
+
23
+ minitest-6:
24
+ runs-on: ubuntu-latest
25
+ strategy:
26
+ matrix:
27
+ ruby: [ '3.4', '3.3', '3.2' ]
28
+ env:
29
+ BUNDLE_GEMFILE: gemfiles/minitest_6.gemfile
30
+ steps:
31
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
32
+ - uses: ruby/setup-ruby@a25f1e45f0e65a92fcb1e95e8847f78fb0a7197a # v1.273.0
33
+ with:
34
+ ruby-version: ${{ matrix.ruby }}
35
+ - name: Install dependencies
36
+ run: bundle install
19
37
  - name: Run test
20
38
  run: bundle exec rake
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /gemfiles/*.lock
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.0
2
+
3
+ * Support minitest 6 [y-yagi]
4
+
1
5
  ## 0.2.5
2
6
 
3
7
  * Add `exceptions_to_skip` option #48 [y-yagi]
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ eval_gemfile File.expand_path("../Gemfile", __dir__)
4
+
5
+ gem "minitest", "< 6"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ eval_gemfile File.expand_path("../Gemfile", __dir__)
4
+
5
+ gem "minitest", ">= 6", "< 7"
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Retry
3
- VERSION = "0.2.5"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -93,39 +93,64 @@ module Minitest
93
93
  ancestors = klass.ancestors.map(&:to_s)
94
94
  return classes_to_retry.any? { |class_to_retry| ancestors.include?(class_to_retry) }
95
95
  end
96
- end
97
-
98
- module ClassMethods
99
- def run_one_method(klass, method_name)
100
- result = super(klass, method_name)
101
96
 
97
+ def run_with_retry(klass, method_name)
102
98
  klass_method_name = "#{klass.name}##{method_name}"
103
- return result unless Minitest::Retry.failure_to_retry?(result.failures, klass_method_name, klass)
104
- if !result.skipped?
105
- Minitest::Retry.failure_callback.call(klass, method_name, result) if Minitest::Retry.failure_callback
106
- Minitest::Retry.retry_count.times do |count|
107
- Minitest::Retry.retry_callback.call(klass, method_name, count + 1, result) if Minitest::Retry.retry_callback
108
- if Minitest::Retry.verbose && Minitest::Retry.io
109
- msg = "[MinitestRetry] retry '%s' count: %s, msg: %s\n" %
110
- [method_name, count + 1, result.failures.map(&:message).join(",")]
111
- Minitest::Retry.io.puts(msg)
112
- end
113
-
114
- result = super(klass, method_name)
115
- break if result.failures.empty?
116
- end
99
+ result = yield
100
+
101
+ return result unless failure_to_retry?(result.failures, klass_method_name, klass)
102
+ return result if result.skipped?
117
103
 
118
- if Minitest::Retry.consistent_failure_callback && !result.failures.empty?
119
- Minitest::Retry.consistent_failure_callback.call(klass, method_name, result)
104
+ failure_callback&.call(klass, method_name, result)
105
+
106
+ retry_count.times do |count|
107
+ retry_callback&.call(klass, method_name, count + 1, result)
108
+
109
+ if verbose && io
110
+ msg = "[MinitestRetry] retry '%s' count: %s, msg: %s\n" %
111
+ [method_name, count + 1, result.failures.map(&:message).join(",")]
112
+ io.puts(msg)
120
113
  end
114
+
115
+ result = yield
116
+ break if result.failures.empty?
121
117
  end
118
+
119
+ if consistent_failure_callback && !result.failures.empty?
120
+ consistent_failure_callback.call(klass, method_name, result)
121
+ end
122
+
122
123
  result
123
124
  end
124
125
  end
125
126
 
127
+ module ClassMethods
128
+ def run_one_method(klass, method_name)
129
+ Minitest::Retry.run_with_retry(klass, method_name) do
130
+ super(klass, method_name)
131
+ end
132
+ end
133
+ end
134
+
135
+ module RunnableMethods
136
+ def run(klass, method_name, reporter)
137
+ reporter.prerecord klass, method_name
138
+ result = Minitest::Retry.run_with_retry(klass, method_name) do
139
+ klass.new(method_name).run
140
+ end
141
+ reporter.record result
142
+ end
143
+ end
144
+
126
145
  def self.prepended(base)
127
- class << base
128
- prepend ClassMethods
146
+ if Minitest::VERSION > "6"
147
+ class << Minitest::Runnable
148
+ prepend RunnableMethods
149
+ end
150
+ else
151
+ class << base
152
+ prepend ClassMethods
153
+ end
129
154
  end
130
155
  end
131
156
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-retry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Yaginuma
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: minitest
@@ -58,6 +58,7 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
+ - ".github/workflows/push_gem.yml"
61
62
  - ".github/workflows/stale.yml"
62
63
  - ".github/workflows/ubuntu.yml"
63
64
  - ".gitignore"
@@ -68,6 +69,8 @@ files:
68
69
  - Rakefile
69
70
  - bin/console
70
71
  - bin/setup
72
+ - gemfiles/minitest_5.gemfile
73
+ - gemfiles/minitest_6.gemfile
71
74
  - lib/minitest/retry.rb
72
75
  - lib/minitest/retry/version.rb
73
76
  - minitest-retry.gemspec
@@ -91,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
94
  - !ruby/object:Gem::Version
92
95
  version: '0'
93
96
  requirements: []
94
- rubygems_version: 3.6.2
97
+ rubygems_version: 3.6.7
95
98
  specification_version: 4
96
99
  summary: re-run the test when the test fails
97
100
  test_files: []