minitest 5.22.2 → 5.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24c5445e518a9b867eabce480e1d5c176c93fc6806eaed987200961e56443ec0
4
- data.tar.gz: 2b1c37793c825e1b437d30a899411a2d71e924ab250c23d348f71ca1dbd68df2
3
+ metadata.gz: 504b1223be3a95fcfafe10a397384628113ff8514e0674ade01f3db968e7c1ae
4
+ data.tar.gz: 59e22fefd004b545f6084c5c91561502325add44200cc77203dbec3334746cd0
5
5
  SHA512:
6
- metadata.gz: bc52b553200c232e0493953439fd935ee6cac3e46c45e121c81c2bc0046a5afd44caf8df980273fd46bf9ac81d38f1349f3a76a9ce9f59afff0e0e2316ea1a45
7
- data.tar.gz: f98fcfb53d73e1d134d16b376aba3d78ef90d27024c18c48a5e0b153cc55225afc38c2c166e92d9282ffab713654843f82c9fa8a20332a16cc7308c9e1e4a140
6
+ metadata.gz: 5f387dcac2c6072f79ff1cb43f407bbb65f2f950785f27ec1b4a803f4ddc0200e5dd05bce956fe8d98ec10a7723c451b5e92b44b1356126657adf429ed616f59
7
+ data.tar.gz: 115fa22f9991580fa4b4e98eb31c10d2b775b5de731a66e6d61f50ec14c51ac87ee25c5c038e75e5889b4845fa546bd5c5d73b8ddf1abc88322dcf5cedbce328
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,15 @@
1
+ === 5.22.3 / 2024-03-13
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * MASSIVE improvement of minitest's pride plugin output: Frequencies doubled! Sine waves shifted!! Comments improved!!! Colors rotated!!!! (havenwood)
6
+
7
+ * 3 bug fixes:
8
+
9
+ * Improved wording on Minitest::Test#parallelize_me! to clarify it goes INSIDE your test class/describe.
10
+ * Minor changes to tests to pass when tests ran with extra flags (eg -p).
11
+ * Support Ruby 3.4's new error message format. (mame)
12
+
1
13
  === 5.22.2 / 2024-02-07
2
14
 
3
15
  * 1 bug fix:
data/Manifest.txt CHANGED
@@ -10,8 +10,10 @@ lib/minitest/assertions.rb
10
10
  lib/minitest/autorun.rb
11
11
  lib/minitest/benchmark.rb
12
12
  lib/minitest/compress.rb
13
+ lib/minitest/error_on_warning.rb
13
14
  lib/minitest/expectations.rb
14
15
  lib/minitest/hell.rb
16
+ lib/minitest/manual_plugins.rb
15
17
  lib/minitest/mock.rb
16
18
  lib/minitest/parallel.rb
17
19
  lib/minitest/pride.rb
data/README.rdoc CHANGED
@@ -406,22 +406,23 @@ Using our example above, here is how we might implement MyCI:
406
406
 
407
407
  === What versions are compatible with what? Or what versions are supported?
408
408
 
409
- Minitest is a dependency of rails, which until fairly recently had an
409
+ Minitest is a dependency of rails, which until very recently had an
410
410
  overzealous backwards compatibility policy. As such, I'm stuck
411
411
  supporting versions of ruby that are long past EOL. Hopefully I'll be
412
412
  able to support only current versions of ruby sometime in the near
413
413
  future.
414
414
 
415
- (As of 2023-03-05)
415
+ (As of 2024-05-10)
416
416
 
