minitest 5.11.3 → 5.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +426 -4
- data/Manifest.txt +6 -0
- data/README.rdoc +119 -20
- data/Rakefile +28 -17
- data/design_rationale.rb +21 -19
- data/lib/hoe/minitest.rb +4 -6
- data/lib/minitest/assertions.rb +257 -100
- data/lib/minitest/autorun.rb +4 -11
- data/lib/minitest/benchmark.rb +15 -18
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/expectations.rb +72 -35
- data/lib/minitest/hell.rb +1 -1
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +131 -44
- data/lib/minitest/parallel.rb +7 -5
- data/lib/minitest/pride.rb +1 -1
- data/lib/minitest/pride_plugin.rb +18 -25
- data/lib/minitest/spec.rb +47 -25
- data/lib/minitest/test.rb +54 -36
- data/lib/minitest/test_task.rb +324 -0
- data/lib/minitest/unit.rb +6 -9
- data/lib/minitest.rb +443 -180
- data/test/minitest/metametameta.rb +65 -17
- data/test/minitest/test_minitest_assertions.rb +1677 -0
- data/test/minitest/test_minitest_benchmark.rb +3 -3
- data/test/minitest/test_minitest_mock.rb +405 -66
- data/test/minitest/test_minitest_reporter.rb +174 -36
- data/test/minitest/test_minitest_spec.rb +368 -196
- data/test/minitest/test_minitest_test.rb +476 -1244
- data/test/minitest/test_minitest_test_task.rb +57 -0
- data.tar.gz.sig +0 -0
- metadata +50 -23
- metadata.gz.sig +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
require "minitest/autorun"
|
|
2
|
-
|
|
2
|
+
require_relative "metametameta"
|
|
3
|
+
require "forwardable"
|
|
3
4
|
|
|
4
|
-
class
|
|
5
|
+
class FakeTest < Minitest::Test
|
|
5
6
|
def woot
|
|
6
7
|
assert true
|
|
7
8
|
end
|
|
@@ -16,33 +17,24 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
16
17
|
reporter << Minitest::SummaryReporter.new(self.io)
|
|
17
18
|
reporter << Minitest::ProgressReporter.new(self.io)
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def reporter.results
|
|
24
|
-
first.results
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def reporter.count
|
|
28
|
-
first.count
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def reporter.assertions
|
|
32
|
-
first.assertions
|
|
33
|
-
end
|
|
20
|
+
# eg reporter.results -> reporters.first.results
|
|
21
|
+
reporter.extend Forwardable
|
|
22
|
+
reporter.delegate :first => :reporters
|
|
23
|
+
reporter.delegate %i[results count assertions options to_s] => :first
|
|
34
24
|
|
|
35
25
|
reporter
|
|
36
26
|
end
|
|
37
27
|
|
|
38
28
|
def setup
|
|
39
|
-
|
|
29
|
+
super
|
|
30
|
+
self.io = StringIO.new(+"")
|
|
40
31
|
self.r = new_composite_reporter
|
|
32
|
+
@et = @ft = @pt = @st = @sse = nil
|
|
41
33
|
end
|
|
42
34
|
|
|
43
35
|
def error_test
|
|
44
|
-
unless
|
|
45
|
-
@et =
|
|
36
|
+
unless @et then
|
|
37
|
+
@et = FakeTest.new :woot
|
|
46
38
|
@et.failures << Minitest::UnexpectedError.new(begin
|
|
47
39
|
raise "no"
|
|
48
40
|
rescue => e
|
|
@@ -53,9 +45,28 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
53
45
|
@et
|
|
54
46
|
end
|
|
55
47
|
|
|
48
|
+
def system_stack_error_test
|
|
49
|
+
unless @sse then
|
|
50
|
+
|
|
51
|
+
ex = SystemStackError.new
|
|
52
|
+
|
|
53
|
+
pre = ("a".."c").to_a
|
|
54
|
+
mid = ("aa".."ad").to_a * 67
|
|
55
|
+
post = ("d".."f").to_a
|
|
56
|
+
ary = pre + mid + post
|
|
57
|
+
|
|
58
|
+
ex.set_backtrace ary
|
|
59
|
+
|
|
60
|
+
@sse = FakeTest.new :woot
|
|
61
|
+
@sse.failures << Minitest::UnexpectedError.new(ex)
|
|
62
|
+
@sse = Minitest::Result.from @sse
|
|
63
|
+
end
|
|
64
|
+
@sse
|
|
65
|
+
end
|
|
66
|
+
|
|
56
67
|
def fail_test
|
|
57
|
-
unless
|
|
58
|
-
@ft =
|
|
68
|
+
unless @ft then
|
|
69
|
+
@ft = FakeTest.new :woot
|
|
59
70
|
@ft.failures << begin
|
|
60
71
|
raise Minitest::Assertion, "boo"
|
|
61
72
|
rescue Minitest::Assertion => e
|
|
@@ -67,12 +78,18 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
67
78
|
end
|
|
68
79
|
|
|
69
80
|
def passing_test
|
|
70
|
-
@pt ||= Minitest::Result.from
|
|
81
|
+
@pt ||= Minitest::Result.from FakeTest.new(:woot)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def passing_test_with_metadata
|
|
85
|
+
test = FakeTest.new :woot
|
|
86
|
+
test.metadata[:meta] = :data
|
|
87
|
+
@pt ||= Minitest::Result.from test
|
|
71
88
|
end
|
|
72
89
|
|
|
73
90
|
def skip_test
|
|
74
|
-
unless
|
|
75
|
-
@st =
|
|
91
|
+
unless @st then
|
|
92
|
+
@st = FakeTest.new :woot
|
|
76
93
|
@st.failures << begin
|
|
77
94
|
raise Minitest::Skip
|
|
78
95
|
rescue Minitest::Assertion => e
|
|
@@ -86,7 +103,25 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
86
103
|
def test_to_s
|
|
87
104
|
r.record passing_test
|
|
88
105
|
r.record fail_test
|
|
89
|
-
assert_match "woot", r.
|
|
106
|
+
assert_match "woot", r.to_s
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_options_skip_F
|
|
110
|
+
r.options[:skip] = "F"
|
|
111
|
+
|
|
112
|
+
r.record passing_test
|
|
113
|
+
r.record fail_test
|
|
114
|
+
|
|
115
|
+
refute_match "woot", r.to_s
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_options_skip_E
|
|
119
|
+
r.options[:skip] = "E"
|
|
120
|
+
|
|
121
|
+
r.record passing_test
|
|
122
|
+
r.record error_test
|
|
123
|
+
|
|
124
|
+
refute_match "RuntimeError: no", r.to_s
|
|
90
125
|
end
|
|
91
126
|
|
|
92
127
|
def test_passed_eh_empty
|
|
@@ -126,7 +161,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
126
161
|
end
|
|
127
162
|
|
|
128
163
|
def test_passed_eh_skipped_verbose
|
|
129
|
-
r.
|
|
164
|
+
r.options[:verbose] = true
|
|
130
165
|
|
|
131
166
|
r.start
|
|
132
167
|
r.results << skip_test
|
|
@@ -153,6 +188,29 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
153
188
|
assert_equal 0, r.assertions
|
|
154
189
|
end
|
|
155
190
|
|
|
191
|
+
def test_record_pass_with_metadata
|
|
192
|
+
reporter = self.r
|
|
193
|
+
|
|
194
|
+
def reporter.metadata
|
|
195
|
+
@metadata
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def reporter.record result
|
|
199
|
+
super
|
|
200
|
+
@metadata = result.metadata if result.metadata?
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
r.record passing_test_with_metadata
|
|
204
|
+
|
|
205
|
+
exp = { :meta => :data }
|
|
206
|
+
assert_equal exp, reporter.metadata
|
|
207
|
+
|
|
208
|
+
assert_equal ".", io.string
|
|
209
|
+
assert_empty r.results
|
|
210
|
+
assert_equal 1, r.count
|
|
211
|
+
assert_equal 0, r.assertions
|
|
212
|
+
end
|
|
213
|
+
|
|
156
214
|
def test_record_fail
|
|
157
215
|
fail_test = self.fail_test
|
|
158
216
|
r.record fail_test
|
|
@@ -187,7 +245,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
187
245
|
r.start
|
|
188
246
|
r.report
|
|
189
247
|
|
|
190
|
-
exp =
|
|
248
|
+
exp = <<~EOM
|
|
191
249
|
Run options:
|
|
192
250
|
|
|
193
251
|
# Running:
|
|
@@ -207,7 +265,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
207
265
|
r.record passing_test
|
|
208
266
|
r.report
|
|
209
267
|
|
|
210
|
-
exp =
|
|
268
|
+
exp = <<~EOM
|
|
211
269
|
Run options:
|
|
212
270
|
|
|
213
271
|
# Running:
|
|
@@ -227,7 +285,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
227
285
|
r.record fail_test
|
|
228
286
|
r.report
|
|
229
287
|
|
|
230
|
-
exp =
|
|
288
|
+
exp = <<~EOM
|
|
231
289
|
Run options:
|
|
232
290
|
|
|
233
291
|
# Running:
|
|
@@ -237,7 +295,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
237
295
|
Finished in 0.00
|
|
238
296
|
|
|
239
297
|
1) Failure:
|
|
240
|
-
|
|
298
|
+
FakeTest#woot [FILE:LINE]:
|
|
241
299
|
boo
|
|
242
300
|
|
|
243
301
|
1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
|
|
@@ -251,7 +309,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
251
309
|
r.record error_test
|
|
252
310
|
r.report
|
|
253
311
|
|
|
254
|
-
exp =
|
|
312
|
+
exp = <<~EOM
|
|
255
313
|
Run options:
|
|
256
314
|
|
|
257
315
|
# Running:
|
|
@@ -261,10 +319,46 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
261
319
|
Finished in 0.00
|
|
262
320
|
|
|
263
321
|
1) Error:
|
|
264
|
-
|
|
322
|
+
FakeTest#woot:
|
|
265
323
|
RuntimeError: no
|
|
266
|
-
FILE:LINE:in
|
|
267
|
-
FILE:LINE:in
|
|
324
|
+
FILE:LINE:in 'error_test'
|
|
325
|
+
FILE:LINE:in 'test_report_error'
|
|
326
|
+
|
|
327
|
+
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
|
|
328
|
+
EOM
|
|
329
|
+
|
|
330
|
+
assert_equal exp, normalize_output(io.string)
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def test_report_error__sse
|
|
334
|
+
r.start
|
|
335
|
+
r.record system_stack_error_test
|
|
336
|
+
r.report
|
|
337
|
+
|
|
338
|
+
exp = <<~EOM
|
|
339
|
+
Run options:
|
|
340
|
+
|
|
341
|
+
# Running:
|
|
342
|
+
|
|
343
|
+
E
|
|
344
|
+
|
|
345
|
+
Finished in 0.00
|
|
346
|
+
|
|
347
|
+
1) Error:
|
|
348
|
+
FakeTest#woot:
|
|
349
|
+
SystemStackError: 274 -> 12
|
|
350
|
+
a
|
|
351
|
+
b
|
|
352
|
+
c
|
|
353
|
+
+->> 67 cycles of 4 lines:
|
|
354
|
+
| aa
|
|
355
|
+
| ab
|
|
356
|
+
| ac
|
|
357
|
+
| ad
|
|
358
|
+
+-<<
|
|
359
|
+
d
|
|
360
|
+
e
|
|
361
|
+
f
|
|
268
362
|
|
|
269
363
|
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
|
|
270
364
|
EOM
|
|
@@ -280,7 +374,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
280
374
|
r.report
|
|
281
375
|
end
|
|
282
376
|
|
|
283
|
-
exp =
|
|
377
|
+
exp = <<~EOM
|
|
284
378
|
Run options:
|
|
285
379
|
|
|
286
380
|
# Running:
|
|
@@ -296,4 +390,48 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
296
390
|
|
|
297
391
|
assert_equal exp, normalize_output(io.string)
|
|
298
392
|
end
|
|
393
|
+
|
|
394
|
+
def test_report_failure_uses_backtrace_filter
|
|
395
|
+
filter = Minitest::BacktraceFilter.new
|
|
396
|
+
def filter.filter _bt
|
|
397
|
+
["foo.rb:123:in 'foo'"]
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
with_backtrace_filter filter do
|
|
401
|
+
r.start
|
|
402
|
+
r.record fail_test
|
|
403
|
+
r.report
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
exp = "FakeTest#woot [foo.rb:123]"
|
|
407
|
+
|
|
408
|
+
assert_includes io.string, exp
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def test_report_failure_uses_backtrace_filter_complex_sorbet
|
|
412
|
+
backtrace = <<~EOBT
|
|
413
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/assertions.rb:183:in 'assert'
|
|
414
|
+
example_test.rb:9:in 'assert_false'
|
|
415
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'bind_call'
|
|
416
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'validate_call'
|
|
417
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/_methods.rb:275:in 'block in _on_method_added'
|
|
418
|
+
example_test.rb:25:in 'test_something'
|
|
419
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:94:in 'block (3 levels) in run'
|
|
420
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:191:in 'capture_exceptions'
|
|
421
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:89:in 'block (2 levels) in run'
|
|
422
|
+
... so many lines ...
|
|
423
|
+
EOBT
|
|
424
|
+
|
|
425
|
+
filter = Minitest::BacktraceFilter.new %r%lib/minitest|gems/sorbet%
|
|
426
|
+
|
|
427
|
+
with_backtrace_filter filter do
|
|
428
|
+
begin
|
|
429
|
+
assert_equal 1, 2
|
|
430
|
+
rescue Minitest::Assertion => e
|
|
431
|
+
e.set_backtrace backtrace.lines.map(&:chomp)
|
|
432
|
+
|
|
433
|
+
assert_match "example_test.rb:25", e.location
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
end
|
|
299
437
|
end
|