minitest 5.25.5 → 5.26.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2ea23b9f86dd37b5f5f3d45fb451303827cbdf9414215d8f769da3624184325
4
- data.tar.gz: 3d976e8b864261af92ba50d466235e4fa529f31d3560d60ec4deba8e724fc872
3
+ metadata.gz: 99c81ecf40f2e6edde9201cded0808484223cdf20d3e819e1b043e50bcc2564c
4
+ data.tar.gz: 543e61e5ac5da94ddbaaa51969b0b5dbf2ea91b400c13fd88830396a22627867
5
5
  SHA512:
6
- metadata.gz: 1258d24412b8461fe9a94acb9b795a1cd2a25db2d16f924ce6367662478d9e0672532636b5a2ccd809f549ba8ba6ab8f0cbeb6e8a249b1b91161cc4297f31c92
7
- data.tar.gz: 4d6a977e948f40d05e7786d07656616e9f3a4e4469a59e7b5a8e571b8f6821284989156ca4225e8e7a29cfe640bbaf544248697e14536f7c63946ffc2a34232e
6
+ metadata.gz: 1e73adb8391043dc989b7dd2c307f5e5af72f2f2e51ef1e0fda7654cff90755fd920e2003f86ef0fa62bae2fbc9e9ec9a7a6bea76abc6a46c5b7f0500fa5b337
7
+ data.tar.gz: 3a860d654d72db62a86397b6849fa5509e21e5f5a021e920b0bca46d147cd8f5d7d5203ad28eb73b22b2a643683db0e8fa8948437688ec18642ef21666e3095f
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,35 @@
1
+ === 5.26.1 / 2025-11-08
2
+
3
+ The Ocean Shores, Slightly Less Tipsy Edition!
4
+
5
+ * 3 bug fixes:
6
+
7
+ * Add links to API doco in README.
8
+ * Add missing require thread.
9
+ * Bumped ruby version to include 4.0 (trunk). (hsbt)
10
+ (see also 5.14.2)
11
+
12
+ === 5.26.0 / 2025-10-07
13
+
14
+ The Seattle.rb Nerd Party, Slightly Tipsy Edition!
15
+
16
+ * 2 minor enhancements:
17
+
18
+ * Added extra documentation to Minitest::TestTask options.
19
+ * Make parallelize_me! a no-op when n_threads=1.
20
+
21
+ * 9 bug fixes:
22
+
23
+ * Bypass parallel_executor entirely when n_threads=1.
24
+ * Don't require rubygems in Rakefile... it is 2025.
25
+ * Ensure that minitest exits non-zero on Interrupt. (tavianator)
26
+ * Fix Minitest.run sequence rdoc to include loop vars and read consistently.
27
+ * Fix call to parallel_executor.shutdown when it isn't defined.
28
+ * Removed some 1.8/1.9-based code from the assertions and expectations.
29
+ * Still fighting with rdoc? Yup. Still fighting with rdoc...
30
+ * Switched assert_equal's diff from Tempfile.open to Tempfile.create.
31
+ * Use Regexp.escape for BASE_RE in case pwd has special chars. (astra_1993)
32
+
1
33
  === 5.25.5 / 2025-03-12
2
34
 
3
35
  * 4 bug fixes:
data/README.rdoc CHANGED
@@ -95,7 +95,9 @@ Given that you'd like to test the following class:
95
95
 
96
96
  === Unit tests
97
97
 
98
- Define your tests as methods beginning with +test_+.
98
+ Define your tests as methods beginning with +test_+. Use
99
+ {assertions}[/minitest/Minitest/Assertions.html] to test for results
100
+ or state.
99
101
 
100
102
  require "minitest/autorun"
101
103
 
@@ -119,6 +121,9 @@ Define your tests as methods beginning with +test_+.
119
121
 
120
122
  === Specs
121
123
 
124
+ Use {expectations}[/minitest/Minitest/Expectations.html] to check
125
+ results or state. They must be wrapped in a value call (eg +_+).
126
+
122
127
  require "minitest/autorun"
123
128
 
124
129
  describe Meme do
@@ -146,7 +151,7 @@ For matchers support check out:
146
151
 
147
152
  === Benchmarks
148
153
 
149
- Add benchmarks to your tests.
154
+ Add {benchmarks}[/minitest/Minitest/Benchmark.html] to your tests.
150
155
 
151
156
  # optionally run benchmarks, good for CI-only work!
