minitest-retry 0.2.5 → 0.3.1
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/.github/workflows/push_gem.yml +33 -0
- data/.github/workflows/stale.yml +1 -1
- data/.github/workflows/ubuntu.yml +24 -6
- data/.gitignore +1 -0
- data/CHANGELOG.md +8 -0
- data/gemfiles/minitest_5.gemfile +5 -0
- data/gemfiles/minitest_6.gemfile +5 -0
- data/lib/minitest/retry/version.rb +1 -1
- data/lib/minitest/retry.rb +46 -22
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ef15ab34a100700a8fd0c7245ff9ebce03f33336dc967b717d615beaf1d885da
|
|
4
|
+
data.tar.gz: 6fec7805359af593b968e70afe3c755c9fed61b4e92290dcdcfa12feb0e11da5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d17edb63d1bc7171b701b502fa44c88b00c2f4a7c1a7bd03c312a0ba1ca679d1db558e91209fcde13f19f2d9f9323cac1346f470731855e2980ae65c51cbe55d
|
|
7
|
+
data.tar.gz: cdbe3f5e4e7061a5c68972f45a537764e46b410b815925e3a606b40939927044a69cc45499d1e8f5d73d333d8284600678b382e2a0dd652fc6b4c716dfaf739b
|
|
@@ -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
|
data/.github/workflows/stale.yml
CHANGED
|
@@ -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
|
-
|
|
6
|
+
minitest-5:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
strategy:
|
|
9
9
|
matrix:
|
|
10
|
-
ruby: [ '3.4', '3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4', '2.3' ]
|
|
10
|
+
ruby: [ '4.0', '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
|
-
|
|
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: [ '4.0', '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
data/CHANGELOG.md
CHANGED
data/lib/minitest/retry.rb
CHANGED
|
@@ -7,6 +7,7 @@ module Minitest
|
|
|
7
7
|
@retry_count, @io, @verbose, @exceptions_to_retry, @methods_to_retry, @classes_to_retry, @methods_to_skip, @exceptions_to_skip = retry_count, io, verbose, exceptions_to_retry, methods_to_retry, classes_to_retry, methods_to_skip, exceptions_to_skip
|
|
8
8
|
@failure_callback, @consistent_failure_callback, @retry_callback = nil, nil, nil
|
|
9
9
|
Minitest.prepend(self)
|
|
10
|
+
Minitest::Test.prepend(TestWithRetry) if Minitest::VERSION > "6"
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def on_failure(&block)
|
|
@@ -93,39 +94,62 @@ module Minitest
|
|
|
93
94
|
ancestors = klass.ancestors.map(&:to_s)
|
|
94
95
|
return classes_to_retry.any? { |class_to_retry| ancestors.include?(class_to_retry) }
|
|
95
96
|
end
|
|
97
|
+
|
|
98
|
+
def run_with_retry(klass_or_instance, method_name)
|
|
99
|
+
klass = klass_or_instance.instance_of?(Class) ? klass_or_instance : klass_or_instance.class
|
|
100
|
+
klass_method_name = "#{klass.name}##{method_name}"
|
|
101
|
+
result = yield
|
|
102
|
+
|
|
103
|
+
return result unless failure_to_retry?(result.failures, klass_method_name, klass)
|
|
104
|
+
return result if result.skipped?
|
|
105
|
+
|
|
106
|
+
failure_callback&.call(klass, method_name, result)
|
|
107
|
+
|
|
108
|
+
retry_count.times do |count|
|
|
109
|
+
retry_callback&.call(klass, method_name, count + 1, result)
|
|
110
|
+
|
|
111
|
+
if verbose && io
|
|
112
|
+
msg = "[MinitestRetry] retry '%s' count: %s, msg: %s\n" %
|
|
113
|
+
[method_name, count + 1, result.failures.map(&:message).join(",")]
|
|
114
|
+
io.puts(msg)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# NOTE: Only keep the last result when executed multiple times.
|
|
118
|
+
klass_or_instance.failures.clear if klass_or_instance.respond_to?(:failures)
|
|
119
|
+
result = yield
|
|
120
|
+
break if result.failures.empty?
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
if consistent_failure_callback && !result.failures.empty?
|
|
124
|
+
consistent_failure_callback.call(klass, method_name, result)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
result
|
|
128
|
+
end
|
|
96
129
|
end
|
|
97
130
|
|
|
98
131
|
module ClassMethods
|
|
99
132
|
def run_one_method(klass, method_name)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
133
|
+
Minitest::Retry.run_with_retry(klass, method_name) do
|
|
134
|
+
super(klass, method_name)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
117
138
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
139
|
+
module TestWithRetry
|
|
140
|
+
def run
|
|
141
|
+
result = Minitest::Retry.run_with_retry(self, self.name) do
|
|
142
|
+
super
|
|
121
143
|
end
|
|
122
144
|
result
|
|
123
145
|
end
|
|
124
146
|
end
|
|
125
147
|
|
|
126
148
|
def self.prepended(base)
|
|
127
|
-
|
|
128
|
-
|
|
149
|
+
unless Minitest::VERSION > "6"
|
|
150
|
+
class << base
|
|
151
|
+
prepend ClassMethods
|
|
152
|
+
end
|
|
129
153
|
end
|
|
130
154
|
end
|
|
131
155
|
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.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yuji Yaginuma
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
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.
|
|
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: []
|