minitest-retry 0.1.6 → 0.2.1

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: 48f8d8974ffc3f3099a0edbbc4c7b3e6124c3084
4
- data.tar.gz: a629409c0946a5c05bea0e24be1d8287ff7bbe32
2
+ SHA256:
3
+ metadata.gz: ee8f32526c33316323c344291e448fff7a4107a4d98af04a0fb7fc8b645a3678
4
+ data.tar.gz: a139a0a4ea5c047e0216903832b688ac1f33e64e78c24ddfed81c624fe4811b1
5
5
  SHA512:
6
- metadata.gz: d8d3c814c37a137be4269cf092a4a363dcdd82597c563e127e948b8631c26804787f8c5bd2c4524707f154f499901f4ff01b8dbfc72acc42af5a5cfc830698d7
7
- data.tar.gz: 8bd918699dbb207c4f100e98a8f508fb0b9f789ac4e2bf1d1b06331a552a0145edbdebe731fcf7545527a5a772a12edbed1ef801ff355b82348c3a01e5bf918d
6
+ metadata.gz: '048d1154af57d771bfa0022ca6686844afda442227c51a123111b101fdd527a0f1029633f0c8aa2783d453963f9c45bd1fe4efc72bbe72f6502fe6979f2b602a'
7
+ data.tar.gz: 9323ed80ec1a7df777504f6b25e602907994d56c4dfea2431124a682c10ead588088e87747dbf1e4cb3a941ccbaf4276538fa00b40e93bfef7ea97771487353c
@@ -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
@@ -1,3 +1,24 @@
1
+ ## 0.2.1
2
+
3
+ * Pass a test result to consistent failure callback #30 [rmacklin]
4
+
5
+ ## 0.2.0
6
+
7
+ * Pass a test result to failure and retry callbacks #29 [aabrahamian]
8
+
9
+ ## 0.1.9
10
+
11
+ * Add on_consistent_failure callback #20 [staugaard]
12
+
13
+ ## 0.1.8
14
+
15
+ * Add retry callback #17 [julien-meichelbeck]
16
+ * Pass test class and test name to failure callback #15, #16 [julien-meichelbeck]
17
+
18
+ ## 0.1.7
19
+
20
+ * Run a callback on each test failure #15 [julien-meichelbeck]
21
+
1
22
  ## 0.1.6
2
23
 
3
24
  * Add exceptions_to_retry option #13 [panjan]
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
@@ -41,6 +41,28 @@ Minitest::Retry.use!(
41
41
  )
42
42
  ```
43
43
 
44
+ #### Callbacks
45
+ The `on_failure` callback is executed each time a test fails:
46
+ ```ruby
47
+ Minitest::Retry.on_failure do |klass, test_name, result|
48
+ # code omitted
49
+ end
50
+ ```
51
+
52
+ The `on_consistent_failure` callback is executed when a test consistently fails:
53
+ ```ruby
54
+ Minitest::Retry.on_consistent_failure do |klass, test_name, result|
55
+ # code omitted
56
+ end
57
+ ```
58
+
59
+ The `on_retry` callback is executed each time a test is retried:
60
+ ```ruby
61
+ Minitest::Retry.on_retry do |klass, test_name, retry_count, result|
62
+ # code omitted
63
+ end
64
+ ```
65
+
44
66
  ## Example
45
67
 
46
68
  ```ruby
data/Rakefile CHANGED
@@ -6,6 +6,7 @@ Rake::TestTask.new(:test) do |t|
6
6
  t.libs << "lib"
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
8
  t.verbose = true
9
+ t.warning = true
9
10
  end
10
11
 
11
12
  task :default => :test
@@ -2,41 +2,72 @@ 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
- Minitest.prepend(self)
8
- end
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, @consistent_failure_callback, @retry_callback = nil, nil, nil
9
+ Minitest.prepend(self)
10
+ end
9
11
 
10
- def self.retry_count
11
- @retry_count
12
- end
12
+ def on_failure(&block)
13
+ return unless block_given?
14
+ @failure_callback = block
15
+ end
13
16
 
14
- def self.io
15
- @io
16
- end
17
+ def on_consistent_failure(&block)
18
+ return unless block_given?
19
+ @consistent_failure_callback = block
20
+ end
17
21
 
18
- def self.verbose
19
- @verbose
20
- end
22
+ def on_retry(&block)
23
+ return unless block_given?
24
+ @retry_callback = block
25
+ end
21
26
 
22
- def self.exceptions_to_retry
23
- @exceptions_to_retry
24
- end
27
+ def retry_count
28
+ @retry_count
29
+ end
25
30
 
26
- def self.failure_to_retry?(failures = [])
27
- return false if failures.empty?
28
- return true if Minitest::Retry.exceptions_to_retry.empty?
29
- errors = failures.map(&:error).map(&:class)
30
- (errors & Minitest::Retry.exceptions_to_retry).any?
31
+ def io
32
+ @io
33
+ end
34
+
35
+ def verbose
36
+ @verbose
37
+ end
38
+
39
+ def exceptions_to_retry
40
+ @exceptions_to_retry
41
+ end
42
+
43
+ def failure_callback
44
+ @failure_callback
45
+ end
46
+
47
+ def consistent_failure_callback
48
+ @consistent_failure_callback
49
+ end
50
+
51
+ def retry_callback
52
+ @retry_callback
53
+ end
54
+
55
+ def failure_to_retry?(failures = [])
56
+ return false if failures.empty?
57
+ return true if Minitest::Retry.exceptions_to_retry.empty?
58
+ errors = failures.map(&:error).map(&:class)
59
+ (errors & Minitest::Retry.exceptions_to_retry).any?
60
+ end
31
61
  end
32
62
 
33
63
  module ClassMethods
34
64
  def run_one_method(klass, method_name)
35
- retry_count = Minitest::Retry.retry_count
36
65
  result = super(klass, method_name)
37
66
  return result unless Minitest::Retry.failure_to_retry?(result.failures)
38
67
  if !result.skipped?
39
- retry_count.times do |count|
68
+ Minitest::Retry.failure_callback.call(klass, method_name, result) if Minitest::Retry.failure_callback
69
+ Minitest::Retry.retry_count.times do |count|
70
+ Minitest::Retry.retry_callback.call(klass, method_name, count + 1, result) if Minitest::Retry.retry_callback
40
71
  if Minitest::Retry.verbose && Minitest::Retry.io
41
72
  msg = "[MinitestRetry] retry '%s' count: %s, msg: %s\n" %
42
73
  [method_name, count + 1, result.failures.map(&:message).join(",")]
@@ -46,6 +77,10 @@ module Minitest
46
77
  result = super(klass, method_name)
47
78
  break if result.failures.empty?
48
79
  end
80
+
81
+ if Minitest::Retry.consistent_failure_callback && !result.failures.empty?
82
+ Minitest::Retry.consistent_failure_callback.call(klass, method_name, result)
83
+ end
49
84
  end
50
85
  result
51
86
  end
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Retry
3
- VERSION = "0.1.6"
3
+ VERSION = "0.2.1"
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.6
4
+ version: 0.2.1
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-11-23 00:00:00.000000000 Z
11
+ date: 2020-05-28 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
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1
4
- - 2.2.6
5
- - 2.3.3
6
- - 2.4.0-preview3
7
- before_install: gem install bundler