152
157
  require "minitest/benchmark" if ENV["BENCH"]
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  # -*- ruby -*-
2
2
 
3
- require "rubygems"
4
3
  require "hoe"
5
4
  $:.unshift "lib" # to pick up lib/minitest/test_task.rb when minitest not installed
6
5
 
@@ -12,7 +11,7 @@ Hoe.spec "minitest" do
12
11
 
13
12
  license "MIT"
14
13
 
15
- require_ruby_version [">= 2.7", "< 4.0"]
14
+ require_ruby_version ">= 2.7"
16
15
  end
17
16
 
18
17
  desc "Find missing expectations"
data/design_rationale.rb CHANGED
@@ -2,25 +2,27 @@
2
2
  ###############################################################################
3
3
  describe Thingy do # class TestThingy < Minitest::Test
4
4
  before do # def setup
5
- do_some_setup # super
6
- end # do_some_setup
7
- # end
8
- it "should do the first thing" do #
9
- 1.must_equal 1 # def test_first_thing
10
- end # assert_equal 1, 1
11
- # end
12
- describe SubThingy do # end
13
- before do #
14
- do_more_setup # class TestSubThingy < TestThingy
15
- end # def setup
16
5
  # super
17
- it "should do the second thing" do # do_more_setup
18
- 2.must_equal 2 # end
19
- end #
20
- end # def test_second_thing
21
- end # assert_equal 2, 2
22
- # end
6
+ do_some_setup # do_some_setup
7
+ end # end
8
+ #
9
+ it "should do the first thing" do # def test_first_thing
10
+ _(1).must_equal 1 # assert_equal 1, 1
11
+ end # end
23
12
  # end
13
+ #
14
+ describe SubThingy do # class TestSubThingy < TestThingy
15
+ before do # def setup
16
+ # super
17
+ do_more_setup # do_more_setup
18
+ end # end
19
+ #
20
+ it "should do the second thing" do # def test_second_thing
21
+ _(2).must_equal 2 # assert_equal 2, 2
22
+ end # end
23
+ end # end
24
+ end #
25
+ #
24
26
  ###############################################################################
25
27
  # runs 2 specs # runs 3 tests
26
28
  ###############################################################################
@@ -33,7 +35,7 @@ class ThingySpec < Minitest::Spec
33
35
  end
34
36
 
35
37
  def test_should_do_the_first_thing
36
- assert_equal 1, 1
38
+ _(1).must_equal 1
37
39
  end
38
40
  end
39
41
 
@@ -47,6 +49,6 @@ class SubThingySpec < ThingySpec
47
49
  remove_method :test_should_do_the_first_thing
48
50
 
49
51
  def test_should_do_the_second_thing
50
- assert_equal 2, 2
52
+ _(2).must_equal 2
51
53
  end
52
54
  end
@@ -62,11 +62,11 @@ module Minitest
62
62
  return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
63
63
  expect
64
64
 
65
- Tempfile.open "expect" do |a|
65
+ Tempfile.create "expect" do |a|
66
66
  a.puts expect
67
67
  a.flush
68
68
 
69
- Tempfile.open "butwas" do |b|
69
+ Tempfile.create "butwas" do |b|
70
70
  b.puts butwas
71
71
  b.flush
72
72
 
@@ -500,14 +500,9 @@ module Minitest
500
500
  value = catch sym do
501
501
  begin
502
502
  yield
503
- rescue ThreadError => e # wtf?!? 1.8 + threads == suck
504
- default += ", not :#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
505
- rescue ArgumentError => e # 1.9 exception
503
+ rescue ArgumentError => e # 1.9+ exception
506
504
  raise e unless e.message.include? "uncaught throw"
507
505
  default += ", not #{e.message.split(/ /).last}"
508
- rescue NameError => e # 1.8 exception
509
- raise e unless e.name == sym
510
- default += ", not #{e.name.inspect}"
511
506
  end
512
507
  caught = false
513
508
  end
@@ -1,3 +1,5 @@
1
+ require "thread"
2
+
1
3
  module Minitest
2
4
  module Parallel # :nodoc:
3
5
 
data/lib/minitest/spec.rb CHANGED
@@ -38,7 +38,11 @@ class Module # :nodoc:
38
38
  end
39
39
  end
40
40
 
41
- Minitest::Expectation = Struct.new :target, :ctx # :nodoc:
41
+ # :stopdoc:
42
+ module Minitest # fucking hell rdoc...
43
+ Expectation = Struct.new :target, :ctx
44
+ end
45
+ # :startdoc:
42
46
 
