minitest 5.16.2 → 6.0.5
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 +373 -1
- data/Manifest.txt +16 -4
- data/README.rdoc +48 -118
- data/Rakefile +17 -2
- data/bin/minitest +5 -0
- data/design_rationale.rb +21 -19
- data/lib/hoe/minitest.rb +4 -2
- data/lib/minitest/assertions.rb +142 -124
- data/lib/minitest/autorun.rb +3 -11
- data/lib/minitest/benchmark.rb +9 -12
- data/lib/minitest/bisect.rb +304 -0
- data/lib/minitest/complete.rb +56 -0
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/expectations.rb +18 -0
- data/lib/minitest/find_minimal_combination.rb +127 -0
- data/lib/minitest/hell.rb +1 -1
- data/lib/minitest/manual_plugins.rb +4 -0
- data/lib/minitest/parallel.rb +10 -8
- data/lib/minitest/path_expander.rb +432 -0
- data/lib/minitest/pride.rb +2 -2
- data/lib/minitest/pride_plugin.rb +17 -24
- data/lib/minitest/server.rb +49 -0
- data/lib/minitest/server_plugin.rb +88 -0
- data/lib/minitest/spec.rb +27 -46
- data/lib/minitest/sprint.rb +105 -0
- data/lib/minitest/sprint_plugin.rb +39 -0
- data/lib/minitest/test.rb +32 -52
- data/lib/minitest/test_task.rb +68 -42
- data/lib/minitest.rb +361 -215
- data/test/minitest/metametameta.rb +33 -19
- data/test/minitest/test_bisect.rb +249 -0
- data/test/minitest/test_find_minimal_combination.rb +138 -0
- data/test/minitest/test_minitest_assertions.rb +311 -173
- data/test/minitest/test_minitest_benchmark.rb +15 -1
- data/test/minitest/test_minitest_reporter.rb +148 -23
- data/test/minitest/test_minitest_spec.rb +157 -132
- data/test/minitest/test_minitest_test.rb +270 -204
- data/test/minitest/test_minitest_test_task.rb +18 -7
- data/test/minitest/test_path_expander.rb +229 -0
- data/test/minitest/test_server.rb +146 -0
- data.tar.gz.sig +2 -2
- metadata +97 -37
- metadata.gz.sig +0 -0
- data/.autotest +0 -34
- data/lib/minitest/mock.rb +0 -323
- data/lib/minitest/unit.rb +0 -42
- data/test/minitest/test_minitest_mock.rb +0 -1139
|
@@ -17,7 +17,7 @@ class TestMinitestBenchmark < Minitest::Test
|
|
|
17
17
|
def test_cls_runnable_methods
|
|
18
18
|
assert_equal [], Minitest::Benchmark.runnable_methods
|
|
19
19
|
|
|
20
|
-
c = Class.new
|
|
20
|
+
c = Class.new Minitest::Benchmark do
|
|
21
21
|
def bench_blah
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -25,6 +25,20 @@ class TestMinitestBenchmark < Minitest::Test
|
|
|
25
25
|
assert_equal ["bench_blah"], c.runnable_methods
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def test_cls_run
|
|
29
|
+
c = Class.new Minitest::Benchmark do
|
|
30
|
+
def bench_dummy
|
|
31
|
+
assert true
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
reporter = Minitest::StatisticsReporter.new(StringIO.new(+""))
|
|
36
|
+
|
|
37
|
+
c.run c, "bench_dummy", reporter
|
|
38
|
+
|
|
39
|
+
assert_equal 1, reporter.count
|
|
40
|
+
end
|
|
41
|
+
|
|
28
42
|
def test_cls_bench_range
|
|
29
43
|
assert_equal [1, 10, 100, 1_000, 10_000], Minitest::Benchmark.bench_range
|
|
30
44
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require "minitest/autorun"
|
|
2
|
-
|
|
2
|
+
require_relative "metametameta"
|
|
3
3
|
require "forwardable"
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class FakeTest < Minitest::Test
|
|
6
6
|
def woot
|
|
7
7
|
assert true
|
|
8
8
|
end
|
|
@@ -13,10 +13,6 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
13
13
|
attr_accessor :r, :io
|
|
14
14
|
|
|
15
15
|
def new_composite_reporter
|
|
16
|
-
# Ruby bug in older versions of 2.2 & 2.3 on all platforms
|
|
17
|
-
# Latest Windows builds were 2.2.6 and 2.3.3. Latest Ruby releases were
|
|
18
|
-
# 2.2.10 and 2.3.8.
|
|
19
|
-
skip if windows? && RUBY_VERSION < '2.4'
|
|
20
16
|
reporter = Minitest::CompositeReporter.new
|
|
21
17
|
reporter << Minitest::SummaryReporter.new(self.io)
|
|
22
18
|
reporter << Minitest::ProgressReporter.new(self.io)
|
|
@@ -31,13 +27,14 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
31
27
|
|
|
32
28
|
def setup
|
|
33
29
|
super
|
|
34
|
-
self.io = StringIO.new("")
|
|
30
|
+
self.io = StringIO.new(+"")
|
|
35
31
|
self.r = new_composite_reporter
|
|
32
|
+
@et = @ft = @pt = @st = @sse = nil
|
|
36
33
|
end
|
|
37
34
|
|
|
38
35
|
def error_test
|
|
39
|
-
unless
|
|
40
|
-
@et =
|
|
36
|
+
unless @et then
|
|
37
|
+
@et = FakeTest.new :woot
|
|
41
38
|
@et.failures << Minitest::UnexpectedError.new(begin
|
|
42
39
|
raise "no"
|
|
43
40
|
rescue => e
|
|
@@ -48,9 +45,28 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
48
45
|
@et
|
|
49
46
|
end
|
|
50
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
|
+
|
|
51
67
|
def fail_test
|
|
52
|
-
unless
|
|
53
|
-
@ft =
|
|
68
|
+
unless @ft then
|
|
69
|
+
@ft = FakeTest.new :woot
|
|
54
70
|
@ft.failures << begin
|
|
55
71
|
raise Minitest::Assertion, "boo"
|
|
56
72
|
rescue Minitest::Assertion => e
|
|
@@ -62,12 +78,18 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
62
78
|
end
|
|
63
79
|
|
|
64
80
|
def passing_test
|
|
65
|
-
@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
|
|
66
88
|
end
|
|
67
89
|
|
|
68
90
|
def skip_test
|
|
69
|
-
unless
|
|
70
|
-
@st =
|
|
91
|
+
unless @st then
|
|
92
|
+
@st = FakeTest.new :woot
|
|
71
93
|
@st.failures << begin
|
|
72
94
|
raise Minitest::Skip
|
|
73
95
|
rescue Minitest::Assertion => e
|
|
@@ -166,6 +188,29 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
166
188
|
assert_equal 0, r.assertions
|
|
167
189
|
end
|
|
168
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
|
+
|
|
169
214
|
def test_record_fail
|
|
170
215
|
fail_test = self.fail_test
|
|
171
216
|
r.record fail_test
|
|
@@ -200,7 +245,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
200
245
|
r.start
|
|
201
246
|
r.report
|
|
202
247
|
|
|
203
|
-
exp =
|
|
248
|
+
exp = <<~EOM
|
|
204
249
|
Run options:
|
|
205
250
|
|
|
206
251
|
# Running:
|
|
@@ -220,7 +265,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
220
265
|
r.record passing_test
|
|
221
266
|
r.report
|
|
222
267
|
|
|
223
|
-
exp =
|
|
268
|
+
exp = <<~EOM
|
|
224
269
|
Run options:
|
|
225
270
|
|
|
226
271
|
# Running:
|
|
@@ -240,7 +285,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
240
285
|
r.record fail_test
|
|
241
286
|
r.report
|
|
242
287
|
|
|
243
|
-
exp =
|
|
288
|
+
exp = <<~EOM
|
|
244
289
|
Run options:
|
|
245
290
|
|
|
246
291
|
# Running:
|
|
@@ -250,7 +295,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
250
295
|
Finished in 0.00
|
|
251
296
|
|
|
252
297
|
1) Failure:
|
|
253
|
-
|
|
298
|
+
FakeTest#woot [FILE:LINE]:
|
|
254
299
|
boo
|
|
255
300
|
|
|
256
301
|
1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
|
|
@@ -264,7 +309,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
264
309
|
r.record error_test
|
|
265
310
|
r.report
|
|
266
311
|
|
|
267
|
-
exp =
|
|
312
|
+
exp = <<~EOM
|
|
268
313
|
Run options:
|
|
269
314
|
|
|
270
315
|
# Running:
|
|
@@ -274,10 +319,46 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
274
319
|
Finished in 0.00
|
|
275
320
|
|
|
276
321
|
1) Error:
|
|
277
|
-
|
|
322
|
+
FakeTest#woot:
|
|
278
323
|
RuntimeError: no
|
|
279
|
-
FILE:LINE:in
|
|
280
|
-
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
|
|
281
362
|
|
|
282
363
|
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
|
|
283
364
|
EOM
|
|
@@ -293,7 +374,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
293
374
|
r.report
|
|
294
375
|
end
|
|
295
376
|
|
|
296
|
-
exp =
|
|
377
|
+
exp = <<~EOM
|
|
297
378
|
Run options:
|
|
298
379
|
|
|
299
380
|
# Running:
|
|
@@ -309,4 +390,48 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
309
390
|
|
|
310
391
|
assert_equal exp, normalize_output(io.string)
|
|
311
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
|
|
312
437
|
end
|