minitest 5.23.1 → 5.24.1

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: eea239479abe950b2b6ac7881a88c73088fd9efc7dcddd5f54ceb7717830e7d7
4
- data.tar.gz: 645ac4943b4bb6d1a4cca710d10bfe6d6526ce78a99d5393aae1a91152a0bded
3
+ metadata.gz: d6452667dd5b1b7c8a083aebc718437613071b7b544b10d6974bc82d1236c900
4
+ data.tar.gz: 452965ff5a2b9e852174b81a9b762818da296869507ba1d16e6106bfe40c913b
5
5
  SHA512:
6
- metadata.gz: 6eb63425f42af466e8d839fa5de4f4dc57da32bc2a6798d40421ac99cc41b9c782a3fa7e91113463de0a261d1af6e8ddf2d3316fba5a141413f15b7fd4aedf73
7
- data.tar.gz: 8c60d2666e50e2c683b9f32363702ba5b529c7170b9c3d32df077fbc912430e6de76b1cc3f0fcdb72d03d0abaa75cda2b90c742ed9937115d7416008e45a45f1
6
+ metadata.gz: f98fdc87bd639f427d527552ed131233f31d9096e97643150df0bd732700070180cf2cb4a278531bd53faa780769404f606f35ea04ac44bf81652a700df20c3d
7
+ data.tar.gz: a1d99a1cdb10b6629e34e76848de7301e80ef85280a54629ca225bb1b9a0e644f83f2b43d51a39d21c97c6da8da47d23c5a96cf3fcc90088a63fe448097b287b
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,14 @@
1
+ === 5.24.0 / 2024-06-18
2
+
3
+ * 2 minor enhancements:
4
+
5
+ * Added Minitest.register_plugin.
6
+ * Extended plugin system to work with modules/classes for opt-out plugins.
7
+
8
+ * 1 bug fix:
9
+
10
+ * Removed anacronism, but allow load_plugins to exit gracefully if --disable=gems.
11
+
1
12
  === 5.23.1 / 2024-05-21
2
13
 
3
14
  * 1 bug fix:
@@ -1,10 +1,3 @@
1
- begin
2
- require "rubygems"
3
- gem "minitest"
4
- rescue Gem::LoadError
5
- # do nothing
6
- end
7
-
8
1
  require "minitest"
9
2
  require "minitest/spec"
10
3
  require "minitest/mock"
@@ -1,6 +1,12 @@
1
1
  require "shellwords"
2
2
  require "rbconfig"
3
- require "rake/tasklib"
3
+
4
+ begin
5
+ require "rake/tasklib"
6
+ rescue LoadError => e
7
+ warn e.message
8
+ return
9
+ end
4
10
 
5
11
  module Minitest # :nodoc:
6
12
 
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.23.1" # :nodoc:
12
+ VERSION = "5.24.0" # :nodoc:
13
13
 
14
14
  @@installed_at_exit ||= false
15
15
  @@after_run = []
@@ -98,20 +98,19 @@ module Minitest
98
98
  @@after_run << block
99
99
  end
100
100
 
101
- def self.init_plugins options # :nodoc:
102
- self.extensions.each do |name|
103
- msg = "plugin_#{name}_init"
104
- send msg, options if self.respond_to? msg
105
- end
101
+ ##
102
+ # Register a plugin to be used. Does NOT require / load it.
103
+
104
+ def self.register_plugin name_or_mod
105
+ self.extensions << name_or_mod
106
+ nil
106
107
  end
107
108
 
108
109
  def self.load_plugins # :nodoc:
109
- return unless self.extensions.empty?
110
+ return unless defined? Gem
110
111
 
111
112
  seen = {}
112
113
 
113
- require "rubygems" unless defined? Gem
114
-
115
114
  Gem.find_files("minitest/*_plugin.rb").each do |plugin_path|
116
115
  name = File.basename plugin_path, "_plugin.rb"
117
116
 
@@ -123,88 +122,22 @@ module Minitest
123
122
  end
124
123
  end
125
124
 