43
47
  ##
44
48
  # Kernel extensions for minitest
@@ -285,9 +289,7 @@ class Minitest::Spec < Minitest::Test
285
289
  defined?(@name) ? @name : super
286
290
  end
287
291
 
288
- def to_s # :nodoc:
289
- name # Can't alias due to 1.8.7, not sure why
290
- end
292
+ alias to_s name
291
293
 
292
294
  attr_reader :desc # :nodoc:
293
295
  alias specify it
data/lib/minitest/test.rb CHANGED
@@ -58,6 +58,7 @@ module Minitest
58
58
  # tests are awesome.
59
59
 
60
60
  def self.parallelize_me!
61
+ return unless Minitest.parallel_executor
61
62
  include Minitest::Parallel::Test
62
63
  extend Minitest::Parallel::Test::ClassMethods
63
64
  end
@@ -44,8 +44,16 @@ module Minitest # :nodoc:
44
44
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # :nodoc:
45
45
 
46
46
  ##
47
- # Create several test-oriented tasks under +name+. Takes an
48
- # optional block to customize variables.
47
+ # Create several test-oriented tasks under +name+ (default:
48
+ # "test"). Takes an optional block to customize variables.
49
+ # Examples:
50
+ #
51
+ # Minitest::TestTask.create # named "test", all defaults
52
+ #
53
+ # Minitest::TestTask.create do |t|
54
+ # t.warning = false # my tests are noisy
55
+ # t.framework = %(require_relative "./test/helper.rb")
56
+ # end
49
57
 
50
58
  def self.create name = :test, &block
51
59
  task = new name
@@ -69,9 +77,18 @@ module Minitest # :nodoc:
69
77
 
70
78
  ##
71
79
  # The code to load the framework. Defaults to requiring
72
- # minitest/autorun...
80
+ # minitest/autorun.
81
+ #
82
+ # If you have a test helper file that requires minitest/autorun
83
+ # and anything else your project standardizes on, then you'll
84
+ # probably want to change this to:
73
85
  #
74
- # Why do I have this as an option?
86
+ # Minitest::TestTask.create do |t|
87
+ # t.framework = %(require_relative "./test/helper.rb")
88
+ # end
89
+ #
90
+ # or something similar. NOTE: if you do this, then helper must
91
+ # require "minitest/autorun" at the top to start the tests.
75
92
 
76
93
  attr_accessor :framework
77
94
 
@@ -100,6 +117,11 @@ module Minitest # :nodoc:
100
117
 
101
118
  ##
102
119
  # Optional: Additional ruby to run before the test framework is loaded.
120
+ # Example:
121
+ #
122
+ # Minitest::TestTask.create "test:cov" do |t|
123
+ # t.test_prelude = %(require "simplecov")
124
+ # end
103
125
 
104
126
  attr_accessor :test_prelude
105
127
 
data/lib/minitest.rb CHANGED
@@ -10,7 +10,7 @@ require_relative "minitest/compress"
10
10
  # runtime. See +Minitest.run+ for more information.
11
11
 
12
12
  module Minitest
13
- VERSION = "5.25.5" # :nodoc:
13
+ VERSION = "5.26.1" # :nodoc:
14
14
 
15
15
  @@installed_at_exit ||= false
16
16
  @@after_run = []
@@ -36,7 +36,7 @@ module Minitest
36
36
  warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"] && ENV["N"].to_i > 0
37
37
  n_threads = (ENV["MT_CPU"] || ENV["N"] || Etc.nprocessors).to_i
38
38
 
39
- self.parallel_executor = Parallel::Executor.new n_threads
39
+ self.parallel_executor = Parallel::Executor.new n_threads if n_threads > 1
40
40
 
41
41
  ##
42
42
  # Filter object for backtraces.
@@ -259,12 +259,13 @@ module Minitest
259
259
  # Minitest.process_args
260
260
  # Minitest.init_plugins
261
261
  # Minitest.__run(reporter, options)
262
- # Runnable.runnables.each
262
+ # Runnable.runnables.each |runnable_klass|
263
263
  # runnable_klass.run(reporter, options)
