minitest-retry 0.1.7 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: adef2404a03df16664a61e705b7a6217e37c50e3
4
- data.tar.gz: ff508f9eba54c0421a2b0dd69f0e2169e84fd87f
2
+ SHA256:
3
+ metadata.gz: 986ef3b3ffb779d7f4351d864c93d932226cbef9653fa7f5bc208502f46586b2
4
+ data.tar.gz: 5e0a10b926b1aa02e08289c017379b68a4b6741dd5572e66ed5fb7aaba5a9d66
5
5
  SHA512:
6
- metadata.gz: 0207ff184998ffcaf7043f23e0ff3a240fa3c7f630fe6e4ce81c6657d548a132bd1177708acaf6b059dc150dc1ca8da8d74df3790b4567c2dfe8ad82cffdbe5a
7
- data.tar.gz: b7228bf144afa0e1041694da7fcbf0898ca88383b708407344cba49f124dbea6f4aec1ac3ad4c15acdaf975b83ff35c06db850fb68cbc7580c1a09185dcd2822
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
- [![Build Status](https://travis-ci.org/y-yagi/minitest-retry.svg?branch=master)](https://travis-ci.org/y-yagi/minitest-retry)
5
+ ![](https://github.com/y-yagi/minitest-retry/workflows/CI/badge.svg)
6
6
  [![Gem Version](https://badge.fury.io/rb/minitest-retry.svg)](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: [] # List of exceptions that will trigger a retry (when empty, all exceptions will).
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
- You can specify an `on_failure` callback which is executed at each retry:
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
 
@@ -2,51 +2,83 @@ require "minitest/retry/version"
2
2
 
3
3
  module Minitest
4
4
  module Retry
5
- def self.use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [])
6
- @retry_count, @io, @verbose, @exceptions_to_retry = retry_count, io, verbose, exceptions_to_retry
7
- @failure_callback = nil
8
- Minitest.prepend(self)
9
- end
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
- def self.on_failure(&block)
12
- return unless block_given?
13
- @failure_callback = block
14
- end
12
+ def on_failure(&block)
13
+ return unless block_given?
14
+ @failure_callback = block
15
+ end
15
16
 
16
- def self.retry_count
17
- @retry_count
18
- end
17
+ def on_consistent_failure(&block)
18
+ return unless block_given?
19
+ @consistent_failure_callback = block
20
+ end
19
21
 
20
- def self.io
21
- @io
22
- end
22
+ def on_retry(&block)
23
+ return unless block_given?
24
+ @retry_callback = block
25
+ end
23
26
 
24
- def self.verbose
25
- @verbose
26
- end
27
+ def retry_count
28
+ @retry_count
29
+ end
27
30
 
28
- def self.exceptions_to_retry
29
- @exceptions_to_retry
30
- end
31
+ def io
32
+ @io
33
+ end
31
34
 
32
- def self.failure_callback
33
- @failure_callback
34
- end
35
+ def verbose
36
+ @verbose
37
+ end
38
+
39
+ def exceptions_to_retry
40
+ @exceptions_to_retry
41
+ end
35
42
 
36
- def self.failure_to_retry?(failures = [])
37
- return false if failures.empty?
38
- return true if Minitest::Retry.exceptions_to_retry.empty?
39
- errors = failures.map(&:error).map(&:class)
40
- (errors & Minitest::Retry.exceptions_to_retry).any?
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
- return result unless Minitest::Retry.failure_to_retry?(result.failures)
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
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Retry
3
- VERSION = "0.1.7"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -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", "~> 1.10"
28
- spec.add_development_dependency "rake", "~> 10.0"
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.1.7
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: 2016-12-31 00:00:00.000000000 Z
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: '1.10'
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: '1.10'
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: '10.0'
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: '10.0'
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
- rubyforge_project:
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
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1
4
- - 2.2.6
5
- - 2.3.3
6
- - 2.4.0
7
- before_install: gem install bundler