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.
@@ -137,6 +137,46 @@ describe Minitest::Spec do
137
137
  end
138
138
  end
139
139
 
140
+ def good_pattern
141
+ capture_io do # 3.0 is noisy
142
+ eval "[1,2,3] => [Integer, Integer, Integer]" # eval to escape parser for ruby<3
143
+ end
144
+ end
145
+
146
+ def bad_pattern
147
+ capture_io do # 3.0 is noisy
148
+ eval "[1,2,3] => [Integer, Integer]" # eval to escape parser for ruby<3
149
+ end
150
+ end
151
+
152
+ it "needs to pattern match" do
153
+ @assertion_count = 1
154
+
155
+ if RUBY_VERSION > "3" then
156
+ expect { good_pattern }.must_pattern_match
157
+ else
158
+ assert_raises NotImplementedError do
159
+ expect {}.must_pattern_match
160
+ end
161
+ end
162
+ end
163
+
164
+ it "needs to error on bad pattern match" do
165
+ skip unless RUBY_VERSION > "3"
166
+
167
+ @assertion_count = 1
168
+
169
+ exp = if RUBY_VERSION.start_with? "3.0"
170
+ "[1, 2, 3]" # terrible error message!
171
+ else
172
+ /length mismatch/
173
+ end
174
+
175
+ assert_triggered exp do
176
+ expect { bad_pattern }.must_pattern_match
177
+ end
178
+ end
179
+
140
180
  it "needs to ensure silence" do
141
181
  @assertion_count -= 1 # no msg
142
182
  @assertion_count += 2 # assert_output is 2 assertions
@@ -172,6 +212,7 @@ describe Minitest::Spec do
172
212
  must_include
173
213
  must_match
174
214
  must_output
215
+ must_pattern_match
175
216
  must_raise
176
217
  must_respond_to
177
218
  must_throw
@@ -243,18 +284,14 @@ describe Minitest::Spec do
243
284
  end
244
285
 
245
286
  it "needs to warn on equality with nil" do
246
- @assertion_count += 1 # extra test
287
+ @assertion_count = 3
288
+ @assertion_count += 2 unless error_on_warn? # 2 extra assertions
289
+
290
+ exp = /DEPRECATED: Use assert_nil if expecting nil from .* This will fail in Minitest 6./
247
291
 
248
- out, err = capture_io do
292
+ assert_deprecation exp do
249
293
  assert_success _(nil).must_equal(nil)
250
294
  end
251
-
252
- exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
253
- "This will fail in Minitest 6.\n"
254
- exp = "" if $-w.nil?
255
-
256
- assert_empty out
257
- assert_equal exp, err
258
295
  end
259
296
 
260
297
  it "needs to verify floats outside a delta" do
@@ -535,7 +572,8 @@ describe Minitest::Spec do
535
572
 
536
573
  it "can NOT use must_equal in a thread. It must use expect in a thread" do
537
574
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
538
- assert_raises RuntimeError do
575
+
576
+ assert_raises RuntimeError, Minitest::UnexpectedWarning do
539
577
  capture_io do
540
578
  Thread.new { (1 + 1).must_equal 2 }.join
541
579
  end
@@ -545,9 +583,9 @@ describe Minitest::Spec do
545
583
  it "fails gracefully when expectation used outside of `it`" do
546
584
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
547
585
 
548
- @assertion_count += 1
586
+ @assertion_count += 2 # assert_match is compound
549
587
 
550
- e = assert_raises RuntimeError do
588
+ e = assert_raises RuntimeError, Minitest::UnexpectedWarning do
551
589
  capture_io do
