minitest-hooks 1.4.2 → 1.5.0

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: cab2b3cd7d0bc63cc18436e87e08ff392e9facfc
4
- data.tar.gz: 82eed894ed6beab837d83fd94a64ab3c36e1acb4
2
+ SHA256:
3
+ metadata.gz: e1b87392a55ca81f157fd989534fc2b79040ec5e195fca3c8a1b7ddffaf15213
4
+ data.tar.gz: 82e5b7956582f51edd760939dee7b27e0dc06f472fd15cf9c21fff8a9855394c
5
5
  SHA512:
6
- metadata.gz: fa12984df59acb3da5d4d038f2d5aa83b758724a5f7a2d258f6f82ddc5d23d7afc739eaaa9b09bdd72befa7f040f693a398ced29b3086e6ef9278118753975bb
7
- data.tar.gz: b2e8f5f4bdf2e1283711cb2b947da5ea5526eaf7e00bd2ec0912011764203c16f7ba376011df4898a4bb8108599b6e416b447859838af44d7adf229f89d152ee
6
+ metadata.gz: 7ebed42f49cb8283e0b7312b05b7e2f67f98532487b78666f9bd1be0f9b53cad6667ff865e8802d7567b1b16cc1c77d75213a5d1ca67cfcafb9363b62e3278dc
7
+ data.tar.gz: 6770a8438db15b61715c2743870d1f25adc77c9214b3fd80395d71ac16541ab932c39f735756b9308cf9721ca4641c1d8e53a684f7c8a95a9617a2e73c24c4cd
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.5.0 (2018-05-21)
2
+
3
+ * Fix use with minitest 5.11+ by using Minitest::Result in such cases (GUI) (#15)
4
+
1
5
  === 1.4.2 (2017-09-12)
2
6
 
3
7
  * Don't modify test instance name if before_all/after_all cause an error (jeremyevans) (#14)
@@ -64,40 +64,39 @@ module Minitest::Hooks::ClassMethods
64
64
  def with_info_handler(reporter, &block)
65
65
  @instance = new(NEW)
66
66
  @instance.time = 0
67
- description = respond_to?(:desc) ? desc : name
68
- @instance.name = "#{description}#around_all"
67
+ @instance.name = "around_all"
69
68
 
70
69
  begin
71
70
  @instance.around_all do
72
71
  begin
73
72
  @instance.capture_exceptions do
74
- @instance.name = "#{description}#before_all"
73
+ @instance.name = "before_all"
75
74
  @instance.before_all
76
75
  end
77
76
 
78
77
  if @instance.failure
79
78
  failed = true
80
- reporter.record @instance
79
+ _record_minitest_hooks_error(reporter, @instance)
81
80
  else
82
81
  super(reporter, &block)
83
82
  end
84
83
  ensure
85
84
  @instance.capture_exceptions do
86
- @instance.name = "#{description}#after_all" unless failed
85
+ @instance.name = "after_all" unless failed
87
86
  @instance.after_all
88
87
  end
89
88
  if @instance.failure && !failed
90
89
  failed = true
91
- reporter.record @instance
90
+ _record_minitest_hooks_error(reporter, @instance)
92
91
  end
93
- @instance.name = "#{description}#around_all" unless failed
92
+ @instance.name = "around_all" unless failed
94
93
  end
95
94
  end
96
95
  rescue => e
97
96
  @instance.capture_exceptions do
98
97
  raise e
99
98
  end
100
- reporter.record @instance
99
+ _record_minitest_hooks_error(reporter, @instance)
101
100
  end
102
101
  end
103
102
 
@@ -132,4 +131,17 @@ module Minitest::Hooks::ClassMethods
132
131
  super
133
132
  end
134
133
  end
134
+
135
+ private
136
+
137
+ def _record_minitest_hooks_error(reporter, instance)
138
+ # In MiniTest 5.11+, use Minitest::Result for wrapping the object to send
139
+ # to the reporter.
140
+ if(defined?(Minitest::Result))
141
+ result = Minitest::Result.from(instance)
142
+ else
143
+ result = instance
144
+ end
145
+ reporter.record result
146
+ end
135
147
  end
@@ -3,6 +3,32 @@ require 'minitest/hooks/default'
3
3
 
4
4
  error = ENV['MINITEST_HOOKS_ERRORS']
5
5
 
6
+ module Minitest
7
+ def self.plugin_result_inspector_reporter_init(options)
8
+ self.reporter << ResultInspectorReporter.new(options[:io], options)
9
+ end
10
+
11
+ class ResultInspectorReporter < SummaryReporter
12
+ def report
13
+ results.each do |result|
14
+ io.puts "result to_s: #{result.to_s.inspect}"
15
+ # For MiniTest 5.11+, we expect Minitest::Result objects.
16
+ if defined?(Minitest::Result)
17
+ io.puts "result source_location: #{result.source_location.inspect}"
18
+ else
19
+ # For older versions of Minitest, extract source_location in a
20
+ # similar fashion to how some third party reporters expected to be
21
+ # able to:
22
+ # https://github.com/circleci/minitest-ci/blob/8b72b0f32f154d91b53d63d1d0a8a8fb3b01d726/lib/minitest/ci_plugin.rb#L139
23
+ io.puts "result source_location: #{result.method(result.name).source_location.inspect}"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Minitest.extensions << "result_inspector_reporter"
31
+
6
32
  describe 'Minitest::Hooks error handling' do
7
33
  before(:all) do
8
34
  raise if error == 'before-all'
@@ -26,11 +52,11 @@ describe 'Minitest::Hooks error handling' do
26
52
  super(&block)
27
53
  case error
28
54
  when 'before-all'
29
- name.must_equal 'Minitest::Hooks error handling#before_all'
55
+ name.must_equal 'before_all'
30
56
  when 'after-all'
31
- name.must_equal 'Minitest::Hooks error handling#after_all'
57
+ name.must_equal 'after_all'
32
58
  else
33
- name.must_equal 'Minitest::Hooks error handling#around_all'
59
+ name.must_equal 'around_all'
34
60
  end
35
61
  raise if error == 'around-all-after'
36
62
  end
@@ -3,15 +3,15 @@ require 'minitest/hooks/default'
3
3
 
4
4
  describe 'Minitest::Hooks error handling' do
5
5
  before(:all) do
6
- name.must_equal 'Minitest::Hooks error handling#before_all'
6
+ name.must_equal 'before_all'
7
7
  end
8
8
  after(:all) do
9
- name.must_equal 'Minitest::Hooks error handling#after_all'
9
+ name.must_equal 'after_all'
10
10
  end
11
11
  around(:all) do |&block|
12
- name.must_equal 'Minitest::Hooks error handling#around_all'
12
+ name.must_equal 'around_all'
13
13
  super(&block)
14
- name.must_equal 'Minitest::Hooks error handling#around_all'
14
+ name.must_equal 'around_all'
15
15
  end
16
16
 
17
17
  3.times do |i|
@@ -24,15 +24,15 @@ class MinitestHooksNameTest < Minitest::Test
24
24
  include Minitest::Hooks
25
25
 
26
26
  def before_all
27
- assert_equal 'MinitestHooksNameTest#before_all', name
27
+ assert_equal 'before_all', name
28
28
  end
29
29
  def after_all
30
- assert_equal 'MinitestHooksNameTest#after_all', name
30
+ assert_equal 'after_all', name
31
31
  end
32
32
  def around_all
33
- assert_equal 'MinitestHooksNameTest#around_all', name
33
+ assert_equal 'around_all', name
34
34
  super
35
- assert_equal 'MinitestHooksNameTest#around_all', name
35
+ assert_equal 'around_all', name
36
36
  end
37
37
 
38
38
  3.times do |i|
@@ -9,8 +9,13 @@ describe 'Minitest::Hooks error handling' do
9
9
  it "should handle errors in #{desc}" do
10
10
  ENV['MINITEST_HOOKS_ERRORS'] = desc
11
11
  Open3.popen3(RUBY, "spec/errors/example.rb", "-v") do |_, o, e, w|
12
- o.read.must_match /#{runs} runs, 0 assertions, 0 failures, #{errors} errors, 0 skips/
13
- e.read.must_equal ''
12
+ output = o.read
13
+ output.must_match /#{runs} runs, 0 assertions, 0 failures, #{errors} errors, 0 skips/
14
+ output.must_match /result to_s: ".*?Minitest::Hooks error handling#\w+.*?spec\/errors\/example\.rb:\d+/
15
+ output.must_match /result source_location: \["(unknown|.+?\.rb)", -?\d+\]/
16
+ output = e.read
17
+ output.gsub!(/Picked up _JAVA_OPTIONS: [^\n]+\n/, '')
18
+ output.must_equal ''
14
19
  w.value.exitstatus.wont_equal 0 if w
15
20
  end
16
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
20
- type: :development
19
+ version: '5.3'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">"
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
26
+ version: '5.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sequel
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.6.13
124
+ rubygems_version: 2.7.6
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Around and before_all/after_all/around_all hooks for Minitest