minitest-retry 0.1.7 → 0.2.2
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 +5 -5
- data/.github/workflows/ubuntu.yml +21 -0
- data/CHANGELOG.md +21 -0
- data/README.md +19 -4
- data/lib/minitest/retry.rb +67 -31
- data/lib/minitest/retry/version.rb +1 -1
- data/minitest-retry.gemspec +2 -2
- metadata +12 -13
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [ '2.7', '2.6', '2.5', '2.4', '2.3' ]
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: ${{ matrix.ruby }}
|
16
|
+
- name: Install dependencies
|
17
|
+
run: |
|
18
|
+
gem install bundler --no-document
|
19
|
+
bundle install
|
20
|
+
- name: Run test
|
21
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## 0.2.2
|
2
|
+
|
3
|
+
* Add `methods_to_retry` option #33 [edudepetris]
|
4
|
+
|
5
|
+
## 0.2.1
|
6
|
+
|
7
|
+
* Pass a test result to consistent failure callback #30 [rmacklin]
|
8
|
+
|
9
|
+
## 0.2.0
|
10
|
+
|
11
|
+
* Pass a test result to failure and retry callbacks #29 [aabrahamian]
|
12
|
+
|
13
|
+
## 0.1.9
|
14
|
+
|
15
|
+
* Add on_consistent_failure callback #20 [staugaard]
|
16
|
+
|
17
|
+
## 0.1.8
|
18
|
+
|
19
|
+
* Add retry callback #17 [julien-meichelbeck]
|
20
|
+
* Pass test class and test name to failure callback #15, #16 [julien-meichelbeck]
|
21
|
+
|
1
22
|
## 0.1.7
|
2
23
|
|
3
24
|
* Run a callback on each test failure #15 [julien-meichelbeck]
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Re-run the test when the test fails.
|
4
4
|
|
5
|
-
|
5
|
+

|
6
6
|
[](http://badge.fury.io/rb/minitest-retry)
|
7
7
|
|
8
8
|
## Installation
|
@@ -37,17 +37,32 @@ 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
|
|
44
|
-
|
45
|
+
#### Callbacks
|
46
|
+
The `on_failure` callback is executed each time a test fails:
|
45
47
|
```ruby
|
46
|
-
Minitest::Retry.on_failure do
|
48
|
+
Minitest::Retry.on_failure do |klass, test_name, result|
|
47
49
|
# code omitted
|
48
50
|
end
|
49
51
|
```
|
50
52
|
|
53
|
+
The `on_consistent_failure` callback is executed when a test consistently fails:
|
54
|
+
```ruby
|
55
|
+
Minitest::Retry.on_consistent_failure do |klass, test_name, result|
|
56
|
+
# code omitted
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
The `on_retry` callback is executed each time a test is retried:
|
61
|
+
```ruby
|
62
|
+
Minitest::Retry.on_retry do |klass, test_name, retry_count, result|
|
63
|
+
# code omitted
|
64
|
+
end
|
65
|
+
```
|
51
66
|
|
52
67
|
## Example
|
53
68
|
|
data/lib/minitest/retry.rb
CHANGED
@@ -2,51 +2,83 @@ 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: [], 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
|
+
@failure_callback, @consistent_failure_callback, @retry_callback = nil, 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_consistent_failure(&block)
|
18
|
+
return unless block_given?
|
19
|
+
@consistent_failure_callback = block
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def on_retry(&block)
|
23
|
+
return unless block_given?
|
24
|
+
@retry_callback = block
|
25
|
+
end
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
def retry_count
|
28
|
+
@retry_count
|
29
|
+
end
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
+
def io
|
32
|
+
@io
|
33
|
+
end
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
def verbose
|
36
|
+
@verbose
|
37
|
+
end
|
38
|
+
|
39
|
+
def exceptions_to_retry
|
40
|
+
@exceptions_to_retry
|
41
|
+
end
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
def methods_to_retry
|
44
|
+
@methods_to_retry
|
45
|
+
end
|
46
|
+
|
47
|
+
def failure_callback
|
48
|
+
@failure_callback
|
49
|
+
end
|
50
|
+
|
51
|
+
def consistent_failure_callback
|
52
|
+
@consistent_failure_callback
|
53
|
+
end
|
54
|
+
|
55
|
+
def retry_callback
|
56
|
+
@retry_callback
|
57
|
+
end
|
58
|
+
|
59
|
+
def failure_to_retry?(failures = [], klass_method_name)
|
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
|
+
|
66
|
+
return true if Minitest::Retry.exceptions_to_retry.empty?
|
67
|
+
errors = failures.map(&:error).map(&:class)
|
68
|
+
(errors & Minitest::Retry.exceptions_to_retry).any?
|
69
|
+
end
|
41
70
|
end
|
42
71
|
|
43
72
|
module ClassMethods
|
44
73
|
def run_one_method(klass, method_name)
|
45
74
|
result = super(klass, method_name)
|
46
|
-
|
75
|
+
|
76
|
+
klass_method_name = "#{klass.name}##{method_name}"
|
77
|
+
return result unless Minitest::Retry.failure_to_retry?(result.failures, klass_method_name)
|
47
78
|
if !result.skipped?
|
48
|
-
Minitest::Retry.failure_callback.call if Minitest::Retry.failure_callback
|
79
|
+
Minitest::Retry.failure_callback.call(klass, method_name, result) if Minitest::Retry.failure_callback
|
49
80
|
Minitest::Retry.retry_count.times do |count|
|
81
|
+
Minitest::Retry.retry_callback.call(klass, method_name, count + 1, result) if Minitest::Retry.retry_callback
|
50
82
|
if Minitest::Retry.verbose && Minitest::Retry.io
|
51
83
|
msg = "[MinitestRetry] retry '%s' count: %s, msg: %s\n" %
|
52
84
|
[method_name, count + 1, result.failures.map(&:message).join(",")]
|
@@ -56,6 +88,10 @@ module Minitest
|
|
56
88
|
result = super(klass, method_name)
|
57
89
|
break if result.failures.empty?
|
58
90
|
end
|
91
|
+
|
92
|
+
if Minitest::Retry.consistent_failure_callback && !result.failures.empty?
|
93
|
+
Minitest::Retry.consistent_failure_callback.call(klass, method_name, result)
|
94
|
+
end
|
59
95
|
end
|
60
96
|
result
|
61
97
|
end
|
data/minitest-retry.gemspec
CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_dependency 'minitest', '>= 5.0'
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler"
|
28
|
-
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "bundler"
|
28
|
+
spec.add_development_dependency "rake"
|
29
29
|
end
|
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.
|
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
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
description: re-run the test when the test fails
|
56
56
|
email:
|
57
57
|
- yuuji.yaginuma@gmail.com
|
@@ -59,8 +59,8 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".github/workflows/ubuntu.yml"
|
62
63
|
- ".gitignore"
|
63
|
-
- ".travis.yml"
|
64
64
|
- CHANGELOG.md
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE.txt
|
@@ -91,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
|
-
|
95
|
-
rubygems_version: 2.5.1
|
94
|
+
rubygems_version: 3.0.3
|
96
95
|
signing_key:
|
97
96
|
specification_version: 4
|
98
97
|
summary: re-run the test when the test fails
|