552
590
  Thread.new { # forces ctx to be nil
553
591
  describe("woot") do
@@ -557,17 +595,21 @@ describe Minitest::Spec do
557
595
  end
558
596
  end
559
597
 
560
- assert_equal "Calling #must_equal outside of test.", e.message
598
+ exp = "Calling #must_equal outside of test."
599
+ exp = "DEPRECATED: global use of must_equal from" if error_on_warn?
600
+
601
+ assert_match exp, e.message
561
602
  end
562
603
 
563
604
  it "deprecates expectation used without _" do
564
605
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
565
606
 
566
- @assertion_count += 3
607
+ @assertion_count += 1
608
+ @assertion_count += 2 unless error_on_warn?
567
609
 
568
610
  exp = /DEPRECATED: global use of must_equal from/
569
611
 
570
- assert_output "", exp do
612
+ assert_deprecation exp do
571
613
  (1 + 1).must_equal 2
572
614
  end
573
615
  end
@@ -577,12 +619,13 @@ describe Minitest::Spec do
577
619
  it "deprecates expectation used without _ with empty backtrace_filter" do
578
620
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
579
621
 
580
- @assertion_count += 3
622
+ @assertion_count += 1
623
+ @assertion_count += 2 unless error_on_warn?
581
624
 
582
625
  exp = /DEPRECATED: global use of must_equal from/
583
626
 
584
627
  with_empty_backtrace_filter do
585
- assert_output "", exp do
628
+ assert_deprecation exp do
586
629
  (1 + 1).must_equal 2
587
630
  end
588
631
  end
@@ -28,24 +28,24 @@ class TestMinitestUnit < MetaMetaMetaTestCase
28
28
  basedir = Pathname.new(File.expand_path "lib/minitest") + "mini"
29
29
  basedir = basedir.relative_path_from(pwd).to_s
30
30
  MINITEST_BASE_DIR = basedir[/\A\./] ? basedir : "./#{basedir}"
31
- BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in `each'",
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'"]
31
+ BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in 'each'",
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'"]
35
35
 
36
36
  def test_filter_backtrace
37
37
  # this is a semi-lame mix of relative paths.
38
38
  # I cheated by making the autotest parts not have ./
39
- bt = (["lib/autotest.rb:571:in `add_exception'",
40
- "test/test_autotest.rb:62:in `test_add_exception'",
41
- "#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
39
+ bt = (["lib/autotest.rb:571:in 'add_exception'",
40
+ "test/test_autotest.rb:62:in 'test_add_exception'",
41
+ "#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
42
42
  BT_MIDDLE +
43
43
  ["#{MINITEST_BASE_DIR}/test.rb:29",
44
44
  "test/test_autotest.rb:422"])
45
45
  bt = util_expand_bt bt
46
46
 
47
- ex = ["lib/autotest.rb:571:in `add_exception'",
48
- "test/test_autotest.rb:62:in `test_add_exception'"]
47
+ ex = ["lib/autotest.rb:571:in 'add_exception'",
48
+ "test/test_autotest.rb:62:in 'test_add_exception'"]
49
49
  ex = util_expand_bt ex
50
50
 
51
51
  Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
@@ -56,7 +56,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
56
56
  end
57
57
 
58
58
  def test_filter_backtrace_all_unit
59
- bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
59
+ bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
60
60
  BT_MIDDLE +
61
61
  ["#{MINITEST_BASE_DIR}/test.rb:29"])
62
62
  ex = bt.clone
@@ -65,7 +65,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
65
65
  end
66
66
 
67
67
  def test_filter_backtrace_unit_starts
68
- bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
68
+ bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
69
69
  BT_MIDDLE +
70
70
  ["#{MINITEST_BASE_DIR}/mini/test.rb:29",
71
71
  "-e:1"])
@@ -94,7 +94,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
94
94
  end
95
95
 
96
96
  def test_this_is_non_ascii_failure_message
97
- fail 'ЁЁЁ'.force_encoding('ASCII-8BIT')
97
+ fail 'ЁЁЁ'.dup.force_encoding(Encoding::BINARY)
98
98
  end
99
99
  end
100
100
 
@@ -111,7 +111,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
111
111
  2) Error:
112
112
  FakeNamedTestXX#test_this_is_non_ascii_failure_message:
113
113
  RuntimeError: ЁЁЁ
