minitest-retry 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +10 -2
- data/lib/minitest/retry.rb +42 -30
- data/lib/minitest/retry/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfdf6a4b4f0b3c08f50a3946aa85e8daa69dc3bc
|
4
|
+
data.tar.gz: 4e3736d728990cc3776b65b2a095860a1b1fc20f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7472580e97b64953d9c397cf8e0827fca1fc0879edde01cb7b2dc4c400a286e664f50f1255aca228ca333cee1d45a946c04f35758bb6f5b73e697ac2940746a6
|
7
|
+
data.tar.gz: 30f020b54531ad76102d08ec91d2e631cf19ba2285c09a3b23de7c391c2b2a95063b11f1b9ec735a0970948298e001e8579e21b7ed24e789b18dbd166ff7d235
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -41,13 +41,21 @@ Minitest::Retry.use!(
|
|
41
41
|
)
|
42
42
|
```
|
43
43
|
|
44
|
-
|
44
|
+
#### Callbacks
|
45
|
+
The `on_failure` callback is executed each time a test fails:
|
45
46
|
```ruby
|
46
|
-
Minitest::Retry.on_failure do
|
47
|
+
Minitest::Retry.on_failure do |klass, test_name|
|
47
48
|
# code omitted
|
48
49
|
end
|
49
50
|
```
|
50
51
|
|
52
|
+
The `on_retry` callback is executed each time a test is retried:
|
53
|
+
```ruby
|
54
|
+
Minitest::Retry.on_retry do |klass, test_name, retry_count|
|
55
|
+
# code omitted
|
56
|
+
end
|
57
|
+
|
58
|
+
|
51
59
|
|
52
60
|
## Example
|
53
61
|
|
data/lib/minitest/retry.rb
CHANGED
@@ -2,42 +2,53 @@ require "minitest/retry/version"
|
|
2
2
|
|
3
3
|
module Minitest
|
4
4
|
module Retry
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
8
|
+
@failure_callback, @retry_callback = nil, nil
|
9
|
+
Minitest.prepend(self)
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def on_failure(&block)
|
13
|
+
return unless block_given?
|
14
|
+
@failure_callback = block
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def on_retry(&block)
|
18
|
+
return unless block_given?
|
19
|
+
@retry_callback = block
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def retry_count
|
23
|
+
@retry_count
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
def io
|
27
|
+
@io
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
def verbose
|
31
|
+
@verbose
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
def exceptions_to_retry
|
35
|
+
@exceptions_to_retry
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
def failure_callback
|
39
|
+
@failure_callback
|
40
|
+
end
|
41
|
+
|
42
|
+
def retry_callback
|
43
|
+
@retry_callback
|
44
|
+
end
|
45
|
+
|
46
|
+
def failure_to_retry?(failures = [])
|
47
|
+
return false if failures.empty?
|
48
|
+
return true if Minitest::Retry.exceptions_to_retry.empty?
|
49
|
+
errors = failures.map(&:error).map(&:class)
|
50
|
+
(errors & Minitest::Retry.exceptions_to_retry).any?
|
51
|
+
end
|
41
52
|
end
|
42
53
|
|
43
54
|
module ClassMethods
|
@@ -45,8 +56,9 @@ module Minitest
|
|
45
56
|
result = super(klass, method_name)
|
46
57
|
return result unless Minitest::Retry.failure_to_retry?(result.failures)
|
47
58
|
if !result.skipped?
|
48
|
-
Minitest::Retry.failure_callback.call if Minitest::Retry.failure_callback
|
59
|
+
Minitest::Retry.failure_callback.call(klass, method_name) if Minitest::Retry.failure_callback
|
49
60
|
Minitest::Retry.retry_count.times do |count|
|
61
|
+
Minitest::Retry.retry_callback.call(klass, method_name, count + 1) if Minitest::Retry.retry_callback
|
50
62
|
if Minitest::Retry.verbose && Minitest::Retry.io
|
51
63
|
msg = "[MinitestRetry] retry '%s' count: %s, msg: %s\n" %
|
52
64
|
[method_name, count + 1, result.failures.map(&:message).join(",")]
|
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.1.
|
4
|
+
version: 0.1.8
|
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: 2017-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.6.8
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: re-run the test when the test fails
|