minitest 5.20.0 → 5.25.1
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 +130 -3
- data/Manifest.txt +3 -0
- data/README.rdoc +16 -13
- data/Rakefile +6 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +77 -80
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +17 -15
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +16 -23
- data/lib/minitest/spec.rb +5 -5
- data/lib/minitest/test.rb +14 -25
- data/lib/minitest/test_task.rb +17 -12
- data/lib/minitest.rb +257 -144
- data/test/minitest/metametameta.rb +32 -18
- data/test/minitest/test_minitest_assertions.rb +159 -140
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +80 -75
- data/test/minitest/test_minitest_reporter.rb +111 -16
- data/test/minitest/test_minitest_spec.rb +54 -55
- data/test/minitest/test_minitest_test.rb +191 -117
- data/test/minitest/test_minitest_test_task.rb +18 -7
- data.tar.gz.sig +0 -0
- metadata +17 -13
- metadata.gz.sig +0 -0
@@ -1,21 +1,18 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require "pathname"
|
4
1
|
require "minitest/metametameta"
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
warn ""
|
15
|
-
end
|
3
|
+
e = Encoding.default_external
|
4
|
+
if e != Encoding::UTF_8 then
|
5
|
+
warn ""
|
6
|
+
warn ""
|
7
|
+
warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
|
8
|
+
warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
|
9
|
+
warn ""
|
10
|
+
warn ""
|
16
11
|
end
|
17
12
|
|
18
13
|
class Minitest::Runnable
|
14
|
+
attr_reader :gc_stats # only needed if running w/ minitest-gcstats
|
15
|
+
|
19
16
|
def whatever # faked for testing
|
20
17
|
assert true
|
21
18
|
end
|
@@ -24,48 +21,45 @@ end
|
|
24
21
|
class TestMinitestUnit < MetaMetaMetaTestCase
|
25
22
|
parallelize_me!
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
"#{MINITEST_BASE_DIR}/test.rb:158:in `each'",
|
33
|
-
"#{MINITEST_BASE_DIR}/test.rb:139:in `run'",
|
34
|
-
"#{MINITEST_BASE_DIR}/test.rb:106:in `run'"]
|
24
|
+
MINITEST_BASE_DIR = "./lib/minitest/mini"
|
25
|
+
BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in 'each'",
|
26
|
+
"#{MINITEST_BASE_DIR}/test.rb:158:in 'each'",
|
27
|
+
"#{MINITEST_BASE_DIR}/test.rb:139:in 'run'",
|
28
|
+
"#{MINITEST_BASE_DIR}/test.rb:106:in 'run'"]
|
35
29
|
|
36
30
|
def test_filter_backtrace
|
37
31
|
# this is a semi-lame mix of relative paths.
|
38
32
|
# I cheated by making the autotest parts not have ./
|
39
|
-
bt = (["lib/autotest.rb:571:in
|
40
|
-
"test/test_autotest.rb:62:in
|
41
|
-
"#{MINITEST_BASE_DIR}/test.rb:165:in
|
33
|
+
bt = (["lib/autotest.rb:571:in 'add_exception'",
|
34
|
+
"test/test_autotest.rb:62:in 'test_add_exception'",
|
35
|
+
"#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
|
42
36
|
BT_MIDDLE +
|
43
37
|
["#{MINITEST_BASE_DIR}/test.rb:29",
|
44
38
|
"test/test_autotest.rb:422"])
|
45
39
|
bt = util_expand_bt bt
|
46
40
|
|
47
|
-
ex = ["lib/autotest.rb:571:in
|
48
|
-
"test/test_autotest.rb:62:in
|
41
|
+
ex = ["lib/autotest.rb:571:in 'add_exception'",
|
42
|
+
"test/test_autotest.rb:62:in 'test_add_exception'"]
|
49
43
|
ex = util_expand_bt ex
|
50
44
|
|
51
45
|
Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
|
52
|
-
fu = Minitest.filter_backtrace
|
46
|
+
fu = Minitest.filter_backtrace bt
|
53
47
|
|
54
48
|
assert_equal ex, fu
|
55
49
|
end
|
56
50
|
end
|
57
51
|
|
58
52
|
def test_filter_backtrace_all_unit
|
59
|
-
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in
|
53
|
+
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
|
60
54
|
BT_MIDDLE +
|
61
55
|
["#{MINITEST_BASE_DIR}/test.rb:29"])
|
62
56
|
ex = bt.clone
|
63
|
-
fu = Minitest.filter_backtrace
|
57
|
+
fu = Minitest.filter_backtrace bt
|
64
58
|
assert_equal ex, fu
|
65
59
|
end
|
66
60
|
|
67
61
|
def test_filter_backtrace_unit_starts
|
68
|
-
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in
|
62
|
+
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
|
69
63
|
BT_MIDDLE +
|
70
64
|
["#{MINITEST_BASE_DIR}/mini/test.rb:29",
|
71
65
|
"-e:1"])
|
@@ -94,24 +88,24 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
94
88
|
end
|
95
89
|
|
96
90
|
def test_this_is_non_ascii_failure_message
|
97
|
-
|
91
|
+
raise "ЁЁЁ".dup.force_encoding(Encoding::BINARY)
|
98
92
|
end
|
99
93
|
end
|
100
94
|
|
101
|
-
expected =
|
95
|
+
expected = <<~EOM
|
102
96
|
FE
|
103
97
|
|
104
98
|
Finished in 0.00
|
105
99
|
|
106
100
|
1) Failure:
|
107
101
|
FakeNamedTestXX#test_this_is_not_ascii_assertion [FILE:LINE]:
|
108
|
-
Expected:
|
109
|
-
Actual:
|
102
|
+
Expected: "ЁЁЁ"
|
103
|
+
Actual: "ёёё"
|
110
104
|
|
111
105
|
2) Error:
|
112
106
|
FakeNamedTestXX#test_this_is_non_ascii_failure_message:
|
113
107
|
RuntimeError: ЁЁЁ
|
114
|
-
FILE:LINE:in
|
108
|
+
FILE:LINE:in 'test_this_is_non_ascii_failure_message'
|
115
109
|
|
116
110
|
2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
|
117
111
|
EOM
|
@@ -164,7 +158,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
164
158
|
end
|
165
159
|
|
166
160
|
def util_expand_bt bt
|
167
|
-
bt.map { |f| (
|
161
|
+
bt.map { |f| f.start_with?(".") ? File.expand_path(f) : f }
|
168
162
|
end
|
169
163
|
end
|
170
164
|
|
@@ -208,15 +202,14 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
208
202
|
def test_class_runnables
|
209
203
|
@assertion_count = 0
|
210
204
|
|
211
|
-
tc = Class.new
|
205
|
+
tc = Class.new Minitest::Test
|
212
206
|
|
213
207
|
assert_equal 1, Minitest::Test.runnables.size
|
214
208
|
assert_equal [tc], Minitest::Test.runnables
|
215
209
|
end
|
216
210
|
|
217
211
|
def test_run_test
|
218
|
-
@tu =
|
219
|
-
Class.new FakeNamedTest do
|
212
|
+
@tu = Class.new FakeNamedTest do
|
220
213
|
attr_reader :foo
|
221
214
|
|
222
215
|
def run
|
@@ -232,7 +225,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
232
225
|
end
|
233
226
|
end
|
234
227
|
|
235
|
-
expected =
|
228
|
+
expected = <<~EOM
|
236
229
|
.
|
237
230
|
|
238
231
|
Finished in 0.00
|
@@ -244,8 +237,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
244
237
|
end
|
245
238
|
|
246
239
|
def test_run_error
|
247
|
-
@tu =
|
248
|
-
Class.new FakeNamedTest do
|
240
|
+
@tu = Class.new FakeNamedTest do
|
249
241
|
def test_something
|
250
242
|
assert true
|
251
243
|
end
|
@@ -255,7 +247,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
255
247
|
end
|
256
248
|
end
|
257
249
|
|
258
|
-
expected =
|
250
|
+
expected = <<~EOM
|
259
251
|
.E
|
260
252
|
|
261
253
|
Finished in 0.00
|
@@ -263,7 +255,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
263
255
|
1) Error:
|
264
256
|
FakeNamedTestXX#test_error:
|
265
257
|
RuntimeError: unhandled exception
|
266
|
-
FILE:LINE:in
|
258
|
+
FILE:LINE:in 'test_error'
|
267
259
|
|
268
260
|
2 runs, 1 assertions, 0 failures, 1 errors, 0 skips
|
269
261
|
EOM
|
@@ -272,8 +264,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
272
264
|
end
|
273
265
|
|
274
266
|
def test_run_error_teardown
|
275
|
-
@tu =
|
276
|
-
Class.new FakeNamedTest do
|
267
|
+
@tu = Class.new FakeNamedTest do
|
277
268
|
def test_something
|
278
269
|
assert true
|
279
270
|
end
|
@@ -283,7 +274,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
283
274
|
end
|
284
275
|
end
|
285
276
|
|
286
|
-
expected =
|
277
|
+
expected = <<~EOM
|
287
278
|
E
|
288
279
|
|
289
280
|
Finished in 0.00
|
@@ -291,7 +282,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
291
282
|
1) Error:
|
292
283
|
FakeNamedTestXX#test_something:
|
293
284
|
RuntimeError: unhandled exception
|
294
|
-
FILE:LINE:in
|
285
|
+
FILE:LINE:in 'teardown'
|
295
286
|
|
296
287
|
1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
|
297
288
|
EOM
|
@@ -302,7 +293,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
302
293
|
def test_run_failing
|
303
294
|
setup_basic_tu
|
304
295
|
|
305
|
-
expected =
|
296
|
+
expected = <<~EOM
|
306
297
|
.F
|
307
298
|
|
308
299
|
Finished in 0.00
|
@@ -318,8 +309,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
318
309
|
end
|
319
310
|
|
320
311
|
def setup_basic_tu
|
321
|
-
@tu =
|
322
|
-
Class.new FakeNamedTest do
|
312
|
+
@tu = Class.new FakeNamedTest do
|
323
313
|
def test_something
|
324
314
|
assert true
|
325
315
|
end
|
@@ -337,7 +327,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
337
327
|
def test_run_failing_filtered
|
338
328
|
setup_basic_tu
|
339
329
|
|
340
|
-
expected =
|
330
|
+
expected = <<~EOM
|
341
331
|
.
|
342
332
|
|
343
333
|
Finished in 0.00
|
@@ -356,14 +346,14 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
356
346
|
assert a
|
357
347
|
end
|
358
348
|
end
|
359
|
-
Object.const_set
|
349
|
+
Object.const_set :Alpha, alpha
|
360
350
|
|
361
351
|
beta = Class.new FakeNamedTest do
|
362
352
|
define_method :test_something do
|
363
353
|
assert true
|
364
354
|
end
|
365
355
|
end
|
366
|
-
Object.const_set
|
356
|
+
Object.const_set :Beta, beta
|
367
357
|
|
368
358
|
@tus = [alpha, beta]
|
369
359
|
|
@@ -374,7 +364,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
374
364
|
end
|
375
365
|
|
376
366
|
def test_run_filtered_including_suite_name
|
377
|
-
expected =
|
367
|
+
expected = <<~EOM
|
378
368
|
.
|
379
369
|
|
380
370
|
Finished in 0.00
|
@@ -386,7 +376,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
386
376
|
end
|
387
377
|
|
388
378
|
def test_run_filtered_including_suite_name_string
|
389
|
-
expected =
|
379
|
+
expected = <<~EOM
|
390
380
|
.
|
391
381
|
|
392
382
|
Finished in 0.00
|
@@ -398,7 +388,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
398
388
|
end
|
399
389
|
|
400
390
|
def test_run_filtered_string_method_only
|
401
|
-
expected =
|
391
|
+
expected = <<~EOM
|
402
392
|
..
|
403
393
|
|
404
394
|
Finished in 0.00
|
@@ -412,7 +402,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
412
402
|
def test_run_failing_excluded
|
413
403
|
setup_basic_tu
|
414
404
|
|
415
|
-
expected =
|
405
|
+
expected = <<~EOM
|
416
406
|
.
|
417
407
|
|
418
408
|
Finished in 0.00
|
@@ -424,7 +414,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
424
414
|
end
|
425
415
|
|
426
416
|
def test_run_filtered_excluding_suite_name
|
427
|
-
expected =
|
417
|
+
expected = <<~EOM
|
428
418
|
.
|
429
419
|
|
430
420
|
Finished in 0.00
|
@@ -436,7 +426,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
436
426
|
end
|
437
427
|
|
438
428
|
def test_run_filtered_excluding_suite_name_string
|
439
|
-
expected =
|
429
|
+
expected = <<~EOM
|
440
430
|
.
|
441
431
|
|
442
432
|
Finished in 0.00
|
@@ -448,7 +438,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
448
438
|
end
|
449
439
|
|
450
440
|
def test_run_filtered_excluding_string_method_only
|
451
|
-
expected =
|
441
|
+
expected = <<~EOM
|
452
442
|
|
453
443
|
|
454
444
|
Finished in 0.00
|
@@ -460,14 +450,13 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
460
450
|
end
|
461
451
|
|
462
452
|
def test_run_passing
|
463
|
-
@tu =
|
464
|
-
Class.new FakeNamedTest do
|
453
|
+
@tu = Class.new FakeNamedTest do
|
465
454
|
def test_something
|
466
455
|
assert true
|
467
456
|
end
|
468
457
|
end
|
469
458
|
|
470
|
-
expected =
|
459
|
+
expected = <<~EOM
|
471
460
|
.
|
472
461
|
|
473
462
|
Finished in 0.00
|
@@ -479,8 +468,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
479
468
|
end
|
480
469
|
|
481
470
|
def test_run_skip
|
482
|
-
@tu =
|
483
|
-
Class.new FakeNamedTest do
|
471
|
+
@tu = Class.new FakeNamedTest do
|
484
472
|
def test_something
|
485
473
|
assert true
|
486
474
|
end
|
@@ -490,7 +478,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
490
478
|
end
|
491
479
|
end
|
492
480
|
|
493
|
-
expected =
|
481
|
+
expected = <<~EOM
|
494
482
|
.S
|
495
483
|
|
496
484
|
Finished in 0.00
|
@@ -506,8 +494,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
506
494
|
end
|
507
495
|
|
508
496
|
def test_run_skip_verbose
|
509
|
-
@tu =
|
510
|
-
Class.new FakeNamedTest do
|
497
|
+
@tu = Class.new FakeNamedTest do
|
511
498
|
def test_something
|
512
499
|
assert true
|
513
500
|
end
|
@@ -517,7 +504,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
517
504
|
end
|
518
505
|
end
|
519
506
|
|
520
|
-
expected =
|
507
|
+
expected = <<~EOM
|
521
508
|
FakeNamedTestXX#test_something = 0.00 s = .
|
522
509
|
FakeNamedTestXX#test_skip = 0.00 s = S
|
523
510
|
|
@@ -534,8 +521,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
534
521
|
end
|
535
522
|
|
536
523
|
def test_run_skip_show_skips
|
537
|
-
@tu =
|
538
|
-
Class.new FakeNamedTest do
|
524
|
+
@tu = Class.new FakeNamedTest do
|
539
525
|
def test_something
|
540
526
|
assert true
|
541
527
|
end
|
@@ -545,7 +531,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
545
531
|
end
|
546
532
|
end
|
547
533
|
|
548
|
-
expected =
|
534
|
+
expected = <<~EOM
|
549
535
|
.S
|
550
536
|
|
551
537
|
Finished in 0.00
|
@@ -561,8 +547,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
561
547
|
end
|
562
548
|
|
563
549
|
def test_run_with_other_runner
|
564
|
-
@tu =
|
565
|
-
Class.new FakeNamedTest do
|
550
|
+
@tu = Class.new FakeNamedTest do
|
566
551
|
def self.run reporter, options = {}
|
567
552
|
@reporter = reporter
|
568
553
|
before_my_suite
|
@@ -585,7 +570,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
585
570
|
end
|
586
571
|
end
|
587
572
|
|
588
|
-
expected =
|
573
|
+
expected = <<~EOM
|
589
574
|
Running wacky! tests
|
590
575
|
..
|
591
576
|
|
@@ -634,8 +619,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
634
619
|
main_latch.release
|
635
620
|
}
|
636
621
|
|
637
|
-
@tu =
|
638
|
-
Class.new FakeNamedTest do
|
622
|
+
@tu = Class.new FakeNamedTest do
|
639
623
|
parallelize_me!
|
640
624
|
|
641
625
|
test_count.times do |i|
|
@@ -652,7 +636,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
652
636
|
end
|
653
637
|
end
|
654
638
|
|
655
|
-
expected =
|
639
|
+
expected = <<~EOM
|
656
640
|
..
|
657
641
|
|
658
642
|
Finished in 0.00
|
@@ -662,18 +646,18 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
662
646
|
|
663
647
|
skip if Minitest.parallel_executor.size < 2 # locks up test runner if 1 CPU
|
664
648
|
|
665
|
-
assert_report
|
666
|
-
reporter.extend
|
667
|
-
define_method
|
649
|
+
assert_report expected do |reporter|
|
650
|
+
reporter.extend Module.new {
|
651
|
+
define_method :record do |result|
|
668
652
|
super(result)
|
669
653
|
wait_latch.release
|
670
654
|
end
|
671
655
|
|
672
|
-
define_method
|
656
|
+
define_method :report do
|
673
657
|
wait_latch.await
|
674
658
|
super()
|
675
659
|
end
|
676
|
-
}
|
660
|
+
}
|
677
661
|
end
|
678
662
|
assert thread.join
|
679
663
|
end
|
@@ -684,8 +668,8 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
|
|
684
668
|
|
685
669
|
def test_before_setup
|
686
670
|
call_order = []
|
687
|
-
|
688
|
-
Class.new FakeNamedTest do
|
671
|
+
|
672
|
+
@tu = Class.new FakeNamedTest do
|
689
673
|
define_method :setup do
|
690
674
|
super()
|
691
675
|
call_order << :setup
|
@@ -700,14 +684,13 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
|
|
700
684
|
|
701
685
|
run_tu_with_fresh_reporter
|
702
686
|
|
703
|
-
expected = [
|
687
|
+
expected = %i[before_setup setup]
|
704
688
|
assert_equal expected, call_order
|
705
689
|
end
|
706
690
|
|
707
691
|
def test_after_teardown
|
708
692
|
call_order = []
|
709
|
-
@tu =
|
710
|
-
Class.new FakeNamedTest do
|
693
|
+
@tu = Class.new FakeNamedTest do
|
711
694
|
define_method :teardown do
|
712
695
|
super()
|
713
696
|
call_order << :teardown
|
@@ -722,14 +705,14 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
|
|
722
705
|
|
723
706
|
run_tu_with_fresh_reporter
|
724
707
|
|
725
|
-
expected = [
|
708
|
+
expected = %i[teardown after_teardown]
|
726
709
|
assert_equal expected, call_order
|
727
710
|
end
|
728
711
|
|
729
712
|
def test_all_teardowns_are_guaranteed_to_run
|
730
713
|
call_order = []
|
731
|
-
|
732
|
-
Class.new FakeNamedTest do
|
714
|
+
|
715
|
+
@tu = Class.new FakeNamedTest do
|
733
716
|
define_method :after_teardown do
|
734
717
|
super()
|
735
718
|
call_order << :after_teardown
|
@@ -753,7 +736,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
|
|
753
736
|
|
754
737
|
run_tu_with_fresh_reporter
|
755
738
|
|
756
|
-
expected = [
|
739
|
+
expected = %i[before_teardown teardown after_teardown]
|
757
740
|
assert_equal expected, call_order
|
758
741
|
end
|
759
742
|
|
@@ -780,7 +763,7 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
|
|
780
763
|
run_tu_with_fresh_reporter
|
781
764
|
|
782
765
|
# Once for the parent class, once for the child
|
783
|
-
expected = [
|
766
|
+
expected = %i[setup_method test teardown_method] * 2
|
784
767
|
|
785
768
|
assert_equal expected, call_order
|
786
769
|
end
|
@@ -813,6 +796,7 @@ class TestMinitestRunnable < Minitest::Test
|
|
813
796
|
new_tc = Marshal.load Marshal.dump @tc
|
814
797
|
|
815
798
|
ivars = new_tc.instance_variables.map(&:to_s).sort
|
799
|
+
ivars.delete "@gc_stats" # only needed if running w/ minitest-gcstats
|
816
800
|
assert_equal expected_ivars, ivars
|
817
801
|
assert_equal "whatever", new_tc.name
|
818
802
|
assert_equal 42, new_tc.assertions
|
@@ -876,11 +860,11 @@ class TestMinitestRunnable < Minitest::Test
|
|
876
860
|
end
|
877
861
|
|
878
862
|
def test_spec_marshal_with_exception_nameerror
|
879
|
-
klass = describe
|
880
|
-
it
|
863
|
+
klass = describe "whatever" do
|
864
|
+
it "raises NameError" do
|
881
865
|
NOPE::does_not_exist
|
882
|
-
|
883
|
-
|
866
|
+
end
|
867
|
+
end
|
884
868
|
|
885
869
|
rm = klass.runnable_methods.first
|
886
870
|
|
@@ -944,10 +928,9 @@ class TestMinitestRunnable < Minitest::Test
|
|
944
928
|
end
|
945
929
|
|
946
930
|
def test_spec_marshal_with_exception__worse_error_typeerror
|
947
|
-
worse_error_klass = Class.new
|
948
|
-
# problem #1: anonymous subclass can'
|
949
|
-
def initialize
|
950
|
-
|
931
|
+
worse_error_klass = Class.new StandardError do
|
932
|
+
# problem #1: anonymous subclass can't marshal, fails sanitize_exception
|
933
|
+
def initialize record = nil
|
951
934
|
super(record.first)
|
952
935
|
end
|
953
936
|
end
|
@@ -1004,8 +987,6 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1004
987
|
# which is not threadsafe. Nearly every method in here is an
|
1005
988
|
# assertion test so it isn't worth splitting it out further.
|
1006
989
|
|
1007
|
-
RUBY18 = !defined? Encoding
|
1008
|
-
|
1009
990
|
def setup
|
1010
991
|
super
|
1011
992
|
|
@@ -1030,7 +1011,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1030
1011
|
$VERBOSE = orig_verbose
|
1031
1012
|
end
|
1032
1013
|
|
1033
|
-
def sample_test_case
|
1014
|
+
def sample_test_case rand
|
1034
1015
|
srand rand
|
1035
1016
|
Class.new FakeNamedTest do
|
1036
1017
|
100.times do |i|
|
@@ -1089,21 +1070,21 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1089
1070
|
|
1090
1071
|
def test_autorun_does_not_affect_fork_success_status
|
1091
1072
|
@assertion_count = 0
|
1092
|
-
skip "windows doesn't have fork" unless Process.respond_to?
|
1073
|
+
skip "windows doesn't have fork" unless Process.respond_to? :fork
|
1093
1074
|
Process.waitpid(fork {})
|
1094
1075
|
assert_equal true, $?.success?
|
1095
1076
|
end
|
1096
1077
|
|
1097
1078
|
def test_autorun_does_not_affect_fork_exit_status
|
1098
1079
|
@assertion_count = 0
|
1099
|
-
skip "windows doesn't have fork" unless Process.respond_to?
|
1080
|
+
skip "windows doesn't have fork" unless Process.respond_to? :fork
|
1100
1081
|
Process.waitpid(fork { exit 42 })
|
1101
1082
|
assert_equal 42, $?.exitstatus
|
1102
1083
|
end
|
1103
1084
|
|
1104
1085
|
def test_autorun_optionally_can_affect_fork_exit_status
|
1105
1086
|
@assertion_count = 0
|
1106
|
-
skip "windows doesn't have fork" unless Process.respond_to?
|
1087
|
+
skip "windows doesn't have fork" unless Process.respond_to? :fork
|
1107
1088
|
Minitest.allow_fork = true
|
1108
1089
|
Process.waitpid(fork { exit 42 })
|
1109
1090
|
refute_equal 42, $?.exitstatus
|
@@ -1126,19 +1107,19 @@ class TestMinitestGuard < Minitest::Test
|
|
1126
1107
|
end
|
1127
1108
|
|
1128
1109
|
def test_rubinius_eh
|
1129
|
-
|
1110
|
+
assert_deprecation do
|
1130
1111
|
assert self.class.rubinius? "rbx"
|
1131
1112
|
end
|
1132
|
-
|
1113
|
+
assert_deprecation do
|
1133
1114
|
assert self.rubinius? "rbx"
|
1134
1115
|
end
|
1135
1116
|
end
|
1136
1117
|
|
1137
1118
|
def test_maglev_eh
|
1138
|
-
|
1119
|
+
assert_deprecation do
|
1139
1120
|
assert self.class.maglev? "maglev"
|
1140
1121
|
end
|
1141
|
-
|
1122
|
+
assert_deprecation do
|
1142
1123
|
assert self.maglev? "maglev"
|
1143
1124
|
end
|
1144
1125
|
end
|
@@ -1179,7 +1160,7 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
|
|
1179
1160
|
bogus_reporter = Class.new do # doesn't subclass AbstractReporter
|
1180
1161
|
def start; @success = false; end
|
1181
1162
|
# def prerecord klass, name; end # doesn't define full API
|
1182
|
-
def record
|
1163
|
+
def record _result; @success = true; end
|
1183
1164
|
def report; end
|
1184
1165
|
def passed?; end
|
1185
1166
|
def results; end
|
@@ -1257,17 +1238,17 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
|
|
1257
1238
|
|
1258
1239
|
run_tu_with_fresh_reporter
|
1259
1240
|
|
1260
|
-
exp =
|
1241
|
+
exp = <<~EOM
|
1261
1242
|
Error:
|
1262
1243
|
FakeNamedTestXX#test_method:
|
1263
1244
|
AnError: AnError
|
1264
|
-
FILE:LINE:in
|
1245
|
+
FILE:LINE:in 'test_method'
|
1265
1246
|
|
1266
1247
|
Error:
|
1267
1248
|
FakeNamedTestXX#test_method:
|
1268
1249
|
RuntimeError: unhandled exception
|
1269
|
-
FILE:LINE:in
|
1270
|
-
|
1250
|
+
FILE:LINE:in 'teardown'
|
1251
|
+
EOM
|
1271
1252
|
|
1272
1253
|
assert_equal exp.strip, normalize_output(first_reporter.results.first.to_s).strip
|
1273
1254
|
end
|
@@ -1280,3 +1261,96 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
|
|
1280
1261
|
end
|
1281
1262
|
end
|
1282
1263
|
end
|
1264
|
+
|
1265
|
+
class TestUnexpectedError < Minitest::Test
|
1266
|
+
def assert_compress exp, input
|
1267
|
+
e = Minitest::UnexpectedError.new RuntimeError.new
|
1268
|
+
|
1269
|
+
exp = exp.lines.map(&:chomp) if String === exp
|
1270
|
+
act = e.compress input
|
1271
|
+
|
1272
|
+
assert_equal exp, act
|
1273
|
+
end
|
1274
|
+
|
1275
|
+
ACT1 = %w[ a b c b c b c b c d ]
|
1276
|
+
|
1277
|
+
def test_normal
|
1278
|
+
assert_compress <<~EXP, %w[ a b c b c b c b c d ]
|
1279
|
+
a
|
1280
|
+
+->> 4 cycles of 2 lines:
|
1281
|
+
| b
|
1282
|
+
| c
|
1283
|
+
+-<<
|
1284
|
+
d
|
1285
|
+
EXP
|
1286
|
+
end
|
1287
|
+
|
1288
|
+
def test_normal2
|
1289
|
+
assert_compress <<~EXP, %w[ a b c b c b c b c ]
|
1290
|
+
a
|
1291
|
+
+->> 4 cycles of 2 lines:
|
1292
|
+
| b
|
1293
|
+
| c
|
1294
|
+
+-<<
|
1295
|
+
EXP
|
1296
|
+
end
|
1297
|
+
|
1298
|
+
def test_longer_c_than_b
|
1299
|
+
# the extra c in the front makes the overall length longer sorting it first
|
1300
|
+
assert_compress <<~EXP, %w[ c a b c b c b c b c b d ]
|
1301
|
+
c
|
1302
|
+
a
|
1303
|
+
b
|
1304
|
+
+->> 4 cycles of 2 lines:
|
1305
|
+
| c
|
1306
|
+
| b
|
1307
|
+
+-<<
|
1308
|
+
d
|
1309
|
+
EXP
|
1310
|
+
end
|
1311
|
+
|
1312
|
+
def test_1_line_cycles
|
1313
|
+
assert_compress <<~EXP, %w[ c a b c b c b c b c b b b d ]
|
1314
|
+
c
|
1315
|
+
a
|
1316
|
+
+->> 4 cycles of 2 lines:
|
1317
|
+
| b
|
1318
|
+
| c
|
1319
|
+
+-<<
|
1320
|
+
+->> 3 cycles of 1 lines:
|
1321
|
+
| b
|
1322
|
+
+-<<
|
1323
|
+
d
|
1324
|
+
EXP
|
1325
|
+
end
|
1326
|
+
|
1327
|
+
def test_sanity3
|
1328
|
+
pre = ("aa".."am").to_a
|
1329
|
+
mid = ("a".."z").to_a * 67
|
1330
|
+
post = ("aa".."am").to_a
|
1331
|
+
ary = pre + mid + post
|
1332
|
+
|
1333
|
+
exp = pre +
|
1334
|
+
[" +->> 67 cycles of 26 lines:"] +
|
1335
|
+
("a".."z").map { |s| " | #{s}" } +
|
1336
|
+
[" +-<<"] +
|
1337
|
+
post
|
1338
|
+
|
1339
|
+
assert_compress exp, ary
|
1340
|
+
end
|
1341
|
+
|
1342
|
+
def test_absurd_patterns
|
1343
|
+
assert_compress <<~EXP, %w[ a b c b c a b c b c a b c ]
|
1344
|
+
+->> 2 cycles of 5 lines:
|
1345
|
+
| a
|
1346
|
+
| +->> 2 cycles of 2 lines:
|
1347
|
+
| | b
|
1348
|
+
| | c
|
1349
|
+
| +-<<
|
1350
|
+
+-<<
|
1351
|
+
a
|
1352
|
+
b
|
1353
|
+
c
|
1354
|
+
EXP
|
1355
|
+
end
|
1356
|
+
end
|