114
- FILE:LINE:in `test_this_is_non_ascii_failure_message'
114
+ FILE:LINE:in 'test_this_is_non_ascii_failure_message'
115
115
 
116
116
  2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
117
117
  EOM
@@ -263,7 +263,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
263
263
  1) Error:
264
264
  FakeNamedTestXX#test_error:
265
265
  RuntimeError: unhandled exception
266
- FILE:LINE:in \`test_error\'
266
+ FILE:LINE:in \'test_error\'
267
267
 
268
268
  2 runs, 1 assertions, 0 failures, 1 errors, 0 skips
269
269
  EOM
@@ -291,7 +291,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
291
291
  1) Error:
292
292
  FakeNamedTestXX#test_something:
293
293
  RuntimeError: unhandled exception
294
- FILE:LINE:in \`teardown\'
294
+ FILE:LINE:in \'teardown\'
295
295
 
296
296
  1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
297
297
  EOM
@@ -1089,17 +1089,27 @@ class TestMinitestUnitTestCase < Minitest::Test
1089
1089
 
1090
1090
  def test_autorun_does_not_affect_fork_success_status
1091
1091
  @assertion_count = 0
1092
- skip "windows doesn't have skip" unless Process.respond_to?(:fork)
1092
+ skip "windows doesn't have fork" unless Process.respond_to?(:fork)
1093
1093
  Process.waitpid(fork {})
1094
1094
  assert_equal true, $?.success?
1095
1095
  end
1096
1096
 
1097
1097
  def test_autorun_does_not_affect_fork_exit_status
1098
1098
  @assertion_count = 0
1099
- skip "windows doesn't have skip" unless Process.respond_to?(:fork)
1099
+ skip "windows doesn't have fork" unless Process.respond_to?(:fork)
1100
1100
  Process.waitpid(fork { exit 42 })
1101
1101
  assert_equal 42, $?.exitstatus
1102
1102
  end
1103
+
1104
+ def test_autorun_optionally_can_affect_fork_exit_status
1105
+ @assertion_count = 0
1106
+ skip "windows doesn't have fork" unless Process.respond_to?(:fork)
1107
+ Minitest.allow_fork = true
1108
+ Process.waitpid(fork { exit 42 })
1109
+ refute_equal 42, $?.exitstatus
1110
+ ensure
1111
+ Minitest.allow_fork = false
1112
+ end
1103
1113
  end
1104
1114
 
1105
1115
  class TestMinitestGuard < Minitest::Test
@@ -1116,19 +1126,19 @@ class TestMinitestGuard < Minitest::Test
1116
1126
  end
1117
1127
 
1118
1128
  def test_rubinius_eh
1119
- assert_output "", /DEPRECATED/ do
1129
+ assert_deprecation do
1120
1130
  assert self.class.rubinius? "rbx"
1121
1131
  end
1122
- assert_output "", /DEPRECATED/ do
1132
+ assert_deprecation do
1123
1133
  assert self.rubinius? "rbx"
1124
1134
  end
1125
1135
  end
1126
1136
 
1127
1137
  def test_maglev_eh
1128
- assert_output "", /DEPRECATED/ do
1138
+ assert_deprecation do
1129
1139
  assert self.class.maglev? "maglev"
1130
1140
  end
1131
- assert_output "", /DEPRECATED/ do
1141
+ assert_deprecation do
1132
1142
  assert self.maglev? "maglev"
1133
1143
  end
1134
1144
  end
@@ -1251,12 +1261,12 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
1251
1261
  Error:
1252
1262
  FakeNamedTestXX#test_method:
1253
1263
  AnError: AnError
1254
- FILE:LINE:in `test_method'
1264
+ FILE:LINE:in 'test_method'
1255
1265
 
1256
1266
  Error:
1257
1267
  FakeNamedTestXX#test_method:
1258
1268
  RuntimeError: unhandled exception
