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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adef2404a03df16664a61e705b7a6217e37c50e3
4
- data.tar.gz: ff508f9eba54c0421a2b0dd69f0e2169e84fd87f
3
+ metadata.gz: dfdf6a4b4f0b3c08f50a3946aa85e8daa69dc3bc
4
+ data.tar.gz: 4e3736d728990cc3776b65b2a095860a1b1fc20f
5
5
  SHA512:
6
- metadata.gz: 0207ff184998ffcaf7043f23e0ff3a240fa3c7f630fe6e4ce81c6657d548a132bd1177708acaf6b059dc150dc1ca8da8d74df3790b4567c2dfe8ad82cffdbe5a
7
- data.tar.gz: b7228bf144afa0e1041694da7fcbf0898ca88383b708407344cba49f124dbea6f4aec1ac3ad4c15acdaf975b83ff35c06db850fb68cbc7580c1a09185dcd2822
6
+ metadata.gz: 7472580e97b64953d9c397cf8e0827fca1fc0879edde01cb7b2dc4c400a286e664f50f1255aca228ca333cee1d45a946c04f35758bb6f5b73e697ac2940746a6
7
+ data.tar.gz: 30f020b54531ad76102d08ec91d2e631cf19ba2285c09a3b23de7c391c2b2a95063b11f1b9ec735a0970948298e001e8579e21b7ed24e789b18dbd166ff7d235
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.1.8
2
+
3
+ * Add retry callback #17 [julien-meichelbeck]
4
+ * Pass test class and test name to failure callback #15, #16 [julien-meichelbeck]
5
+
1
6
  ## 0.1.7
2
7
 
3
8
  * Run a callback on each test failure #15 [julien-meichelbeck]
data/README.md CHANGED
@@ -41,13 +41,21 @@ Minitest::Retry.use!(
41
41
  )
42
42
  ```
43
43
 
44
- You can specify an `on_failure` callback which is executed at each retry:
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
 
@@ -2,42 +2,53 @@ 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: [])
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
- 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_retry(&block)
18
+ return unless block_given?
19
+ @retry_callback = block
20
+ end
19
21
 
20
- def self.io
21
- @io
22
- end
22
+ def retry_count
23
+ @retry_count
24
+ end
23
25
 
24
- def self.verbose
25
- @verbose
26
- end
26
+ def io
27
+ @io
28
+ end
27
29
 
28
- def self.exceptions_to_retry
29
- @exceptions_to_retry
30
- end
30
+ def verbose
31
+ @verbose
32
+ end
31
33
 
32
- def self.failure_callback
33
- @failure_callback
34
- end
34
+ def exceptions_to_retry
35
+ @exceptions_to_retry
36
+ end
35
37
 
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?
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(",")]
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Retry
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  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.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: 2016-12-31 00:00:00.000000000 Z
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.5.1
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