417
417
  Current versions of rails: (https://endoflife.date/rails)
418
418
 
419
- | rails | min ruby | rec ruby | minitest | status | EOL Date |
420
- |-------+----------+----------+----------+----------+------------|
421
- | 7.0 | >= 2.7 | 3.1 | >= 5.1 | Current | 2025-06-01?|
422
- | 6.1 | >= 2.5 | 3.0 | >= 5.1 | Maint | 2024-06-01?|
423
- | 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security | 2023-06-01 |
424
- | 5.2 | >= 2.2.2 | 2.5 | ~> 5.1 | EOL | 2022-06-01 |
419
+ | rails | min ruby | minitest | status | EOL Date |
420
+ |-------+----------+----------+----------+------------|
421
+ | 7.1 | >= 2.7 | >= 5.1 | Current | 2026-06-01?|
422
+ | 7.0 | >= 2.7 | >= 5.1 | Maint | 2025-06-01?|
423
+ | 6.1 | >= 2.5 | >= 5.1 | Security | 2024-06-01?|
424
+ | 6.0 | >= 2.5 | >= 5.1 | EOL | 2023-06-01 |
425
+ | 5.2 | >= 2.2.2 | ~> 5.1 | EOL | 2022-06-01 |
425
426
 
426
427
  If you want to look at the requirements for a specific version, run:
427
428
 
@@ -431,12 +432,13 @@ Current versions of ruby: (https://endoflife.date/ruby)
431
432
 
432
433
  | ruby | Status | EOL Date |
433
434
  |------+---------+------------|
434
- | 3.2 | Current | 2026-03-31 |
435
- | 3.1 | Maint | 2025-03-31 |
436
- | 3.0 | Maint | 2024-03-31 |
437
- | 2.7 | Security| 2023-03-31 |
435
+ | 3.3 | Current | 2027-03-31 |
436
+ | 3.2 | Maint | 2026-03-31 |
437
+ | 3.1 | Security| 2025-03-31 |
438
+ | 3.0 | EOL | 2024-03-31 |
439
+ | 2.7 | EOL | 2023-03-31 |
438
440
  | 2.6 | EOL | 2022-03-31 |
439
- | 2.5 | EOL | 2021-03-31 |
441
+ | 2.5 | EOL | 2021-03-31 | DO YOU SEE WHAT I'M STUCK WITH???
440
442
 
441
443
  === How to test SimpleDelegates?
442
444
 
data/Rakefile CHANGED
@@ -33,6 +33,7 @@ task :specs do
33
33
  /_includes/ => "_include",
34
34
  /(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
35
35
  /must_raises/ => "must_raise",
36
+ /(must|wont)_pattern/ => '\1_pattern_match',
36
37
  /(must|wont)_predicate/ => '\1_be',
37
38
  /(must|wont)_path_exists/ => 'path_\1_exist',
38
39
  }
@@ -72,4 +73,9 @@ task :bugs do
72
73
  sh "for f in bug*.rb ; do echo $f; echo; #{Gem.ruby} -Ilib $f && rm $f ; done"
73
74
  end
74
75
 
76
+ Minitest::TestTask.create :testW0 do |t|
77
+ t.warning = false
78
+ t.test_prelude = "$-w = nil"
79
+ end
80
+
75
81
  # vim: syntax=Ruby
@@ -0,0 +1,11 @@
1
+ module Minitest
2
+
3
+ module ErrorOnWarning
4
+ def warn(message, category: nil)
5
+ message = "[#{category}] #{message}" if category
6
+ raise UnexpectedWarning, message
7
+ end
8
+ end
9
+
10
+ ::Warning.singleton_class.prepend(ErrorOnWarning)
11
+ end
@@ -0,0 +1,16 @@
1
+ require "minitest"
2
+
3
+ ARGV << "--no-plugins"
4
+
5
+ module Minitest
6
+ ##
7
+ # Manually load plugins by name.
8
+
9
+ def self.load *names
10
+ names.each do |name|
11
+ require "minitest/#{name}_plugin"
12
+
13
+ self.extensions << name.to_s
14
+ end
15
+ end
16
+ end
@@ -113,19 +113,16 @@ module Minitest
113
113
  #
114
114
  # plot (3*sin(x)+3), (3*sin(x+2*pi/3)+3), (3*sin(x+4*pi/3)+3)
115
115
 
116
- # 6 has wide pretty gradients. 3 == lolcat, about half the width
117
- @colors = (0...(6 * 7)).map { |n|
118
- n *= 1.0 / 6
116
+ @colors = (6 * 7).times.map { |n|
117
+ n *= 1.0 / 3
119
118
  r = (3 * Math.sin(n ) + 3).to_i
120
- g = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
121
- b = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
122
-
123
- # Then we take rgb and encode them in a single number using base 6.
124
- # For some mysterious reason, we add 16... to clear the bottom 4 bits?
125
- # Yes... they're ugly.
119
+ g = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
120
+ b = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
126
121
 
122
+ # Then we take rgb and encode them in a single number using
123
+ # base 6, shifted by 16 for the base 16 ansi colors.
127
124
  36 * r + 6 * g + b + 16
128
- }
125
+ }.rotate(4) # puts "red" first
129
126
 
130
127
  super
131
128
  end
data/lib/minitest/test.rb CHANGED
@@ -52,9 +52,10 @@ module Minitest
52
52
  end
53
53
 
54
54
  ##
55
- # Call this at the top of your tests when you want to run your
56
- # tests in parallel. In doing so, you're admitting that you rule
57
- # and your tests are awesome.
55
+ # Call this at the top of your tests (inside the +Minitest::Test+
56
+ # subclass or +describe+ block) when you want to run your tests in
57
+ # parallel. In doing so, you're admitting that you rule and your
58
+ # tests are awesome.
58
59
 
59
60
  def self.parallelize_me!
60
61
  include Minitest::Parallel::Test
@@ -114,7 +114,7 @@ module Minitest # :nodoc:
114
114
  self.test_globs = ["test/**/test_*.rb",
115
115
  "test/**/*_test.rb"]
116
116
  self.test_prelude = nil
117
- self.verbose = Rake.application.options.trace
117
+ self.verbose = Rake.application.options.trace || Rake.verbose == true
118
118
  self.warning = true
119
119
  end
120
120
 
data/lib/minitest.rb CHANGED
@@ -9,7 +9,7 @@ require_relative "minitest/compress"
9
9
  # :include: README.rdoc
10
10
 
11
11
  module Minitest
12
- VERSION = "5.22.2" # :nodoc:
12
+ VERSION = "5.22.3" # :nodoc:
13
13
 
14
14
  @@installed_at_exit ||= false
15
15
  @@after_run = []
@@ -167,10 +167,10 @@ module Minitest
167
167
 
168
168
  # might have been removed/replaced during init_plugins:
169
169
  summary = reporter.reporters.grep(SummaryReporter).first
170
- return empty_run! options if summary && summary.count == 0
171
170
 
172
171
  reporter.report
173
172
 
173
+ return empty_run! options if summary && summary.count == 0
174
174
  reporter.passed?
175
175
  end
176
176
 
@@ -253,6 +253,20 @@ module Minitest
253
253
  options[:skip] = s.chars.to_a
254
254
  end
255
255
 
256
+ ruby27plus = ::Warning.respond_to?(:[]=)
257
+
258
+ opts.on "-W[error]", String, "Turn Ruby warnings into errors" do |s|
259
+ options[:Werror] = true
260
+ case s
261
+ when "error", "all", nil then
262
+ require "minitest/error_on_warning"
263
+ $VERBOSE = true
264
+ ::Warning[:deprecated] = true if ruby27plus
265
+ else
266
+ ::Warning[s.to_sym] = true if ruby27plus # check validity of category
267
+ end
268
+ end
269
+
256
270
  unless extensions.empty?
257
271
  opts.separator ""
258
272
  opts.separator "Known extensions: #{extensions.join(", ")}"
@@ -782,6 +796,11 @@ module Minitest
782
796
 
783
797
  attr_accessor :errors
784
798
 
799
+ ##
800
+ # Total number of tests that warned.
801
+
802
+ attr_accessor :warnings
803
+
785
804
  ##
786
805
  # Total number of tests that where skipped.
787
806
 
@@ -797,6 +816,7 @@ module Minitest
797
816
  self.total_time = nil
798
817
  self.failures = nil
799
818
  self.errors = nil
819
+ self.warnings = nil
800
820
  self.skips = nil
801
821
  end
802
822
 
@@ -825,6 +845,7 @@ module Minitest
825
845
  self.total_time = Minitest.clock_time - start_time
826
846
  self.failures = aggregate[Assertion].size
827
847
  self.errors = aggregate[UnexpectedError].size
848
+ self.warnings = aggregate[UnexpectedWarning].size
828
849
  self.skips = aggregate[Skip].size
829
850
  end
830
851
  end
@@ -900,6 +921,8 @@ module Minitest
900
921
  results.any?(&:skipped?) unless
901
922
  options[:verbose] or options[:show_skips] or ENV["MT_NO_SKIP_MSG"]
902
923
 
924
+ extra.prepend ", %d warnings" % [warnings] if options[:Werror]
925
+
903
926
  "%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
904
927
  [count, assertions, failures, errors, skips, extra]
905
928
  end
@@ -960,7 +983,7 @@ module Minitest
960
983
  # Represents run failures.
961
984
 
962
985
  class Assertion < Exception
963
- RE = /in .(?:assert|refute|flunk|pass|fail|raise|must|wont)/ # :nodoc:
986
+ RE = /in [`'](?:[^']+[#.])?(?:assert|refute|flunk|pass|fail|raise|must|wont)/ # :nodoc:
964
987
 
965
988
  def error # :nodoc:
966
989
  self
@@ -1034,6 +1057,15 @@ module Minitest
1034
1057
  end
1035
1058
  end
1036
1059
 
1060
+ ##
1061
+ # Assertion raised on warning when running in -Werror mode.
1062
+
1063
+ class UnexpectedWarning < Assertion
1064
+ def result_label # :nodoc:
1065
+ "Warning"
1066
+ end
1067
+ end
1068
+
1037
1069
  ##
1038
1070
  # Provides a simple set of guards that you can use in your tests
1039
1071
  # to skip execution if it is not applicable. These methods are
@@ -1107,7 +1139,7 @@ module Minitest
1107
1139
 
1108
1140
  class BacktraceFilter
1109
1141
 
1110
- MT_RE = %r%lib/minitest% #:nodoc:
1142
+ MT_RE = %r%lib/minitest|internal:warning% #:nodoc:
1111
1143
 
1112
1144
  attr_accessor :regexp
1113
1145
 
@@ -25,8 +25,19 @@ class Minitest::Test
25
25
  end
26
26
  end
27
27
  end
28
- end
29
28
 
29
+ def error_on_warn?
30
+ defined?(Minitest::ErrorOnWarning)
31
+ end
32
+
33
+ def assert_deprecation re = /DEPRECATED/
34
+ assert_output "", re do
35
+ yield
36
+ end
37
+ rescue Minitest::UnexpectedWarning => e # raised if -Werror was used
38
+ assert_match re, e.message
39
+ end
40
+ end
30
41
 
31
42
  class FakeNamedTest < Minitest::Test
32
43
  @@count = 0
@@ -56,7 +67,7 @@ class MetaMetaMetaTestCase < Minitest::Test
56
67
  def run_tu_with_fresh_reporter flags = %w[--seed 42]
57
68
  options = Minitest.process_args flags
58
69
 
59
- @output = StringIO.new("".encode('UTF-8'))
70
+ @output = StringIO.new("".encode(Encoding::UTF_8))
60
71
 
61
72
  self.reporter = Minitest::CompositeReporter.new
62
73
  reporter << Minitest::SummaryReporter.new(@output, options)
@@ -110,12 +121,15 @@ class MetaMetaMetaTestCase < Minitest::Test
110
121
 
111
122
  if windows? then
112
123
  output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, "[FILE:LINE]")
113
- output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
124
+ output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in [`']/, '\1FILE:LINE:in \'')
114
125
  else
115
- output.gsub!(/\[([^\]:]+):\d+\]/) { "[#{file[$1]}:LINE]" }
116
- output.gsub!(/^(\s+)([^:]+):\d+:in/) { "#{$1}#{file[$2]}:LINE:in" }
126
+ output.gsub!(/\[([^\]:]+):\d+\]/) { "[#{file[$1]}:LINE]" }
127
+ output.gsub!(/^(\s+)([^:]+):\d+:in [`']/) { "#{$1}#{file[$2]}:LINE:in '" }
117
128
  end
118
129
 
130
+ output.gsub!(/in [`']block in (?:([^']+)[#.])?/, "in 'block in")
131
+ output.gsub!(/in [`'](?:([^']+)[#.])?/, "in '")
132
+
119
133
  output.gsub!(/( at )[^:]+:\d+/) { "#{$1}[#{file[$2]}:LINE]" } # eval?
120
134
 
121
135
  output
@@ -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
@@ -971,16 +966,24 @@ class TestMinitestAssertions < Minitest::Test
971
966
  end
972
967
 
973
968
  def test_assert_send
974
- assert_deprecated :assert_send do
969
+ @assertion_count = 0 if error_on_warn?
970
+ assert_deprecation(/DEPRECATED: assert_send/) do
975
971
  @tc.assert_send [1, :<, 2]
976
972
  end
977
973
  end
978
974
 
979
975
  def test_assert_send_bad
980
- assert_deprecated :assert_send do
981
- 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
982
979
  @tc.assert_send [1, :>, 2]
983
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
984
987
  end
985
988
  end
986
989
 
@@ -1498,7 +1501,7 @@ class TestMinitestAssertions < Minitest::Test
1498
1501
  d0 = Time.now
1499
1502
  d1 = d0 + 86_400 # I am an idiot
1500
1503
 
1501
- assert_output "", /Stale skip_until \"not yet\" at .*?:\d+$/ do
1504
+ assert_deprecation(/Stale skip_until \"not yet\" at .*?:\d+$/) do
1502
1505
  assert_skip_until d0, "not yet"
1503
1506
  end
1504
1507
 
@@ -1642,14 +1645,14 @@ class TestMinitestAssertionHelpers < Minitest::Test
1642
1645
  end
1643
1646
 
1644
1647
  def test_mu_pp_for_diff_str_bad_encoding
1645
- str = "\666".force_encoding Encoding::UTF_8
1648
+ str = "\666".dup.force_encoding Encoding::UTF_8
1646
1649
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6\""
1647
1650
 
1648
1651
  assert_mu_pp_for_diff exp, str, :raw
1649
1652
  end
1650
1653
 
1651
1654
  def test_mu_pp_for_diff_str_bad_encoding_both
1652
- str = "\666A\\n\nB".force_encoding Encoding::UTF_8
1655
+ str = "\666A\\n\nB".dup.force_encoding Encoding::UTF_8
1653
1656
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6A\\\\n\\nB\""
1654
1657
 
1655
1658
  assert_mu_pp_for_diff exp, str, :raw
@@ -1696,7 +1699,7 @@ class TestMinitestAssertionHelpers < Minitest::Test
1696
1699
  end
1697
1700
 
1698
1701
  def test_mu_pp_str_bad_encoding
1699
- str = "\666".force_encoding Encoding::UTF_8
1702
+ str = "\666".dup.force_encoding Encoding::UTF_8
1700
1703
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6\""
1701
1704
 
1702
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/
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
 
@@ -324,8 +324,8 @@ class TestMinitestReporter < MetaMetaMetaTestCase
324
324
  1) Error:
325
325
  Minitest::Test#woot:
326
326
  RuntimeError: no
327
- FILE:LINE:in `error_test'
328
- FILE:LINE:in `test_report_error'
327
+ FILE:LINE:in 'error_test'
328
+ FILE:LINE:in 'test_report_error'
329
329
 
330
330
  1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
331
331
  EOM
@@ -397,7 +397,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
397
397
  def test_report_failure_uses_backtrace_filter
398
398
  filter = Minitest::BacktraceFilter.new
399
399
  def filter.filter _bt
400
- ["foo.rb:123:in `foo'"]
400
+ ["foo.rb:123:in 'foo'"]
401
401
  end
402
402
 
403
403
  with_backtrace_filter filter do
@@ -413,15 +413,15 @@ class TestMinitestReporter < MetaMetaMetaTestCase
413
413
 
414
414
  def test_report_failure_uses_backtrace_filter_complex_sorbet
415
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'
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
425
  ... so many lines ...
426
426
  EOBT
427
427
 
@@ -284,18 +284,14 @@ describe Minitest::Spec do
284
284
  end
285
285
 
286
286
  it "needs to warn on equality with nil" do
287
- @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./
288
291
 
289
- out, err = capture_io do
292
+ assert_deprecation exp do
290
293
  assert_success _(nil).must_equal(nil)
291
294
  end
292
-
293
- exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
294
- "This will fail in Minitest 6.\n"
295
- exp = "" if $-w.nil?
296
-
297
- assert_empty out
298
- assert_equal exp, err
299
295
  end
300
296
 
301
297
  it "needs to verify floats outside a delta" do
@@ -576,7 +572,8 @@ describe Minitest::Spec do
576
572
 
577
573
  it "can NOT use must_equal in a thread. It must use expect in a thread" do
578
574
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
579
- assert_raises RuntimeError do
575
+
576
+ assert_raises RuntimeError, Minitest::UnexpectedWarning do
580
577
  capture_io do
581
578
  Thread.new { (1 + 1).must_equal 2 }.join
582
579
  end
@@ -586,9 +583,9 @@ describe Minitest::Spec do
586
583
  it "fails gracefully when expectation used outside of `it`" do
587
584
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
588
585
 
589
- @assertion_count += 1
586
+ @assertion_count += 2 # assert_match is compound
590
587
 
591
- e = assert_raises RuntimeError do
588
+ e = assert_raises RuntimeError, Minitest::UnexpectedWarning do
592
589
  capture_io do
593
590
  Thread.new { # forces ctx to be nil
594
591
  describe("woot") do
@@ -598,17 +595,21 @@ describe Minitest::Spec do
598
595
  end
599
596
  end
600
597
 
601
- 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
602
602
  end
603
603
 
604
604
  it "deprecates expectation used without _" do
605
605
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
606
606
 
607
- @assertion_count += 3
607
+ @assertion_count += 1
608
+ @assertion_count += 2 unless error_on_warn?
608
609
 
609
610
  exp = /DEPRECATED: global use of must_equal from/
610
611
 
611
- assert_output "", exp do
612
+ assert_deprecation exp do
612
613
  (1 + 1).must_equal 2
613
614
  end
614
615
  end
@@ -618,12 +619,13 @@ describe Minitest::Spec do
618
619
  it "deprecates expectation used without _ with empty backtrace_filter" do
619
620
  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
620
621
 
621
- @assertion_count += 3
622
+ @assertion_count += 1
623
+ @assertion_count += 2 unless error_on_warn?
622
624
 
623
625
  exp = /DEPRECATED: global use of must_equal from/
624
626
 
625
627
  with_empty_backtrace_filter do
626
- assert_output "", exp do
628
+ assert_deprecation exp do
627
629
  (1 + 1).must_equal 2
628
630
  end
629
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
@@ -1126,19 +1126,19 @@ class TestMinitestGuard < Minitest::Test
1126
1126
  end
1127
1127
 
1128
1128
  def test_rubinius_eh
1129
- assert_output "", /DEPRECATED/ do
1129
+ assert_deprecation do
1130
1130
  assert self.class.rubinius? "rbx"
1131
1131
  end
1132
- assert_output "", /DEPRECATED/ do
1132
+ assert_deprecation do
1133
1133
  assert self.rubinius? "rbx"
1134
1134
  end
1135
1135
  end
1136
1136
 
1137
1137
  def test_maglev_eh
1138
- assert_output "", /DEPRECATED/ do
1138
+ assert_deprecation do
1139
1139
  assert self.class.maglev? "maglev"
1140
1140
  end
1141
- assert_output "", /DEPRECATED/ do
1141
+ assert_deprecation do
1142
1142
  assert self.maglev? "maglev"
1143
1143
  end
1144
1144
  end
@@ -1261,12 +1261,12 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
1261
1261
  Error:
1262
1262
  FakeNamedTestXX#test_method:
1263
1263
  AnError: AnError
1264
- FILE:LINE:in `test_method'
1264
+ FILE:LINE:in 'test_method'
1265
1265
 
1266
1266
  Error:
1267
1267
  FakeNamedTestXX#test_method:
1268
1268
  RuntimeError: unhandled exception
1269
- FILE:LINE:in `teardown'
1269
+ FILE:LINE:in 'teardown'
1270
1270
  "
1271
1271
 
1272
1272
  assert_equal exp.strip, normalize_output(first_reporter.results.first.to_s).strip
@@ -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.22.2
4
+ version: 5.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  S7043fq9EbQdBr2AXdj92+CDwuTfHI6/Hj5FVBDULufrJaan4xUgL70Hvc6pTTeW
30
30
  deKfBjgVAq7EYHu1AczzlUly
31
31
  -----END CERTIFICATE-----
32
- date: 2024-02-07 00:00:00.000000000 Z
32
+ date: 2024-05-15 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdoc
@@ -140,8 +140,10 @@ files:
140
140
  - lib/minitest/autorun.rb
141
141
  - lib/minitest/benchmark.rb
142
142
  - lib/minitest/compress.rb
143
+ - lib/minitest/error_on_warning.rb
143
144
  - lib/minitest/expectations.rb
144
145
  - lib/minitest/hell.rb
146
+ - lib/minitest/manual_plugins.rb
145
147
  - lib/minitest/mock.rb
146
148
  - lib/minitest/parallel.rb
147
149
  - lib/minitest/pride.rb
metadata.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- rr��)O��eMaH֬� �$"Gh�����s�ў�L��M6�/�H����BR��F
2
- KU5��(8J�<u&�
3
- @[�
1
+ (�h��b��dv�.����l2 ��x��Wɐ��1K�Q!�Y݊��(�Χ�#ij²��}�
2
+ 3xYo>Zga�ڝ���A��_���J9y��^�'�n��-��+H�v��؛����{�3ُ�P��(otF���j��4A3m�,N��S��c���2�\�������9�Hs�}:}��GyF��v������T���Y^������.N���>`�K�����$ww��^i+T�l� ��D{�����