minitest-retry 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -1
- data/lib/minitest/retry.rb +15 -4
- data/lib/minitest/retry/version.rb +1 -1
- 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: 986ef3b3ffb779d7f4351d864c93d932226cbef9653fa7f5bc208502f46586b2
|
4
|
+
data.tar.gz: 5e0a10b926b1aa02e08289c017379b68a4b6741dd5572e66ed5fb7aaba5a9d66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 800c226cf0c6f93553db2e2e242a46fbddcd6f048c2c266db7c4ceec0ab50186601e46e858ac512d3075aead1c23e79067ee887f1552fe3bb12275d097f1cb43
|
7
|
+
data.tar.gz: eb564f112cad335895e657924e437240db612dd1d2afde35f2da2d30aeed5ed25805641287ba69a93ec996a31563630ba6acdb7f4ff837029c1ac361dfe8cf0a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,8 @@ Minitest::Retry.use!(
|
|
37
37
|
retry_count: 3, # The number of times to retry. The default is 3.
|
38
38
|
verbose: true, # Whether or not to display the message at the time of retry. The default is true.
|
39
39
|
io: $stdout, # Display destination of retry when the message. The default is stdout.
|
40
|
-
exceptions_to_retry: []
|
40
|
+
exceptions_to_retry: [], # List of exceptions that will trigger a retry (when empty, all exceptions will).
|
41
|
+
methods_to_retry: [] # List of methods that will trigger a retry (when empty, all methods will).
|
41
42
|
)
|
42
43
|
```
|
43
44
|
|
data/lib/minitest/retry.rb
CHANGED
@@ -3,8 +3,8 @@ require "minitest/retry/version"
|
|
3
3
|
module Minitest
|
4
4
|
module Retry
|
5
5
|
class << self
|
6
|
-
def use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [])
|
7
|
-
@retry_count, @io, @verbose, @exceptions_to_retry = retry_count, io, verbose, exceptions_to_retry
|
6
|
+
def use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [], methods_to_retry: [])
|
7
|
+
@retry_count, @io, @verbose, @exceptions_to_retry, @methods_to_retry = retry_count, io, verbose, exceptions_to_retry, methods_to_retry
|
8
8
|
@failure_callback, @consistent_failure_callback, @retry_callback = nil, nil, nil
|
9
9
|
Minitest.prepend(self)
|
10
10
|
end
|
@@ -40,6 +40,10 @@ module Minitest
|
|
40
40
|
@exceptions_to_retry
|
41
41
|
end
|
42
42
|
|
43
|
+
def methods_to_retry
|
44
|
+
@methods_to_retry
|
45
|
+
end
|
46
|
+
|
43
47
|
def failure_callback
|
44
48
|
@failure_callback
|
45
49
|
end
|
@@ -52,8 +56,13 @@ module Minitest
|
|
52
56
|
@retry_callback
|
53
57
|
end
|
54
58
|
|
55
|
-
def failure_to_retry?(failures = [])
|
59
|
+
def failure_to_retry?(failures = [], klass_method_name)
|
56
60
|
return false if failures.empty?
|
61
|
+
|
62
|
+
if methods_to_retry.any?
|
63
|
+
return methods_to_retry.include?(klass_method_name)
|
64
|
+
end
|
65
|
+
|
57
66
|
return true if Minitest::Retry.exceptions_to_retry.empty?
|
58
67
|
errors = failures.map(&:error).map(&:class)
|
59
68
|
(errors & Minitest::Retry.exceptions_to_retry).any?
|
@@ -63,7 +72,9 @@ module Minitest
|
|
63
72
|
module ClassMethods
|
64
73
|
def run_one_method(klass, method_name)
|
65
74
|
result = super(klass, method_name)
|
66
|
-
|
75
|
+
|
76
|
+
klass_method_name = "#{klass.name}##{method_name}"
|
77
|
+
return result unless Minitest::Retry.failure_to_retry?(result.failures, klass_method_name)
|
67
78
|
if !result.skipped?
|
68
79
|
Minitest::Retry.failure_callback.call(klass, method_name, result) if Minitest::Retry.failure_callback
|
69
80
|
Minitest::Retry.retry_count.times do |count|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Yaginuma
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|