264
- # self.runnable_methods.each
265
- # self.run_one_method(self, runnable_method, reporter)
266
- # Minitest.run_one_method(klass, runnable_method)
267
- # klass.new(runnable_method).run
264
+ # filtered_methods = runnable_methods.select {...}.reject {...}
265
+ # filtered_methods.each |runnable_method|
266
+ # runnable_klass.run_one_method(self, runnable_method, reporter)
267
+ # Minitest.run_one_method(runnable_klass, runnable_method)
268
+ # runnable_klass.new(runnable_method).run
268
269
 
269
270
  def self.run args = []
270
271
  self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
@@ -286,18 +287,19 @@ module Minitest
286
287
  reporter.start
287
288
  begin
288
289
  __run reporter, options
290
+ finished = true
289
291
  rescue Interrupt
290
292
  warn "Interrupted. Exiting..."
291
293
  end
292
- self.parallel_executor.shutdown
294
+ self.parallel_executor.shutdown if parallel_executor.respond_to? :shutdown
293
295
 
294
296
  # might have been removed/replaced during init_plugins:
295
297
  summary = reporter.reporters.grep(SummaryReporter).first
296
298
 
297
299
  reporter.report
298
300
 
299
- return empty_run! options if summary && summary.count == 0
300
- reporter.passed?
301
+ return empty_run! options if finished && summary && summary.count == 0
302
+ finished and reporter.passed?
301
303
  end
302
304
 
303
305
  def self.empty_run! options # :nodoc:
@@ -409,6 +411,7 @@ module Minitest
409
411
  pos = Regexp.new $1 if pos.kind_of?(String) && pos =~ %r%/(.*)/%
410
412
  neg = Regexp.new $1 if neg.kind_of?(String) && neg =~ %r%/(.*)/%
411
413
 
414
+ # at most 1-2% slower than a 1-pass version, stop optimizing this
412
415
  filtered_methods = self.runnable_methods
413
416
  .select { |m| !pos || pos === m || pos === "#{self}##{m}" }
414
417
  .reject { |m| neg && (neg === m || neg === "#{self}##{m}") }
@@ -572,7 +575,7 @@ module Minitest
572
575
  def skipped?
573
576
  raise NotImplementedError, "subclass responsibility"
574
577
  end
575
- end
578
+ end # Runnable
576
579
 
577
580
  ##
578
581
  # Shared code for anything that can get passed to a Reporter. See
@@ -624,7 +627,7 @@ module Minitest
624
627
  def error?
625
628
  self.failures.any? UnexpectedError
626
629
  end
627
- end
630
+ end # Reportable
628
631
 
629
632
  ##
630
633
  # This represents a test result in a clean way that can be
@@ -678,7 +681,7 @@ module Minitest
678
681
  "#{failure.result_label}:\n#{self.location}:\n#{failure.message}\n"
679
682
  }.join "\n"
680
683
  end
681
- end
684
+ end # Result
682
685
 
683
686
  ##
684
687
  # Defines the API for Reporters. Subclass this and override whatever
@@ -728,7 +731,7 @@ module Minitest
728
731
  def synchronize &block # :nodoc:
729
732
  @mutex.synchronize(&block)
730
733
  end
731
- end
734
+ end # AbstractReportera
732
735
 
733
736
  class Reporter < AbstractReporter # :nodoc:
734
737
  ##
@@ -883,7 +886,7 @@ module Minitest
883
886
  self.warnings = aggregate[UnexpectedWarning].size
884
887
  self.skips = aggregate[Skip].size
885
888
  end
886
- end
889
+ end # StatisticsReporter
887
890
 
888
891
  ##
889
892
  # A reporter that prints the header, summary, and failure details at
@@ -961,7 +964,7 @@ module Minitest
961
964
  "%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
962
965
  [count, assertions, failures, errors, skips, extra.join]
963
966
  end
964
- end
967
+ end # SummaryReporter
965
968
 
966
969
  ##
967
970
  # Dispatch to multiple reporters as one.
@@ -1012,7 +1015,7 @@ module Minitest
1012
1015
  def report # :nodoc:
1013
1016
  self.reporters.each(&:report)
1014
1017
  end
1015
- end
1018
+ end # CompositeReporter
1016
1019
 
1017
1020
  ##
1018
1021
  # Represents run failures.
@@ -1079,7 +1082,7 @@ module Minitest
1079
1082
  self.error.backtrace
1080
1083
  end
1081
1084
 
1082
- BASE_RE = %r%#{Dir.pwd}/% # :nodoc:
1085
+ BASE_RE = %r%#{Regexp.escape Dir.pwd}/% # :nodoc:
1083
1086
 
1084
1087
  def message # :nodoc:
1085
1088
  bt = Minitest.filter_backtrace(self.backtrace).join("\n ")
@@ -318,13 +318,13 @@ class TestMinitestAssertions < Minitest::Test
318
318
  end
319
319
 
320
320
  def test_assert_equal_string_both_escaped_unescaped_newlines
321
- msg = <<~EOM
321
+ msg = <<~'EOM' # NOTE: single quotes on heredoc
322
322
  --- expected
323
323
  +++ actual
324
324
  @@ -1,2 +1 @@
325
- -"A\\n
325
+ -"A\n
326
326
  -B"
327
- +"A\\n\\\\nB"
327
+ +"A\n\\nB"
328
328
  EOM
329
329
 
330
330
  assert_triggered msg do
@@ -108,7 +108,7 @@ describe Minitest::Spec do
108
108
  end
109
109
 
110
110
  it "needs to catch an expected exception" do
111
- @assertion_count = 2
111
+ @assertion_count -= 2
112
112
 
113
113
  expect { raise "blah" }.must_raise RuntimeError
114
114
  expect { raise Minitest::Assertion }.must_raise Minitest::Assertion
@@ -710,8 +710,6 @@ describe Minitest::Spec do
710
710
  end
711
711
 
712
712
  describe Minitest::Spec, :let do
713
- i_suck_and_my_tests_are_order_dependent!
714
-
715
713
  def _count
716
714
  $let_count ||= 0
717
715
  end
@@ -722,21 +720,21 @@ describe Minitest::Spec, :let do
722
720
  end
723
721
 
724
722
  it "is evaluated once per example" do
725
- _(_count).must_equal 0
723
+ exp = _count + 1
726
724
 
727
- _(count).must_equal 1
728
- _(count).must_equal 1
725
+ _(count).must_equal exp
726
+ _(count).must_equal exp
729
727
 
730
- _(_count).must_equal 1
728
+ _(_count).must_equal exp
731
729
  end
732
730
 
733
731
  it "is REALLY evaluated once per example" do
734
- _(_count).must_equal 1
732
+ exp = _count + 1
735
733
 
736
- _(count).must_equal 2
737
- _(count).must_equal 2
734
+ _(count).must_equal exp
735
+ _(count).must_equal exp
738
736
 
739
- _(_count).must_equal 2
737
+ _(_count).must_equal exp
740
738
  end
741
739
 
742
740
  it 'raises an error if the name begins with "test"' do
@@ -662,7 +662,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
662
662
  2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
663
663
  EOM
664
664
 
665
- skip if Minitest.parallel_executor.size < 2 # locks up test runner if 1 CPU
665
+ skip unless Minitest.parallel_executor # locks up test runner if 1 CPU
666
666
 
667
667
  assert_report expected do |reporter|
668
668
  reporter.extend Module.new {
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.25.5
4
+ version: 5.26.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -28,7 +28,7 @@ cert_chain:
28
28
  bwfinv7Yp5fA6AysuZLhCykyfDuZVRrUp0Vb68YCKsLjJly/Theak+euNTxvHsB+
29
29
  al9oSgPPHICMEX65qvLywitx
30
30
  -----END CERTIFICATE-----
31
- date: 2025-03-12 00:00:00.000000000 Z
31
+ date: 1980-01-02 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rdoc
@@ -56,14 +56,14 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '4.2'
59
+ version: '4.3'
60
60
  type: :development
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '4.2'
66
+ version: '4.3'
67
67
  description: |-
68
68
  minitest provides a complete suite of testing facilities supporting
69
69
  TDD, BDD, mocking, and benchmarking.
@@ -176,16 +176,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
176
  - - ">="
177
177
  - !ruby/object:Gem::Version
178
178
  version: '2.7'
179
- - - "<"
180
- - !ruby/object:Gem::Version
181
- version: '4.0'
182
179
  required_rubygems_version: !ruby/object:Gem::Requirement
183
180
  requirements:
184
181
  - - ">="
185
182
  - !ruby/object:Gem::Version
186
183
  version: '0'
187
184
  requirements: []
188
- rubygems_version: 3.6.3
185
+ rubygems_version: 3.7.2
189
186
  specification_version: 4
190
187
  summary: minitest provides a complete suite of testing facilities supporting TDD,
191
188
  BDD, mocking, and benchmarking
metadata.gz.sig CHANGED
Binary file