1259
- FILE:LINE:in `teardown'
1269
+ FILE:LINE:in 'teardown'
1260
1270
  "
1261
1271
 
1262
1272
  assert_equal exp.strip, normalize_output(first_reporter.results.first.to_s).strip
@@ -1270,3 +1280,96 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
1270
1280
  end
1271
1281
  end
1272
1282
  end
1283
+
1284
+ class TestUnexpectedError < Minitest::Test
1285
+ def assert_compress exp, input
1286
+ e = Minitest::UnexpectedError.new RuntimeError.new
1287
+
1288
+ exp = exp.lines.map(&:chomp) if String === exp
1289
+ act = e.compress input
1290
+
1291
+ assert_equal exp, act
1292
+ end
1293
+
1294
+ ACT1 = %w[ a b c b c b c b c d ]
1295
+
1296
+ def test_normal
1297
+ assert_compress <<~EXP, %w[ a b c b c b c b c d ]
1298
+ a
1299
+ +->> 4 cycles of 2 lines:
1300
+ | b
1301
+ | c
1302
+ +-<<
1303
+ d
1304
+ EXP
1305
+ end
1306
+
1307
+ def test_normal2
1308
+ assert_compress <<~EXP, %w[ a b c b c b c b c ]
1309
+ a
1310
+ +->> 4 cycles of 2 lines:
1311
+ | b
1312
+ | c
1313
+ +-<<
1314
+ EXP
1315
+ end
1316
+
1317
+ def test_longer_c_than_b
1318
+ # the extra c in the front makes the overall length longer sorting it first
1319
+ assert_compress <<~EXP, %w[ c a b c b c b c b c b d ]
1320
+ c
1321
+ a
1322
+ b
1323
+ +->> 4 cycles of 2 lines:
1324
+ | c
1325
+ | b
1326
+ +-<<
1327
+ d
1328
+ EXP
1329
+ end
1330
+
1331
+ def test_1_line_cycles
1332
+ assert_compress <<~EXP, %w[ c a b c b c b c b c b b b d ]
1333
+ c
1334
+ a
1335
+ +->> 4 cycles of 2 lines:
1336
+ | b
1337
+ | c
1338
+ +-<<
1339
+ +->> 3 cycles of 1 lines:
1340
+ | b
1341
+ +-<<
1342
+ d
1343
+ EXP
1344
+ end
1345
+
1346
+ def test_sanity3
1347
+ pre = ("aa".."am").to_a
1348
+ mid = ("a".."z").to_a * 67
1349
+ post = ("aa".."am").to_a
1350
+ ary = pre + mid + post
1351
+
1352
+ exp = pre +
1353
+ [" +->> 67 cycles of 26 lines:"] +
1354
+ ("a".."z").map { |s| " | #{s}" } +
1355
+ [" +-<<"] +
1356
+ post
1357
+
1358
+ assert_compress exp, ary
1359
+ end
1360
+
1361
+ def test_absurd_patterns
1362
+ assert_compress <<~EXP, %w[ a b c b c a b c b c a b c ]
1363
+ +->> 2 cycles of 5 lines:
1364
+ | a
1365
+ | +->> 2 cycles of 2 lines:
1366
+ | | b
1367
+ | | c
1368
+ | +-<<
1369
+ +-<<
1370
+ a
1371
+ b
1372
+ c
1373
+ EXP
1374
+ end
1375
+ end
@@ -26,6 +26,7 @@ class TestHoeTest < Minitest::Test
26
26
  end
27
27
 
28
28
  assert_equal MT_EXPECTED % [framework].join("; "), @tester.make_test_cmd
29
+ .sub(/ -- .+/, " -- ")
29
30
  end
30
31
 
31
32
  def test_make_test_cmd_for_minitest_prelude
@@ -42,5 +43,6 @@ class TestHoeTest < Minitest::Test
42
43
  end
43
44
 
44
45
  assert_equal MT_EXPECTED % [prelude, framework].join("; "), @tester.make_test_cmd
46
+ .sub(/ -- .+/, " -- ")
45
47
  end
46
48
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.17.0
4
+ version: 5.23.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBBzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTIzMDEwMTA3NTExN1oXDTI0MDEwMTA3NTExN1owRTETMBEGA1UE
15
+ GRYDY29tMB4XDTI0MDEwMjIxMjEyM1oXDTI1MDEwMTIxMjEyM1owRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQAkg3y+PBnBAPWdxxITm5sPHqdWQgSyCpRA20o4LTuWr8BWhSXBkfQNa7cY6fOn
26
- xyM34VPzBFbExv6XOGDfOMFBVaYTHuN9peC/5/umL7kLl+nflXzL2QA7K6LYj5Bg
27
- sM574Onr0dZDM6Vn69bzQ7rBIFDfK/OhlPzqKZad4nsdcsVH8ODCiT+ATMIZyz5K
28
- WCnNtqlyiWXI8tdTpahDgcUwfcN/oN7v4K8iU5IbLJX6HQ5DKgmKjfb6XyMth16k
29
- ROfWo9Uyp8ba/j9eVG14KkYRaLydAY1MNQk2yd3R5CGfeOpD1kttxjoypoUJ2dOG
30
- nsNBRuQJ1UfiCG97a6DNm+Fr
25
+ AQCygvpmncmkiSs9r/Kceo4bBPDszhTv6iBi4LwMReqnFrpNLMOWJw7xi8x+3eL2
26
+ XS09ZPNOt2zm70KmFouBMgOysnDY4k2dE8uF6B8JbZOO8QfalW+CoNBliefOTcn2
27
+ bg5IOP7UoGM5lC174/cbDJrJnRG9bzig5FAP0mvsgA8zgTRXQzIUAZEo92D5K7p4
28
+ B4/O998ho6BSOgYBI9Yk1ttdCtti6Y+8N9+fZESsjtWMykA+WXWeGUScHqiU+gH8
29
+ S7043fq9EbQdBr2AXdj92+CDwuTfHI6/Hj5FVBDULufrJaan4xUgL70Hvc6pTTeW
30
+ deKfBjgVAq7EYHu1AczzlUly
31
31
  -----END CERTIFICATE-----
32
- date: 2023-01-01 00:00:00.000000000 Z
32
+ date: 2024-05-22 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdoc
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '4.0'
60
+ version: '4.2'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '4.0'
67
+ version: '4.2'
68
68
  description: |-
69
69
  minitest provides a complete suite of testing facilities supporting
70
70
  TDD, BDD, mocking, and benchmarking.
@@ -139,8 +139,11 @@ files:
139
139
  - lib/minitest/assertions.rb
140
140
  - lib/minitest/autorun.rb
141
141
  - lib/minitest/benchmark.rb
142
+ - lib/minitest/compress.rb
143
+ - lib/minitest/error_on_warning.rb
142
144
  - lib/minitest/expectations.rb
143
145
  - lib/minitest/hell.rb
146
+ - lib/minitest/manual_plugins.rb
144
147
  - lib/minitest/mock.rb
145
148
  - lib/minitest/parallel.rb
146
149
  - lib/minitest/pride.rb
@@ -157,12 +160,13 @@ files:
157
160
  - test/minitest/test_minitest_spec.rb
158
161
  - test/minitest/test_minitest_test.rb
159
162
  - test/minitest/test_minitest_test_task.rb
160
- homepage: https://github.com/seattlerb/minitest
163
+ homepage: https://github.com/minitest/minitest
161
164
  licenses:
162
165
  - MIT
163
166
  metadata:
164
- homepage_uri: https://github.com/seattlerb/minitest
165
- bug_tracker_uri: https://github.com/seattlerb/minitest/issues
167
+ homepage_uri: https://github.com/minitest/minitest
168
+ bug_tracker_uri: https://github.com/minitest/minitest/issues
169
+ changelog_uri: https://github.com/minitest/minitest/blob/master/History.rdoc
166
170
  post_install_message:
167
171
  rdoc_options:
168
172
  - "--main"
@@ -183,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
187
  - !ruby/object:Gem::Version
184
188
  version: '0'
185
189
  requirements: []
186
- rubygems_version: 3.3.12
190
+ rubygems_version: 3.5.3
187
191
  signing_key:
188
192
  specification_version: 4
189
193
  summary: minitest provides a complete suite of testing facilities supporting TDD,
metadata.gz.sig CHANGED
Binary file