minitest-retry 0.1.6 → 0.1.7

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: 48f8d8974ffc3f3099a0edbbc4c7b3e6124c3084
4
- data.tar.gz: a629409c0946a5c05bea0e24be1d8287ff7bbe32
3
+ metadata.gz: adef2404a03df16664a61e705b7a6217e37c50e3
4
+ data.tar.gz: ff508f9eba54c0421a2b0dd69f0e2169e84fd87f
5
5
  SHA512:
6
- metadata.gz: d8d3c814c37a137be4269cf092a4a363dcdd82597c563e127e948b8631c26804787f8c5bd2c4524707f154f499901f4ff01b8dbfc72acc42af5a5cfc830698d7
7
- data.tar.gz: 8bd918699dbb207c4f100e98a8f508fb0b9f789ac4e2bf1d1b06331a552a0145edbdebe731fcf7545527a5a772a12edbed1ef801ff355b82348c3a01e5bf918d
6
+ metadata.gz: 0207ff184998ffcaf7043f23e0ff3a240fa3c7f630fe6e4ce81c6657d548a132bd1177708acaf6b059dc150dc1ca8da8d74df3790b4567c2dfe8ad82cffdbe5a
7
+ data.tar.gz: b7228bf144afa0e1041694da7fcbf0898ca88383b708407344cba49f124dbea6f4aec1ac3ad4c15acdaf975b83ff35c06db850fb68cbc7580c1a09185dcd2822
data/.travis.yml CHANGED
@@ -3,5 +3,5 @@ rvm:
3
3
  - 2.1
4
4
  - 2.2.6
5
5
  - 2.3.3
6
- - 2.4.0-preview3
6
+ - 2.4.0
7
7
  before_install: gem install bundler
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.7
2
+
3
+ * Run a callback on each test failure #15 [julien-meichelbeck]
4
+
1
5
  ## 0.1.6
2
6
 
3
7
  * Add exceptions_to_retry option #13 [panjan]
data/README.md CHANGED
@@ -41,6 +41,14 @@ Minitest::Retry.use!(
41
41
  )
42
42
  ```
43
43
 
44
+ You can specify an `on_failure` callback which is executed at each retry:
45
+ ```ruby
46
+ Minitest::Retry.on_failure do
47
+ # code omitted
48
+ end
49
+ ```
50
+
51
+
44
52
  ## Example
45
53
 
46
54
  ```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
@@ -4,9 +4,15 @@ module Minitest
4
4
  module Retry
5
5
  def self.use!(retry_count: 3, io: $stdout, verbose: true, exceptions_to_retry: [])
6
6
  @retry_count, @io, @verbose, @exceptions_to_retry = retry_count, io, verbose, exceptions_to_retry
7
+ @failure_callback = nil
7
8
  Minitest.prepend(self)
8
9
  end
9
10
 
11
+ def self.on_failure(&block)
12
+ return unless block_given?
13
+ @failure_callback = block
14
+ end
15
+
10
16
  def self.retry_count
11
17
  @retry_count
12
18
  end
@@ -23,6 +29,10 @@ module Minitest
23
29
  @exceptions_to_retry
24
30
  end
25
31
 
32
+ def self.failure_callback
33
+ @failure_callback
34
+ end
35
+
26
36
  def self.failure_to_retry?(failures = [])
27
37
  return false if failures.empty?
28
38
  return true if Minitest::Retry.exceptions_to_retry.empty?
@@ -32,11 +42,11 @@ module Minitest
32
42
 
33
43
  module ClassMethods
34
44
  def run_one_method(klass, method_name)
35
- retry_count = Minitest::Retry.retry_count
36
45
  result = super(klass, method_name)
37
46
  return result unless Minitest::Retry.failure_to_retry?(result.failures)
38
47
  if !result.skipped?
39
- retry_count.times do |count|
48
+ Minitest::Retry.failure_callback.call if Minitest::Retry.failure_callback
49
+ Minitest::Retry.retry_count.times do |count|
40
50
  if Minitest::Retry.verbose && Minitest::Retry.io
41
51
  msg = "[MinitestRetry] retry '%s' count: %s, msg: %s\n" %
42
52
  [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.6"
3
+ VERSION = "0.1.7"
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.6
4
+ version: 0.1.7
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: 2016-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest