minitest 5.17.0 → 5.23.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.
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require "minitest/autorun"
4
+ require_relative "metametameta"
4
5
 
5
6
  if defined? Encoding then
6
7
  e = Encoding.default_external
@@ -33,7 +34,6 @@ class TestMinitestAssertions < Minitest::Test
33
34
 
34
35
  class DummyTest
35
36
  include Minitest::Assertions
36
- # include Minitest::Reportable # TODO: why do I really need this?
37
37
 
38
38
  attr_accessor :assertions, :failure
39
39
 
@@ -58,15 +58,6 @@ class TestMinitestAssertions < Minitest::Test
58
58
  "expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}")
59
59
  end
60
60
 
61
- def assert_deprecated name
62
- dep = /DEPRECATED: #{name}. From #{__FILE__}:\d+(?::.*)?/
63
- dep = "" if $-w.nil?
64
-
65
- assert_output nil, dep do
66
- yield
67
- end
68
- end
69
-
70
61
  def assert_triggered expected, klass = Minitest::Assertion
71
62
  e = assert_raises klass do
72
63
  yield
@@ -301,7 +292,7 @@ class TestMinitestAssertions < Minitest::Test
301
292
  err_re = /Use assert_nil if expecting nil from .*test_minitest_\w+.rb/
302
293
  err_re = "" if $-w.nil?
303
294
 
304
- assert_output "", err_re do
295
+ assert_deprecation err_re do
305
296
  @tc.assert_equal nil, nil
306
297
  end
307
298
  end
@@ -379,7 +370,7 @@ class TestMinitestAssertions < Minitest::Test
379
370
  EOM
380
371
 
381
372
  assert_triggered msg do
382
- x = "bad-utf8-\xF1.txt".force_encoding "ASCII"
373
+ x = "bad-utf8-\xF1.txt".dup.force_encoding Encoding::ASCII
383
374
  y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
384
375
  @tc.assert_equal x, y
385
376
  end
@@ -762,12 +753,13 @@ class TestMinitestAssertions < Minitest::Test
762
753
  Class: <SomeError>
763
754
  Message: <\"blah\">
764
755
  ---Backtrace---
765
- FILE:LINE:in \`block in test_assert_raises_default_triggered\'
756
+ FILE:LINE:in \'block in test_assert_raises_default_triggered\'
766
757
  ---------------
767
758
  EOM
768
759
 
769
760
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
770
761
  actual.gsub!(RE_LEVELS, "") unless jruby?
762
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
771
763
 
772
764
  assert_equal expected, actual
773
765
  end
@@ -841,12 +833,13 @@ class TestMinitestAssertions < Minitest::Test
841
833
  Class: <AnError>
842
834
  Message: <\"some message\">
843
835
  ---Backtrace---
844
- FILE:LINE:in \`block in test_assert_raises_subclass_triggered\'
836
+ FILE:LINE:in \'block in test_assert_raises_subclass_triggered\'
845
837
  ---------------
846
838
  EOM
847
839
 
848
840
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
849
841
  actual.gsub!(RE_LEVELS, "") unless jruby?
842
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
850
843
 
851
844
  assert_equal expected.chomp, actual
852
845
  end
@@ -863,12 +856,13 @@ class TestMinitestAssertions < Minitest::Test
863
856
  Class: <SyntaxError>
864
857
  Message: <\"icky\">
865
858
  ---Backtrace---
866
- FILE:LINE:in \`block in test_assert_raises_triggered_different\'
859
+ FILE:LINE:in \'block in test_assert_raises_triggered_different\'
867
860
  ---------------
868
861
  EOM
869
862
 
870
863
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
871
864
  actual.gsub!(RE_LEVELS, "") unless jruby?
865
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
872
866
 
873
867
  assert_equal expected, actual
874
868
  end
@@ -886,12 +880,13 @@ class TestMinitestAssertions < Minitest::Test
886
880
  Class: <SyntaxError>
887
881
  Message: <\"icky\">
888
882
  ---Backtrace---
889
- FILE:LINE:in \`block in test_assert_raises_triggered_different_msg\'
883
+ FILE:LINE:in \'block in test_assert_raises_triggered_different_msg\'
890
884
  ---------------
891
885
  EOM
892
886
 
893
887
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
894
888
  actual.gsub!(RE_LEVELS, "") unless jruby?
889
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
895
890
 
896
891
  assert_equal expected.chomp, actual
897
892
  end
@@ -936,6 +931,16 @@ class TestMinitestAssertions < Minitest::Test
936
931
  end
937
932
  end
938
933
 
934
+ def test_assert_respond_to__include_all
935
+ @tc.assert_respond_to @tc, :exit, include_all: true
936
+ end
937
+
938
+ def test_assert_respond_to__include_all_triggered
939
+ assert_triggered(/Expected .+::DummyTest. to respond to #exit\?/) do
940
+ @tc.assert_respond_to @tc, :exit?, include_all: true
941
+ end
942
+ end
943
+
939
944
  def test_assert_same
940
945
  @assertion_count = 3
941
946
 
@@ -961,16 +966,24 @@ class TestMinitestAssertions < Minitest::Test
961
966
  end
962
967
 
963
968
  def test_assert_send
964
- assert_deprecated :assert_send do
969
+ @assertion_count = 0 if error_on_warn?
970
+ assert_deprecation(/DEPRECATED: assert_send/) do
965
971
  @tc.assert_send [1, :<, 2]
966
972
  end
967
973
  end
968
974
 
969
975
  def test_assert_send_bad
970
- assert_deprecated :assert_send do
971
- assert_triggered "Expected 1.>(*[2]) to return true." do
976
+ if error_on_warn? then
977
+ @assertion_count = 0
978
+ assert_deprecation(/DEPRECATED: assert_send/) do
972
979
  @tc.assert_send [1, :>, 2]
973
980
  end
981
+ else
982
+ assert_triggered "Expected 1.>(*[2]) to return true." do
983
+ assert_deprecation(/DEPRECATED: assert_send/) do
984
+ @tc.assert_send [1, :>, 2]
985
+ end
986
+ end
974
987
  end
975
988
  end
976
989
 
@@ -1062,6 +1075,66 @@ class TestMinitestAssertions < Minitest::Test
1062
1075
  end
1063
1076
  end
1064
1077
 
1078
+ def test_assert_pattern
1079
+ if RUBY_VERSION > "3" then
1080
+ @tc.assert_pattern do
1081
+ exp = if RUBY_VERSION.start_with? "3.0"
1082
+ "(eval):1: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!\n"
1083
+ else
1084
+ ""
1085
+ end
1086
+ assert_output nil, exp do
1087
+ eval "[1,2,3] => [Integer, Integer, Integer]" # eval to escape parser for ruby<3
1088
+ end
1089
+ end
1090
+ else
1091
+ @assertion_count = 0
1092
+
1093
+ assert_raises NotImplementedError do
1094
+ @tc.assert_pattern do
1095
+ # do nothing
1096
+ end
1097
+ end
1098
+ end
1099
+ end
1100
+
1101
+ def test_assert_pattern_traps_nomatchingpatternerror
1102
+ skip unless RUBY_VERSION > "3"
1103
+ exp = if RUBY_VERSION.start_with? "3.0" then
1104
+ "[1, 2, 3]" # terrible error message!
1105
+ else
1106
+ /length mismatch/
1107
+ end
1108
+
1109
+ assert_triggered exp do
1110
+ @tc.assert_pattern do
1111
+ capture_io do # 3.0 is noisy
1112
+ eval "[1,2,3] => [Integer, Integer]" # eval to escape parser for ruby<3
1113
+ end
1114
+ end
1115
+ end
1116
+ end
1117
+
1118
+ def test_assert_pattern_raises_other_exceptions
1119
+ skip unless RUBY_VERSION >= "3.0"
1120
+
1121
+ @assertion_count = 0
1122
+
1123
+ assert_raises RuntimeError do
1124
+ @tc.assert_pattern do
1125
+ raise "boom"
1126
+ end
1127
+ end
1128
+ end
1129
+
1130
+ def test_assert_pattern_with_no_block
1131
+ skip unless RUBY_VERSION >= "3.0"
1132
+
1133
+ assert_triggered "assert_pattern requires a block to capture errors." do
1134
+ @tc.assert_pattern
1135
+ end
1136
+ end
1137
+
1065
1138
  def test_capture_io
1066
1139
  @assertion_count = 0
1067
1140
 
@@ -1093,18 +1166,14 @@ class TestMinitestAssertions < Minitest::Test
1093
1166
  def test_class_asserts_match_refutes
1094
1167
  @assertion_count = 0
1095
1168
 
1096
- methods = Minitest::Assertions.public_instance_methods
1097
- methods.map!(&:to_s) if Symbol === methods.first
1169
+ methods = Minitest::Assertions.public_instance_methods.map(&:to_s)
1098
1170
 
1099
1171
  # These don't have corresponding refutes _on purpose_. They're
1100
1172
  # useless and will never be added, so don't bother.
1101
1173
  ignores = %w[assert_output assert_raises assert_send
1102
1174
  assert_silent assert_throws assert_mock]
1103
1175
 
1104
- # These are test/unit methods. I'm not actually sure why they're still here
1105
- ignores += %w[assert_no_match assert_not_equal assert_not_nil
1106
- assert_not_same assert_nothing_raised
1107
- assert_nothing_thrown assert_raise]
1176
+ ignores += %w[assert_allocations] # for minitest-gcstats
1108
1177
 
1109
1178
  asserts = methods.grep(/^assert/).sort - ignores
1110
1179
  refutes = methods.grep(/^refute/).sort - ignores
@@ -1314,6 +1383,56 @@ class TestMinitestAssertions < Minitest::Test
1314
1383
  end
1315
1384
  end
1316
1385
 
1386
+ def test_refute_pattern
1387
+ if RUBY_VERSION >= "3.0"
1388
+ @tc.refute_pattern do
1389
+ capture_io do # 3.0 is noisy
1390
+ eval "[1,2,3] => [Integer, Integer, String]"
1391
+ end
1392
+ end
1393
+ else
1394
+ @assertion_count = 0
1395
+
1396
+ assert_raises NotImplementedError do
1397
+ @tc.refute_pattern do
1398
+ eval "[1,2,3] => [Integer, Integer, String]"
1399
+ end
1400
+ end
1401
+ end
1402
+ end
1403
+
1404
+ def test_refute_pattern_expects_nomatchingpatternerror
1405
+ skip unless RUBY_VERSION > "3"
1406
+
1407
+ assert_triggered(/NoMatchingPatternError expected, but nothing was raised./) do
1408
+ @tc.refute_pattern do
1409
+ capture_io do # 3.0 is noisy
1410
+ eval "[1,2,3] => [Integer, Integer, Integer]"
1411
+ end
1412
+ end
1413
+ end
1414
+ end
1415
+
1416
+ def test_refute_pattern_raises_other_exceptions
1417
+ skip unless RUBY_VERSION >= "3.0"
1418
+
1419
+ @assertion_count = 0
1420
+
1421
+ assert_raises RuntimeError do
1422
+ @tc.refute_pattern do
1423
+ raise "boom"
1424
+ end
1425
+ end
1426
+ end
1427
+
1428
+ def test_refute_pattern_with_no_block
1429
+ skip unless RUBY_VERSION >= "3.0"
1430
+
1431
+ assert_triggered "refute_pattern requires a block to capture errors." do
1432
+ @tc.refute_pattern
1433
+ end
1434
+ end
1435
+
1317
1436
  def test_refute_predicate
1318
1437
  @tc.refute_predicate "42", :empty?
1319
1438
  end
@@ -1334,6 +1453,16 @@ class TestMinitestAssertions < Minitest::Test
1334
1453
  end
1335
1454
  end
1336
1455
 
1456
+ def test_refute_respond_to__include_all
1457
+ @tc.refute_respond_to "blah", :missing, include_all: true
1458
+ end
1459
+
1460
+ def test_refute_respond_to__include_all_triggered
1461
+ assert_triggered(/Expected .*DummyTest.* to not respond to exit./) do
1462
+ @tc.refute_respond_to @tc, :exit, include_all: true
1463
+ end
1464
+ end
1465
+
1337
1466
  def test_refute_same
1338
1467
  @tc.refute_same 1, 2
1339
1468
  end
@@ -1372,7 +1501,7 @@ class TestMinitestAssertions < Minitest::Test
1372
1501
  d0 = Time.now
1373
1502
  d1 = d0 + 86_400 # I am an idiot
1374
1503
 
1375
- assert_output "", /Stale skip_until \"not yet\" at .*?:\d+$/ do
1504
+ assert_deprecation(/Stale skip_until \"not yet\" at .*?:\d+$/) do
1376
1505
  assert_skip_until d0, "not yet"
1377
1506
  end
1378
1507
 
@@ -1516,14 +1645,14 @@ class TestMinitestAssertionHelpers < Minitest::Test
1516
1645
  end
1517
1646
 
1518
1647
  def test_mu_pp_for_diff_str_bad_encoding
1519
- str = "\666".force_encoding Encoding::UTF_8
1648
+ str = "\666".dup.force_encoding Encoding::UTF_8
1520
1649
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6\""
1521
1650
 
1522
1651
  assert_mu_pp_for_diff exp, str, :raw
1523
1652
  end
1524
1653
 
1525
1654
  def test_mu_pp_for_diff_str_bad_encoding_both
1526
- str = "\666A\\n\nB".force_encoding Encoding::UTF_8
1655
+ str = "\666A\\n\nB".dup.force_encoding Encoding::UTF_8
1527
1656
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6A\\\\n\\nB\""
1528
1657
 
1529
1658
  assert_mu_pp_for_diff exp, str, :raw
@@ -1570,7 +1699,7 @@ class TestMinitestAssertionHelpers < Minitest::Test
1570
1699
  end
1571
1700
 
1572
1701
  def test_mu_pp_str_bad_encoding
1573
- str = "\666".force_encoding Encoding::UTF_8
1702
+ str = "\666".dup.force_encoding Encoding::UTF_8
1574
1703
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6\""
1575
1704
 
1576
1705
  assert_mu_pp exp, str, :raw
@@ -423,10 +423,12 @@ class TestMinitestMock < Minitest::Test
423
423
  arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
424
424
  mock = Minitest::Mock.new
425
425
 
426
- assert_output nil, /Using MT_KWARGS_HAC. yet passing kwargs/ do
426
+ assert_deprecation(/Using MT_KWARGS_HAC. yet passing kwargs/) do
427
427
  mock.expect :foo, nil, [{}], k1: arg1, k2: arg2, k3: arg3
428
428
  end
429
429
 
430
+ skip "-Werror" if error_on_warn? # mock above raised, so this is dead
431
+
430
432
  mock.foo({}, k1: arg1, k2: arg2, k3: arg3)
431
433
 
432
434
  assert_mock mock
@@ -686,7 +688,7 @@ class TestMinitestStub < Minitest::Test
686
688
  end
687
689
 
688
690
  def test_stub_yield_self
689
- obj = "foo"
691
+ obj = +"foo"
690
692
 
691
693
  val = obj.stub :to_s, "bar" do |s|
692
694
  s.to_s
@@ -728,7 +730,7 @@ class TestMinitestStub < Minitest::Test
728
730
  end
729
731
 
730
732
  exp = jruby? ? /Undefined method nope_nope_nope for '#{self.class}::Time'/ :
731
- /undefined method `nope_nope_nope' for( class)? `#{self.class}::Time'/
733
+ /undefined method [`']nope_nope_nope' for( class)? [`']#{self.class}::Time'/
732
734
  assert_match exp, e.message
733
735
  end
734
736
 
@@ -816,7 +818,7 @@ class TestMinitestStub < Minitest::Test
816
818
  # [:value, :block_call, :args] => N/A
817
819
 
818
820
  class Bar
819
- def call
821
+ def call(&_) # to ignore unused block
820
822
  puts "hi"
821
823
  end
822
824
  end
@@ -956,7 +958,7 @@ class TestMinitestStub < Minitest::Test
956
958
  def test_stub_lambda_block_call_5
957
959
  @assertion_count += 1
958
960
  rs = nil
959
- io = StringIO.new "", "w"
961
+ io = StringIO.new(+"", "w")
960
962
  File.stub5 :open, lambda { |p, m, &blk| blk and blk.call io } do
961
963
  File.open "foo.txt", "r" do |f|
962
964
  rs = f && f.write("woot")
@@ -971,7 +973,7 @@ class TestMinitestStub < Minitest::Test
971
973
 
972
974
  @assertion_count += 1
973
975
  rs = nil
974
- io = StringIO.new "", "w"
976
+ io = StringIO.new(+"", "w")
975
977
  File.stub6 :open, lambda { |p, m, &blk| blk.call io } do
976
978
  File.open "foo.txt", "r" do |f|
977
979
  rs = f.write("woot")
@@ -984,7 +986,7 @@ class TestMinitestStub < Minitest::Test
984
986
  def test_stub_lambda_block_call_args_5
985
987
  @assertion_count += 1
986
988
  rs = nil
987
- io = StringIO.new "", "w"
989
+ io = StringIO.new(+"", "w")
988
990
  File.stub5(:open, lambda { |p, m, &blk| blk and blk.call io }, :WTF?) do
989
991
  File.open "foo.txt", "r" do |f|
990
992
  rs = f.write("woot")
@@ -999,7 +1001,7 @@ class TestMinitestStub < Minitest::Test
999
1001
 
1000
1002
  @assertion_count += 1
1001
1003
  rs = nil
1002
- io = StringIO.new "", "w"
1004
+ io = StringIO.new(+"", "w")
1003
1005
  File.stub6(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
1004
1006
  File.open "foo.txt", "r" do |f|
1005
1007
  rs = f.write("woot")
@@ -1014,7 +1016,7 @@ class TestMinitestStub < Minitest::Test
1014
1016
 
1015
1017
  @assertion_count += 2
1016
1018
  rs = nil
1017
- io = StringIO.new "", "w"
1019
+ io = StringIO.new(+"", "w")
1018
1020
  @tc.assert_raises ArgumentError do
1019
1021
  File.stub6_2(:open, lambda { |p, m, &blk| blk.call io }, :WTF?) do
1020
1022
  File.open "foo.txt", "r" do |f|
@@ -1064,7 +1066,7 @@ class TestMinitestStub < Minitest::Test
1064
1066
  def test_stub_value_block_args_5
1065
1067
  @assertion_count += 2
1066
1068
  rs = nil
1067
- io = StringIO.new "", "w"
1069
+ io = StringIO.new(+"", "w")
1068
1070
  File.stub5 :open, :value, io do
1069
1071
  result = File.open "foo.txt", "r" do |f|
1070
1072
  rs = f.write("woot")
@@ -1083,7 +1085,7 @@ class TestMinitestStub < Minitest::Test
1083
1085
  end
1084
1086
  end
1085
1087
  end
1086
- exp = "undefined method `write' for nil:NilClass"
1088
+ exp = /undefined method [`']write' for nil/
1087
1089
  assert_match exp, e.message
1088
1090
  end
1089
1091
 
@@ -1092,7 +1094,7 @@ class TestMinitestStub < Minitest::Test
1092
1094
 
1093
1095
  @assertion_count += 2
1094
1096
  rs = nil
1095
- io = StringIO.new "", "w"
1097
+ io = StringIO.new(+"", "w")
1096
1098
  assert_deprecated do
1097
1099
  File.stub6 :open, :value, io do
1098
1100
  result = File.open "foo.txt", "r" do |f|
@@ -1110,7 +1112,7 @@ class TestMinitestStub < Minitest::Test
1110
1112
 
1111
1113
  @assertion_count += 2
1112
1114
  rs = nil
1113
- io = StringIO.new "", "w"
1115
+ io = StringIO.new(+"", "w")
1114
1116
  @tc.assert_raises ArgumentError do
1115
1117
  File.stub6_2 :open, :value, io do
1116
1118
  result = File.open "foo.txt", "r" do |f|
@@ -31,7 +31,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
31
31
 
32
32
  def setup
33
33
  super
34
- self.io = StringIO.new("")
34
+ self.io = StringIO.new(+"")
35
35
  self.r = new_composite_reporter
36
36
  end
37
37
 
@@ -48,6 +48,25 @@ class TestMinitestReporter < MetaMetaMetaTestCase
48
48
  @et
49
49
  end
50
50
 
51
+ def system_stack_error_test
52
+ unless defined? @sse then
53
+
54
+ ex = SystemStackError.new
55
+
56
+ pre = ("a".."c").to_a
57
+ mid = ("aa".."ad").to_a * 67
58
+ post = ("d".."f").to_a
59
+ ary = pre + mid + post
60
+
61
+ ex.set_backtrace ary
62
+
63
+ @sse = Minitest::Test.new(:woot)
64
+ @sse.failures << Minitest::UnexpectedError.new(ex)
65
+ @sse = Minitest::Result.from @sse
66
+ end
67
+ @sse
68
+ end
69
+
51
70
  def fail_test
52
71
  unless defined? @ft then
53
72
  @ft = Minitest::Test.new(:woot)
@@ -65,6 +84,12 @@ class TestMinitestReporter < MetaMetaMetaTestCase
65
84
  @pt ||= Minitest::Result.from Minitest::Test.new(:woot)
66
85
  end
67
86
 
87
+ def passing_test_with_metadata
88
+ test = Minitest::Test.new(:woot)
89
+ test.metadata[:meta] = :data
90
+ @pt ||= Minitest::Result.from test
91
+ end
92
+
68
93
  def skip_test
69
94
  unless defined? @st then
70
95
  @st = Minitest::Test.new(:woot)
@@ -166,6 +191,29 @@ class TestMinitestReporter < MetaMetaMetaTestCase
166
191
  assert_equal 0, r.assertions
167
192
  end
168
193
 
194
+ def test_record_pass_with_metadata
195
+ reporter = self.r
196
+
197
+ def reporter.metadata
198
+ @metadata
199
+ end
200
+
201
+ def reporter.record result
202
+ super
203
+ @metadata = result.metadata if result.metadata?
204
+ end
205
+
206
+ r.record passing_test_with_metadata
207
+
208
+ exp = { :meta => :data }
209
+ assert_equal exp, reporter.metadata
210
+
211
+ assert_equal ".", io.string
212
+ assert_empty r.results
213
+ assert_equal 1, r.count
214
+ assert_equal 0, r.assertions
215
+ end
216
+
169
217
  def test_record_fail
170
218
  fail_test = self.fail_test
171
219
  r.record fail_test
@@ -276,8 +324,44 @@ class TestMinitestReporter < MetaMetaMetaTestCase
276
324
  1) Error:
277
325
  Minitest::Test#woot:
278
326
  RuntimeError: no
279
- FILE:LINE:in `error_test'
280
- FILE:LINE:in `test_report_error'
327
+ FILE:LINE:in 'error_test'
328
+ FILE:LINE:in 'test_report_error'
329
+
330
+ 1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
331
+ EOM
332
+
333
+ assert_equal exp, normalize_output(io.string)
334
+ end
335
+
336
+ def test_report_error__sse
337
+ r.start
338
+ r.record system_stack_error_test
339
+ r.report
340
+
341
+ exp = clean <<-EOM
342
+ Run options:
343
+
344
+ # Running:
345
+
346
+ E
347
+
348
+ Finished in 0.00
349
+
350
+ 1) Error:
351
+ Minitest::Test#woot:
352
+ SystemStackError: 274 -> 12
353
+ a
354
+ b
355
+ c
356
+ +->> 67 cycles of 4 lines:
357
+ | aa
358
+ | ab
359
+ | ac
360
+ | ad
361
+ +-<<
362
+ d
363
+ e
364
+ f
281
365
 
282
366
  1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
283
367
  EOM
@@ -309,4 +393,48 @@ class TestMinitestReporter < MetaMetaMetaTestCase
309
393
 
310
394
  assert_equal exp, normalize_output(io.string)
311
395
  end
396
+
397
+ def test_report_failure_uses_backtrace_filter
398
+ filter = Minitest::BacktraceFilter.new
399
+ def filter.filter _bt
400
+ ["foo.rb:123:in 'foo'"]
401
+ end
402
+
403
+ with_backtrace_filter filter do
404
+ r.start
405
+ r.record fail_test
406
+ r.report
407
+ end
408
+
409
+ exp = "Minitest::Test#woot [foo.rb:123]"
410
+
411
+ assert_includes io.string, exp
412
+ end
413
+
414
+ def test_report_failure_uses_backtrace_filter_complex_sorbet
415
+ backtrace = <<~EOBT
416
+ /Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/assertions.rb:183:in 'assert'
417
+ example_test.rb:9:in 'assert_false'
418
+ /Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'bind_call'
419
+ /Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'validate_call'
420
+ /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'
421
+ example_test.rb:25:in 'test_something'
422
+ /Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:94:in 'block (3 levels) in run'
423
+ /Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:191:in 'capture_exceptions'
424
+ /Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:89:in 'block (2 levels) in run'
425
+ ... so many lines ...
426
+ EOBT
427
+
428
+ filter = Minitest::BacktraceFilter.new %r%lib/minitest|gems/sorbet%
429
+
430
+ with_backtrace_filter filter do
431
+ begin
432
+ assert_equal 1, 2
433
+ rescue Minitest::Assertion => e
434
+ e.set_backtrace backtrace.lines.map(&:chomp)
435
+
436
+ assert_match "example_test.rb:25", e.location
437
+ end
438
+ end
439
+ end
312
440
  end