minitest 5.11.3 → 5.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +102 -3
- data/Manifest.txt +1 -0
- data/README.rdoc +61 -7
- data/Rakefile +4 -16
- data/lib/minitest/assertions.rb +140 -26
- data/lib/minitest/benchmark.rb +2 -2
- data/lib/minitest/expectations.rb +54 -35
- data/lib/minitest/mock.rb +5 -1
- data/lib/minitest/spec.rb +19 -8
- data/lib/minitest.rb +90 -21
- data/test/minitest/metametameta.rb +42 -8
- data/test/minitest/test_minitest_assertions.rb +1575 -0
- data/test/minitest/test_minitest_mock.rb +14 -4
- data/test/minitest/test_minitest_spec.rb +215 -141
- data/test/minitest/test_minitest_test.rb +38 -1096
- data.tar.gz.sig +0 -0
- metadata +33 -22
- metadata.gz.sig +0 -0
@@ -9,10 +9,11 @@
|
|
9
9
|
#
|
10
10
|
# it "should still work in threads" do
|
11
11
|
# my_threaded_thingy do
|
12
|
-
# (1+1).must_equal 2
|
13
|
-
# assert_equal 2, 1+1
|
14
|
-
# _(1 + 1).must_equal 2
|
15
|
-
# value(1 + 1).must_equal 2
|
12
|
+
# (1+1).must_equal 2 # bad
|
13
|
+
# assert_equal 2, 1+1 # good
|
14
|
+
# _(1 + 1).must_equal 2 # good
|
15
|
+
# value(1 + 1).must_equal 2 # good, also #expect
|
16
|
+
# _ { 1 + "1" }.must_raise TypeError # good
|
16
17
|
# end
|
17
18
|
# end
|
18
19
|
|
@@ -21,7 +22,7 @@ module Minitest::Expectations
|
|
21
22
|
##
|
22
23
|
# See Minitest::Assertions#assert_empty.
|
23
24
|
#
|
24
|
-
# collection.must_be_empty
|
25
|
+
# _(collection).must_be_empty
|
25
26
|
#
|
26
27
|
# :method: must_be_empty
|
27
28
|
|
@@ -30,7 +31,7 @@ module Minitest::Expectations
|
|
30
31
|
##
|
31
32
|
# See Minitest::Assertions#assert_equal
|
32
33
|
#
|
33
|
-
# a.must_equal b
|
34
|
+
# _(a).must_equal b
|
34
35
|
#
|
35
36
|
# :method: must_equal
|
36
37
|
|
@@ -39,18 +40,18 @@ module Minitest::Expectations
|
|
39
40
|
##
|
40
41
|
# See Minitest::Assertions#assert_in_delta
|
41
42
|
#
|
42
|
-
# n.must_be_close_to m [, delta]
|
43
|
+
# _(n).must_be_close_to m [, delta]
|
43
44
|
#
|
44
45
|
# :method: must_be_close_to
|
45
46
|
|
46
47
|
infect_an_assertion :assert_in_delta, :must_be_close_to
|
47
48
|
|
48
|
-
|
49
|
+
infect_an_assertion :assert_in_delta, :must_be_within_delta # :nodoc:
|
49
50
|
|
50
51
|
##
|
51
52
|
# See Minitest::Assertions#assert_in_epsilon
|
52
53
|
#
|
53
|
-
# n.must_be_within_epsilon m [, epsilon]
|
54
|
+
# _(n).must_be_within_epsilon m [, epsilon]
|
54
55
|
#
|
55
56
|
# :method: must_be_within_epsilon
|
56
57
|
|
@@ -59,7 +60,7 @@ module Minitest::Expectations
|
|
59
60
|
##
|
60
61
|
# See Minitest::Assertions#assert_includes
|
61
62
|
#
|
62
|
-
# collection.must_include obj
|
63
|
+
# _(collection).must_include obj
|
63
64
|
#
|
64
65
|
# :method: must_include
|
65
66
|
|
@@ -68,7 +69,7 @@ module Minitest::Expectations
|
|
68
69
|
##
|
69
70
|
# See Minitest::Assertions#assert_instance_of
|
70
71
|
#
|
71
|
-
# obj.must_be_instance_of klass
|
72
|
+
# _(obj).must_be_instance_of klass
|
72
73
|
#
|
73
74
|
# :method: must_be_instance_of
|
74
75
|
|
@@ -77,7 +78,7 @@ module Minitest::Expectations
|
|
77
78
|
##
|
78
79
|
# See Minitest::Assertions#assert_kind_of
|
79
80
|
#
|
80
|
-
# obj.must_be_kind_of mod
|
81
|
+
# _(obj).must_be_kind_of mod
|
81
82
|
#
|
82
83
|
# :method: must_be_kind_of
|
83
84
|
|
@@ -86,7 +87,7 @@ module Minitest::Expectations
|
|
86
87
|
##
|
87
88
|
# See Minitest::Assertions#assert_match
|
88
89
|
#
|
89
|
-
# a.must_match b
|
90
|
+
# _(a).must_match b
|
90
91
|
#
|
91
92
|
# :method: must_match
|
92
93
|
|
@@ -95,7 +96,7 @@ module Minitest::Expectations
|
|
95
96
|
##
|
96
97
|
# See Minitest::Assertions#assert_nil
|
97
98
|
#
|
98
|
-
# obj.must_be_nil
|
99
|
+
# _(obj).must_be_nil
|
99
100
|
#
|
100
101
|
# :method: must_be_nil
|
101
102
|
|
@@ -104,11 +105,11 @@ module Minitest::Expectations
|
|
104
105
|
##
|
105
106
|
# See Minitest::Assertions#assert_operator
|
106
107
|
#
|
107
|
-
# n.must_be :<=, 42
|
108
|
+
# _(n).must_be :<=, 42
|
108
109
|
#
|
109
110
|
# This can also do predicates:
|
110
111
|
#
|
111
|
-
# str.must_be :empty?
|
112
|
+
# _(str).must_be :empty?
|
112
113
|
#
|
113
114
|
# :method: must_be
|
114
115
|
|
@@ -117,7 +118,7 @@ module Minitest::Expectations
|
|
117
118
|
##
|
118
119
|
# See Minitest::Assertions#assert_output
|
119
120
|
#
|
120
|
-
#
|
121
|
+
# _ { ... }.must_output out_or_nil [, err]
|
121
122
|
#
|
122
123
|
# :method: must_output
|
123
124
|
|
@@ -126,7 +127,7 @@ module Minitest::Expectations
|
|
126
127
|
##
|
127
128
|
# See Minitest::Assertions#assert_raises
|
128
129
|
#
|
129
|
-
#
|
130
|
+
# _ { ... }.must_raise exception
|
130
131
|
#
|
131
132
|
# :method: must_raise
|
132
133
|
|
@@ -135,7 +136,7 @@ module Minitest::Expectations
|
|
135
136
|
##
|
136
137
|
# See Minitest::Assertions#assert_respond_to
|
137
138
|
#
|
138
|
-
# obj.must_respond_to msg
|
139
|
+
# _(obj).must_respond_to msg
|
139
140
|
#
|
140
141
|
# :method: must_respond_to
|
141
142
|
|
@@ -144,7 +145,7 @@ module Minitest::Expectations
|
|
144
145
|
##
|
145
146
|
# See Minitest::Assertions#assert_same
|
146
147
|
#
|
147
|
-
# a.must_be_same_as b
|
148
|
+
# _(a).must_be_same_as b
|
148
149
|
#
|
149
150
|
# :method: must_be_same_as
|
150
151
|
|
@@ -153,7 +154,7 @@ module Minitest::Expectations
|
|
153
154
|
##
|
154
155
|
# See Minitest::Assertions#assert_silent
|
155
156
|
#
|
156
|
-
#
|
157
|
+
# _ { ... }.must_be_silent
|
157
158
|
#
|
158
159
|
# :method: must_be_silent
|
159
160
|
|
@@ -162,16 +163,34 @@ module Minitest::Expectations
|
|
162
163
|
##
|
163
164
|
# See Minitest::Assertions#assert_throws
|
164
165
|
#
|
165
|
-
#
|
166
|
+
# _ { ... }.must_throw sym
|
166
167
|
#
|
167
168
|
# :method: must_throw
|
168
169
|
|
169
170
|
infect_an_assertion :assert_throws, :must_throw, :block
|
170
171
|
|
172
|
+
##
|
173
|
+
# See Minitest::Assertions#assert_path_exists
|
174
|
+
#
|
175
|
+
# _(some_path).path_must_exist
|
176
|
+
#
|
177
|
+
# :method: path_must_exist
|
178
|
+
|
179
|
+
infect_an_assertion :assert_path_exists, :path_must_exist, :unary
|
180
|
+
|
181
|
+
##
|
182
|
+
# See Minitest::Assertions#refute_path_exists
|
183
|
+
#
|
184
|
+
# _(some_path).path_wont_exist
|
185
|
+
#
|
186
|
+
# :method: path_wont_exist
|
187
|
+
|
188
|
+
infect_an_assertion :refute_path_exists, :path_wont_exist, :unary
|
189
|
+
|
171
190
|
##
|
172
191
|
# See Minitest::Assertions#refute_empty
|
173
192
|
#
|
174
|
-
# collection.wont_be_empty
|
193
|
+
# _(collection).wont_be_empty
|
175
194
|
#
|
176
195
|
# :method: wont_be_empty
|
177
196
|
|
@@ -180,7 +199,7 @@ module Minitest::Expectations
|
|
180
199
|
##
|
181
200
|
# See Minitest::Assertions#refute_equal
|
182
201
|
#
|
183
|
-
# a.wont_equal b
|
202
|
+
# _(a).wont_equal b
|
184
203
|
#
|
185
204
|
# :method: wont_equal
|
186
205
|
|
@@ -189,18 +208,18 @@ module Minitest::Expectations
|
|
189
208
|
##
|
190
209
|
# See Minitest::Assertions#refute_in_delta
|
191
210
|
#
|
192
|
-
# n.wont_be_close_to m [, delta]
|
211
|
+
# _(n).wont_be_close_to m [, delta]
|
193
212
|
#
|
194
213
|
# :method: wont_be_close_to
|
195
214
|
|
196
215
|
infect_an_assertion :refute_in_delta, :wont_be_close_to
|
197
216
|
|
198
|
-
|
217
|
+
infect_an_assertion :refute_in_delta, :wont_be_within_delta # :nodoc:
|
199
218
|
|
200
219
|
##
|
201
220
|
# See Minitest::Assertions#refute_in_epsilon
|
202
221
|
#
|
203
|
-
# n.wont_be_within_epsilon m [, epsilon]
|
222
|
+
# _(n).wont_be_within_epsilon m [, epsilon]
|
204
223
|
#
|
205
224
|
# :method: wont_be_within_epsilon
|
206
225
|
|
@@ -209,7 +228,7 @@ module Minitest::Expectations
|
|
209
228
|
##
|
210
229
|
# See Minitest::Assertions#refute_includes
|
211
230
|
#
|
212
|
-
# collection.wont_include obj
|
231
|
+
# _(collection).wont_include obj
|
213
232
|
#
|
214
233
|
# :method: wont_include
|
215
234
|
|
@@ -218,7 +237,7 @@ module Minitest::Expectations
|
|
218
237
|
##
|
219
238
|
# See Minitest::Assertions#refute_instance_of
|
220
239
|
#
|
221
|
-
# obj.wont_be_instance_of klass
|
240
|
+
# _(obj).wont_be_instance_of klass
|
222
241
|
#
|
223
242
|
# :method: wont_be_instance_of
|
224
243
|
|
@@ -227,7 +246,7 @@ module Minitest::Expectations
|
|
227
246
|
##
|
228
247
|
# See Minitest::Assertions#refute_kind_of
|
229
248
|
#
|
230
|
-
# obj.wont_be_kind_of mod
|
249
|
+
# _(obj).wont_be_kind_of mod
|
231
250
|
#
|
232
251
|
# :method: wont_be_kind_of
|
233
252
|
|
@@ -236,7 +255,7 @@ module Minitest::Expectations
|
|
236
255
|
##
|
237
256
|
# See Minitest::Assertions#refute_match
|
238
257
|
#
|
239
|
-
# a.wont_match b
|
258
|
+
# _(a).wont_match b
|
240
259
|
#
|
241
260
|
# :method: wont_match
|
242
261
|
|
@@ -245,7 +264,7 @@ module Minitest::Expectations
|
|
245
264
|
##
|
246
265
|
# See Minitest::Assertions#refute_nil
|
247
266
|
#
|
248
|
-
# obj.wont_be_nil
|
267
|
+
# _(obj).wont_be_nil
|
249
268
|
#
|
250
269
|
# :method: wont_be_nil
|
251
270
|
|
@@ -254,7 +273,7 @@ module Minitest::Expectations
|
|
254
273
|
##
|
255
274
|
# See Minitest::Assertions#refute_operator
|
256
275
|
#
|
257
|
-
# n.wont_be :<=, 42
|
276
|
+
# _(n).wont_be :<=, 42
|
258
277
|
#
|
259
278
|
# This can also do predicates:
|
260
279
|
#
|
@@ -267,7 +286,7 @@ module Minitest::Expectations
|
|
267
286
|
##
|
268
287
|
# See Minitest::Assertions#refute_respond_to
|
269
288
|
#
|
270
|
-
# obj.wont_respond_to msg
|
289
|
+
# _(obj).wont_respond_to msg
|
271
290
|
#
|
272
291
|
# :method: wont_respond_to
|
273
292
|
|
@@ -276,7 +295,7 @@ module Minitest::Expectations
|
|
276
295
|
##
|
277
296
|
# See Minitest::Assertions#refute_same
|
278
297
|
#
|
279
|
-
# a.wont_be_same_as b
|
298
|
+
# _(a).wont_be_same_as b
|
280
299
|
#
|
281
300
|
# :method: wont_be_same_as
|
282
301
|
|
data/lib/minitest/mock.rb
CHANGED
@@ -207,7 +207,9 @@ class Object
|
|
207
207
|
# assert obj_under_test.stale?
|
208
208
|
# end
|
209
209
|
# end
|
210
|
-
|
210
|
+
#--
|
211
|
+
# NOTE: keyword args in callables are NOT checked for correctness
|
212
|
+
# against the existing method. Too many edge cases to be worth it.
|
211
213
|
|
212
214
|
def stub name, val_or_callable, *block_args
|
213
215
|
new_name = "__minitest_stub__#{name}"
|
@@ -231,6 +233,8 @@ class Object
|
|
231
233
|
end
|
232
234
|
end
|
233
235
|
|
236
|
+
metaclass.send(:ruby2_keywords, name) if metaclass.respond_to?(:ruby2_keywords, true)
|
237
|
+
|
234
238
|
yield self
|
235
239
|
ensure
|
236
240
|
metaclass.send :undef_method, name
|
data/lib/minitest/spec.rb
CHANGED
@@ -8,12 +8,16 @@ class Module # :nodoc:
|
|
8
8
|
# warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
|
9
9
|
self.class_eval <<-EOM, __FILE__, __LINE__ + 1
|
10
10
|
def #{new_name} *args
|
11
|
+
where = Minitest.filter_backtrace(caller).first
|
12
|
+
where = where.split(/:in /, 2).first # clean up noise
|
13
|
+
warn "DEPRECATED: global use of #{new_name} from #\{where}. Use _(obj).#{new_name} instead. This will fail in Minitest 6."
|
11
14
|
Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
|
12
15
|
end
|
13
16
|
EOM
|
14
17
|
|
15
18
|
Minitest::Expectation.class_eval <<-EOM, __FILE__, __LINE__ + 1
|
16
19
|
def #{new_name} *args
|
20
|
+
raise "Calling ##{new_name} outside of test." unless ctx
|
17
21
|
case
|
18
22
|
when #{!!dont_flip} then
|
19
23
|
ctx.#{meth}(target, *args)
|
@@ -285,21 +289,28 @@ class Minitest::Spec < Minitest::Test
|
|
285
289
|
|
286
290
|
module InstanceMethods
|
287
291
|
##
|
288
|
-
#
|
289
|
-
# available to it.
|
292
|
+
# Takes a value or a block and returns a value monad that has
|
293
|
+
# all of Expectations methods available to it.
|
290
294
|
#
|
291
|
-
#
|
295
|
+
# _(1 + 1).must_equal 2
|
292
296
|
#
|
293
|
-
#
|
294
|
-
#
|
295
|
-
#
|
297
|
+
# And for blocks:
|
298
|
+
#
|
299
|
+
# _ { 1 + "1" }.must_raise TypeError
|
296
300
|
#
|
297
301
|
# This method of expectation-based testing is preferable to
|
298
302
|
# straight-expectation methods (on Object) because it stores its
|
299
303
|
# test context, bypassing our hacky use of thread-local variables.
|
300
304
|
#
|
301
|
-
# At some point, the methods on Object will be deprecated
|
302
|
-
# removed.
|
305
|
+
# NOTE: At some point, the methods on Object will be deprecated
|
306
|
+
# and then removed.
|
307
|
+
#
|
308
|
+
# It is also aliased to #value and #expect for your aesthetic
|
309
|
+
# pleasure:
|
310
|
+
#
|
311
|
+
# _(1 + 1).must_equal 2
|
312
|
+
# value(1 + 1).must_equal 2
|
313
|
+
# expect(1 + 1).must_equal 2
|
303
314
|
|
304
315
|
def _ value = nil, &block
|
305
316
|
Minitest::Expectation.new block || value, self
|
data/lib/minitest.rb
CHANGED
@@ -8,7 +8,7 @@ require "stringio"
|
|
8
8
|
# :include: README.rdoc
|
9
9
|
|
10
10
|
module Minitest
|
11
|
-
VERSION = "5.
|
11
|
+
VERSION = "5.14.4" # :nodoc:
|
12
12
|
ENCS = "".respond_to? :encoding # :nodoc:
|
13
13
|
|
14
14
|
@@installed_at_exit ||= false
|
@@ -21,7 +21,10 @@ module Minitest
|
|
21
21
|
# Parallel test executor
|
22
22
|
|
23
23
|
mc.send :attr_accessor, :parallel_executor
|
24
|
-
|
24
|
+
|
25
|
+
warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"]
|
26
|
+
n_threads = (ENV["MT_CPU"] || ENV["N"] || 2).to_i
|
27
|
+
self.parallel_executor = Parallel::Executor.new n_threads
|
25
28
|
|
26
29
|
##
|
27
30
|
# Filter object for backtraces.
|
@@ -55,7 +58,9 @@ module Minitest
|
|
55
58
|
|
56
59
|
exit_code = nil
|
57
60
|
|
61
|
+
pid = Process.pid
|
58
62
|
at_exit {
|
63
|
+
next if Process.pid != pid
|
59
64
|
@@after_run.reverse_each(&:call)
|
60
65
|
exit exit_code || false
|
61
66
|
}
|
@@ -233,7 +238,9 @@ module Minitest
|
|
233
238
|
end
|
234
239
|
|
235
240
|
def self.filter_backtrace bt # :nodoc:
|
236
|
-
backtrace_filter.filter bt
|
241
|
+
result = backtrace_filter.filter bt
|
242
|
+
result = bt.dup if result.empty?
|
243
|
+
result
|
237
244
|
end
|
238
245
|
|
239
246
|
##
|
@@ -301,7 +308,7 @@ module Minitest
|
|
301
308
|
|
302
309
|
def self.run reporter, options = {}
|
303
310
|
filter = options[:filter] || "/./"
|
304
|
-
filter = Regexp.new $1 if filter =~ %r%/(.*)/%
|
311
|
+
filter = Regexp.new $1 if filter.is_a?(String) && filter =~ %r%/(.*)/%
|
305
312
|
|
306
313
|
filtered_methods = self.runnable_methods.find_all { |m|
|
307
314
|
filter === m || filter === "#{self}##{m}"
|
@@ -422,7 +429,8 @@ module Minitest
|
|
422
429
|
|
423
430
|
##
|
424
431
|
# Returns a single character string to print based on the result
|
425
|
-
# of the run.
|
432
|
+
# of the run. One of <tt>"."</tt>, <tt>"F"</tt>,
|
433
|
+
# <tt>"E"</tt> or <tt>"S"</tt>.
|
426
434
|
|
427
435
|
def result_code
|
428
436
|
raise NotImplementedError, "subclass responsibility"
|
@@ -560,8 +568,10 @@ module Minitest
|
|
560
568
|
end
|
561
569
|
|
562
570
|
##
|
563
|
-
#
|
564
|
-
# result
|
571
|
+
# Output and record the result of the test. Call
|
572
|
+
# {result#result_code}[rdoc-ref:Runnable#result_code] to get the
|
573
|
+
# result character string. Stores the result of the run if the run
|
574
|
+
# did not pass.
|
565
575
|
|
566
576
|
def record result
|
567
577
|
end
|
@@ -628,18 +638,63 @@ module Minitest
|
|
628
638
|
#
|
629
639
|
# If you want to create an entirely different type of output (eg,
|
630
640
|
# CI, HTML, etc), this is the place to start.
|
641
|
+
#
|
642
|
+
# Example:
|
643
|
+
#
|
644
|
+
# class JenkinsCIReporter < StatisticsReporter
|
645
|
+
# def report
|
646
|
+
# super # Needed to calculate some statistics
|
647
|
+
#
|
648
|
+
# print "<testsuite "
|
649
|
+
# print "tests='#{count}' "
|
650
|
+
# print "failures='#{failures}' "
|
651
|
+
# # Remaining XML...
|
652
|
+
# end
|
653
|
+
# end
|
631
654
|
|
632
655
|
class StatisticsReporter < Reporter
|
633
|
-
|
656
|
+
##
|
657
|
+
# Total number of assertions.
|
658
|
+
|
634
659
|
attr_accessor :assertions
|
660
|
+
|
661
|
+
##
|
662
|
+
# Total number of test cases.
|
663
|
+
|
635
664
|
attr_accessor :count
|
665
|
+
|
666
|
+
##
|
667
|
+
# An +Array+ of test cases that failed or were skipped.
|
668
|
+
|
636
669
|
attr_accessor :results
|
670
|
+
|
671
|
+
##
|
672
|
+
# Time the test run started. If available, the monotonic clock is
|
673
|
+
# used and this is a +Float+, otherwise it's an instance of
|
674
|
+
# +Time+.
|
675
|
+
|
637
676
|
attr_accessor :start_time
|
677
|
+
|
678
|
+
##
|
679
|
+
# Test run time. If available, the monotonic clock is used and
|
680
|
+
# this is a +Float+, otherwise it's an instance of +Time+.
|
681
|
+
|
638
682
|
attr_accessor :total_time
|
683
|
+
|
684
|
+
##
|
685
|
+
# Total number of tests that failed.
|
686
|
+
|
639
687
|
attr_accessor :failures
|
688
|
+
|
689
|
+
##
|
690
|
+
# Total number of tests that erred.
|
691
|
+
|
640
692
|
attr_accessor :errors
|
693
|
+
|
694
|
+
##
|
695
|
+
# Total number of tests that where skipped.
|
696
|
+
|
641
697
|
attr_accessor :skips
|
642
|
-
# :startdoc:
|
643
698
|
|
644
699
|
def initialize io = $stdout, options = {} # :nodoc:
|
645
700
|
super
|
@@ -669,7 +724,10 @@ module Minitest
|
|
669
724
|
results << result if not result.passed? or result.skipped?
|
670
725
|
end
|
671
726
|
|
672
|
-
|
727
|
+
##
|
728
|
+
# Report on the tracked statistics.
|
729
|
+
|
730
|
+
def report
|
673
731
|
aggregate = results.group_by { |r| r.failure.class }
|
674
732
|
aggregate.default = [] # dumb. group_by should provide this
|
675
733
|
|
@@ -851,24 +909,21 @@ module Minitest
|
|
851
909
|
# Assertion wrapping an unexpected error that was raised during a run.
|
852
910
|
|
853
911
|
class UnexpectedError < Assertion
|
854
|
-
|
912
|
+
# TODO: figure out how to use `cause` instead
|
913
|
+
attr_accessor :error # :nodoc:
|
855
914
|
|
856
|
-
def initialize
|
915
|
+
def initialize error # :nodoc:
|
857
916
|
super "Unexpected exception"
|
858
|
-
self.
|
917
|
+
self.error = error
|
859
918
|
end
|
860
919
|
|
861
920
|
def backtrace # :nodoc:
|
862
|
-
self.
|
863
|
-
end
|
864
|
-
|
865
|
-
def error # :nodoc:
|
866
|
-
self.exception
|
921
|
+
self.error.backtrace
|
867
922
|
end
|
868
923
|
|
869
924
|
def message # :nodoc:
|
870
925
|
bt = Minitest.filter_backtrace(self.backtrace).join "\n "
|
871
|
-
"#{self.
|
926
|
+
"#{self.error.class}: #{self.error.message}\n #{bt}"
|
872
927
|
end
|
873
928
|
|
874
929
|
def result_label # :nodoc:
|
@@ -904,6 +959,9 @@ module Minitest
|
|
904
959
|
# Is this running on maglev?
|
905
960
|
|
906
961
|
def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
962
|
+
where = Minitest.filter_backtrace(caller).first
|
963
|
+
where = where.split(/:in /, 2).first # clean up noise
|
964
|
+
warn "DEPRECATED: `maglev?` called from #{where}. This will fail in Minitest 6."
|
907
965
|
"maglev" == platform
|
908
966
|
end
|
909
967
|
|
@@ -914,10 +972,20 @@ module Minitest
|
|
914
972
|
/^ruby/ =~ platform
|
915
973
|
end
|
916
974
|
|
975
|
+
##
|
976
|
+
# Is this running on macOS?
|
977
|
+
|
978
|
+
def osx? platform = RUBY_PLATFORM
|
979
|
+
/darwin/ =~ platform
|
980
|
+
end
|
981
|
+
|
917
982
|
##
|
918
983
|
# Is this running on rubinius?
|
919
984
|
|
920
985
|
def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
986
|
+
where = Minitest.filter_backtrace(caller).first
|
987
|
+
where = where.split(/:in /, 2).first # clean up noise
|
988
|
+
warn "DEPRECATED: `rubinius?` called from #{where}. This will fail in Minitest 6."
|
921
989
|
"rbx" == platform
|
922
990
|
end
|
923
991
|
|
@@ -939,12 +1007,13 @@ module Minitest
|
|
939
1007
|
MT_RE = %r%lib/minitest% #:nodoc:
|
940
1008
|
|
941
1009
|
##
|
942
|
-
# Filter +bt+ to something useful. Returns the whole thing if
|
1010
|
+
# Filter +bt+ to something useful. Returns the whole thing if
|
1011
|
+
# $DEBUG (ruby) or $MT_DEBUG (env).
|
943
1012
|
|
944
1013
|
def filter bt
|
945
1014
|
return ["No backtrace"] unless bt
|
946
1015
|
|
947
|
-
return bt.dup if $DEBUG
|
1016
|
+
return bt.dup if $DEBUG || ENV["MT_DEBUG"]
|
948
1017
|
|
949
1018
|
new_bt = bt.take_while { |line| line !~ MT_RE }
|
950
1019
|
new_bt = bt.select { |line| line !~ MT_RE } if new_bt.empty?
|
@@ -6,8 +6,27 @@ class Minitest::Test
|
|
6
6
|
def clean s
|
7
7
|
s.gsub(/^ {6}/, "")
|
8
8
|
end
|
9
|
+
|
10
|
+
def with_empty_backtrace_filter
|
11
|
+
original = Minitest.backtrace_filter
|
12
|
+
|
13
|
+
obj = Minitest::BacktraceFilter.new
|
14
|
+
def obj.filter _bt
|
15
|
+
[]
|
16
|
+
end
|
17
|
+
|
18
|
+
Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
|
19
|
+
begin
|
20
|
+
Minitest.backtrace_filter = obj
|
21
|
+
yield
|
22
|
+
ensure
|
23
|
+
Minitest.backtrace_filter = original
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
9
27
|
end
|
10
28
|
|
29
|
+
|
11
30
|
class FakeNamedTest < Minitest::Test
|
12
31
|
@@count = 0
|
13
32
|
|
@@ -19,9 +38,20 @@ class FakeNamedTest < Minitest::Test
|
|
19
38
|
end
|
20
39
|
end
|
21
40
|
|
41
|
+
module MyModule; end
|
42
|
+
class AnError < StandardError; include MyModule; end
|
43
|
+
|
22
44
|
class MetaMetaMetaTestCase < Minitest::Test
|
23
45
|
attr_accessor :reporter, :output, :tu
|
24
46
|
|
47
|
+
def with_stderr err
|
48
|
+
old = $stderr
|
49
|
+
$stderr = err
|
50
|
+
yield
|
51
|
+
ensure
|
52
|
+
$stderr = old
|
53
|
+
end
|
54
|
+
|
25
55
|
def run_tu_with_fresh_reporter flags = %w[--seed 42]
|
26
56
|
options = Minitest.process_args flags
|
27
57
|
|
@@ -31,18 +61,20 @@ class MetaMetaMetaTestCase < Minitest::Test
|
|
31
61
|
reporter << Minitest::SummaryReporter.new(@output, options)
|
32
62
|
reporter << Minitest::ProgressReporter.new(@output, options)
|
33
63
|
|
34
|
-
|
64
|
+
with_stderr @output do
|
65
|
+
reporter.start
|
35
66
|
|
36
|
-
|
67
|
+
yield(reporter) if block_given?
|
37
68
|
|
38
|
-
|
39
|
-
|
40
|
-
|
69
|
+
@tus ||= [@tu]
|
70
|
+
@tus.each do |tu|
|
71
|
+
Minitest::Runnable.runnables.delete tu
|
41
72
|
|
42
|
-
|
43
|
-
|
73
|
+
tu.run reporter, options
|
74
|
+
end
|
44
75
|
|
45
|
-
|
76
|
+
reporter.report
|
77
|
+
end
|
46
78
|
end
|
47
79
|
|
48
80
|
def first_reporter
|
@@ -81,6 +113,8 @@ class MetaMetaMetaTestCase < Minitest::Test
|
|
81
113
|
output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
|
82
114
|
end
|
83
115
|
|
116
|
+
output.gsub!(/( at )[^:]+:\d+/, '\1[FILE:LINE]')
|
117
|
+
|
84
118
|
output
|
85
119
|
end
|
86
120
|
|