126
- ##
127
- # This is the top-level run method. Everything starts from here. It
128
- # tells each Runnable sub-class to run, and each of those are
129
- # responsible for doing whatever they do.
130
- #
131
- # The overall structure of a run looks like this:
132
- #
133
- # Minitest.autorun
134
- # Minitest.run(args)
135
- # Minitest.__run(reporter, options)
136
- # Runnable.runnables.each
137
- # runnable_klass.run(reporter, options)
138
- # self.runnable_methods.each
139
- # self.run_one_method(self, runnable_method, reporter)
140
- # Minitest.run_one_method(klass, runnable_method)
141
- # klass.new(runnable_method).run
142
-
143
- def self.run args = []
144
- self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
145
-
146
- options = process_args args
147
-
148
- Minitest.seed = options[:seed]
149
- srand Minitest.seed
150
-
151
- reporter = CompositeReporter.new
152
- reporter << SummaryReporter.new(options[:io], options)
153
- reporter << ProgressReporter.new(options[:io], options) unless options[:quiet]
154
-
155
- self.reporter = reporter # this makes it available to plugins
156
- self.init_plugins options
157
- self.reporter = nil # runnables shouldn't depend on the reporter, ever
158
-
159
- self.parallel_executor.start if parallel_executor.respond_to?(:start)
160
- reporter.start
161
- begin
162
- __run reporter, options
163
- rescue Interrupt
164
- warn "Interrupted. Exiting..."
125
+ def self.init_plugins options # :nodoc:
126
+ self.extensions.each do |mod_or_meth|
127
+ case mod_or_meth
128
+ when Symbol, String then
129
+ name = mod_or_meth
130
+ msg = "plugin_#{name}_init"
131
+ next unless self.respond_to? msg
132
+ send msg, options
133
+ when Module then
134
+ recv = mod_or_meth
135
+ next unless recv.respond_to? :minitest_plugin_init
136
+ recv.minitest_plugin_init options
137
+ else
138
+ raise ArgumentError, "plugin is %p, but it must be a symbol, string or module" % [mod_or_meth]
139
+ end
165
140
  end
166
- self.parallel_executor.shutdown
167
-
168
- # might have been removed/replaced during init_plugins:
169
- summary = reporter.reporters.grep(SummaryReporter).first
170
-
171
- reporter.report
172
-
173
- return empty_run! options if summary && summary.count == 0
174
- reporter.passed?
175
- end
176
-
177
- def self.empty_run! options # :nodoc:
178
- filter = options[:filter]
179
- return true unless filter # no filter, but nothing ran == success
180
-
181
- warn "Nothing ran for filter: %s" % [filter]
182
-
183
- require "did_you_mean" # soft dependency, punt if it doesn't load
184
-
185
- ms = Runnable.runnables.flat_map(&:runnable_methods)
186
- cs = DidYouMean::SpellChecker.new(dictionary: ms).correct filter
187
-
188
- warn DidYouMean::Formatter.message_for cs unless cs.empty?
189
- rescue LoadError
190
- # do nothing
191
- end
192
-
193
- ##
194
- # Internal run method. Responsible for telling all Runnable
195
- # sub-classes to run.
196
-
197
- def self.__run reporter, options
198
- suites = Runnable.runnables.shuffle
199
- parallel, serial = suites.partition { |s| s.test_order == :parallel }
200
-
201
- # If we run the parallel tests before the serial tests, the parallel tests
202
- # could run in parallel with the serial tests. This would be bad because
203
- # the serial tests won't lock around Reporter#record. Run the serial tests
204
- # first, so that after they complete, the parallel tests will lock when
205
- # recording results.
206
- serial.map { |suite| suite.run reporter, options } +
207
- parallel.map { |suite| suite.run reporter, options }
208
141
  end
209
142
 
210
143
  def self.process_args args = [] # :nodoc:
@@ -271,9 +204,19 @@ module Minitest
271
204
  opts.separator ""
272
205
  opts.separator "Known extensions: #{extensions.join(", ")}"
273
206
 
274
- extensions.each do |meth|
275
- msg = "plugin_#{meth}_options"
276
- send msg, opts, options if self.respond_to?(msg)
207
+ extensions.each do |mod_or_meth|
208
+ case mod_or_meth
209
+ when Symbol, String then
210
+ meth = mod_or_meth
211
+ msg = "plugin_#{meth}_options"
212
+ send msg, opts, options if respond_to?(msg)
213
+ when Module
214
+ recv = mod_or_meth
215
+ next unless recv.respond_to? :minitest_plugin_options
216
+ recv.minitest_plugin_options opts, options
217
+ else
218
+ raise ArgumentError, "plugin is %p, but it must be a symbol, string or module" % [mod_or_meth]
219
+ end
277
220
  end
278
221
  end
279
222
 
@@ -303,6 +246,93 @@ module Minitest
303
246
  options
304
247
  end
305
248
 
249
+ ##
250
+ # This is the top-level run method. Everything starts from here. It
251
+ # tells each Runnable sub-class to run, and each of those are
252
+ # responsible for doing whatever they do.
253
+ #
254
+ # The overall structure of a run looks like this:
255
+ #
256
+ # Minitest.autorun
257
+ # Minitest.run(args)
258
+ # Minitest.load_plugins
259
+ # Minitest.process_args
260
+ # Minitest.init_plugins
261
+ # Minitest.__run(reporter, options)
262
+ # Runnable.runnables.each
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
268
+
269
+ def self.run args = []
270
+ self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
271
+
272
+ options = process_args args
273
+
274
+ Minitest.seed = options[:seed]
275
+ srand Minitest.seed
276
+
277
+ reporter = CompositeReporter.new
278
+ reporter << SummaryReporter.new(options[:io], options)
279
+ reporter << ProgressReporter.new(options[:io], options) unless options[:quiet]
280
+
281
+ self.reporter = reporter # this makes it available to plugins
282
+ self.init_plugins options
283
+ self.reporter = nil # runnables shouldn't depend on the reporter, ever
284
+
285
+ self.parallel_executor.start if parallel_executor.respond_to?(:start)
286
+ reporter.start
287
+ begin
288
+ __run reporter, options
289
+ rescue Interrupt
290
+ warn "Interrupted. Exiting..."
291
+ end
292
+ self.parallel_executor.shutdown
293
+
294
+ # might have been removed/replaced during init_plugins:
295
+ summary = reporter.reporters.grep(SummaryReporter).first
296
+
297
+ reporter.report
298
+
299
+ return empty_run! options if summary && summary.count == 0
300
+ reporter.passed?
301
+ end
302
+
303
+ def self.empty_run! options # :nodoc:
304
+ filter = options[:filter]
305
+ return true unless filter # no filter, but nothing ran == success
306
+
307
+ warn "Nothing ran for filter: %s" % [filter]
308
+
309
+ require "did_you_mean" # soft dependency, punt if it doesn't load
310
+
311
+ ms = Runnable.runnables.flat_map(&:runnable_methods)
312
+ cs = DidYouMean::SpellChecker.new(dictionary: ms).correct filter
313
+
314
+ warn DidYouMean::Formatter.message_for cs unless cs.empty?
315
+ rescue LoadError
316
+ # do nothing
317
+ end
318
+
319
+ ##
320
+ # Internal run method. Responsible for telling all Runnable
321
+ # sub-classes to run.
322
+
323
+ def self.__run reporter, options
324
+ suites = Runnable.runnables.shuffle
325
+ parallel, serial = suites.partition { |s| s.test_order == :parallel }
326
+
327
+ # If we run the parallel tests before the serial tests, the parallel tests
328
+ # could run in parallel with the serial tests. This would be bad because
329
+ # the serial tests won't lock around Reporter#record. Run the serial tests
330
+ # first, so that after they complete, the parallel tests will lock when
331
+ # recording results.
332
+ serial.map { |suite| suite.run reporter, options } +
333
+ parallel.map { |suite| suite.run reporter, options }
334
+ end
335
+
306
336
  def self.filter_backtrace bt # :nodoc:
307
337
  result = backtrace_filter.filter bt
308
338
  result = bt.dup if result.empty?
@@ -957,8 +957,8 @@ class TestMinitestAssertions < Minitest::Test
957
957
  @tc.assert_same 1, 2
958
958
  end
959
959
 
960
- s1 = "blah"
961
- s2 = "blah"
960
+ s1 = +"blah"
961
+ s2 = +"blah"
962
962
 
963
963
  assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do
964
964
  @tc.assert_same s1, s2
@@ -1,5 +1,11 @@
1
1
  require "minitest/autorun"
2
- require "hoe"
2
+
3
+ begin
4
+ require "hoe"
5
+ rescue LoadError => e
6
+ warn e.message
7
+ return
8
+ end
3
9
 
4
10
  require "minitest/test_task"
5
11
 
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.23.1
4
+ version: 5.24.1
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-05-22 00:00:00.000000000 Z
32
+ date: 2024-06-29 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdoc
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  requirements: []
190
- rubygems_version: 3.5.3
190
+ rubygems_version: 3.5.14
191
191
  signing_key:
192
192
  specification_version: 4
193
193
  summary: minitest provides a complete suite of testing facilities supporting TDD,
metadata.gz.sig CHANGED
Binary file