minitest 5.20.0 → 5.24.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: 667a803a272949e7b05440f91a56155ea3977a5b9d364542801889c5a2fe0ff0
4
- data.tar.gz: 862bf0ff3d24eea4bbe6c7f435ceef19aaa97748f6a87ec3fa51dc218ca79298
3
+ metadata.gz: d6452667dd5b1b7c8a083aebc718437613071b7b544b10d6974bc82d1236c900
4
+ data.tar.gz: 452965ff5a2b9e852174b81a9b762818da296869507ba1d16e6106bfe40c913b
5
5
  SHA512:
6
- metadata.gz: 2284c84ae5f98a3454e9a95417e609ca1a8ef9af8ee8b1fad8f2aca2632fde6a309e266ef1d399d9a7d47337cdcba696500a1b36f1fa7d952615eb390a89e329
7
- data.tar.gz: a76204f74c2caf693a4302065815b871863ae655372d25fc4d41e416b0d4935704c1e1068457b5cda934312e3915ae8a27595ca962c98e544dd45b54cac2aef7
6
+ metadata.gz: f98fdc87bd639f427d527552ed131233f31d9096e97643150df0bd732700070180cf2cb4a278531bd53faa780769404f606f35ea04ac44bf81652a700df20c3d
7
+ data.tar.gz: a1d99a1cdb10b6629e34e76848de7301e80ef85280a54629ca225bb1b9a0e644f83f2b43d51a39d21c97c6da8da47d23c5a96cf3fcc90088a63fe448097b287b
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,102 @@
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
+
12
+ === 5.23.1 / 2024-05-21
13
+
14
+ * 1 bug fix:
15
+
16
+ * Fully qualify the Queue class to avoid conflicts with other libraries. (rafaelfranca)
17
+
18
+ === 5.23.0 / 2024-05-15
19
+
20
+ * 3 minor enhancements:
21
+
22
+ * Added -Werror to raise on any warning output. (byroot)
23
+ * Added UnexpectedWarning as a failure summary type, added count to output if activated.
24
+ * Added minitest/manual_plugins.rb w/ new Minitest.load method. (tenderlove)
25
+
26
+ * 2 bug fixes:
27
+
28
+ * Allow empty_run! and reporter to display summary for empty runs. (zzak)
29
+ * Make test task verbose using either rake's -v or -t (was just -t).
30
+
31
+ === 5.22.3 / 2024-03-13
32
+
33
+ * 1 minor enhancement:
34
+
35
+ * MASSIVE improvement of minitest's pride plugin output: Frequencies doubled! Sine waves shifted!! Comments improved!!! Colors rotated!!!! (havenwood)
36
+
37
+ * 3 bug fixes:
38
+
39
+ * Improved wording on Minitest::Test#parallelize_me! to clarify it goes INSIDE your test class/describe.
40
+ * Minor changes to tests to pass when tests ran with extra flags (eg -p).
41
+ * Support Ruby 3.4's new error message format. (mame)
42
+
43
+ === 5.22.2 / 2024-02-07
44
+
45
+ * 1 bug fix:
46
+
47
+ * Third time's a charm? Remember: 'ensure' is almost always the
48
+ wrong way to go (for results... it's great for cleaning up).
49
+
50
+ === 5.22.1 / 2024-02-06
51
+
52
+ * 1 bug fix:
53
+
54
+ * Don't exit non-zero if no tests ran and no filter (aka, the test file is empty).
55
+ (I'm starting to think the exit 1 thing for @tenderlove was a mistake...)
56
+
57
+ === 5.22.0 / 2024-02-05
58
+
59
+ * 1 minor enhancement:
60
+
61
+ * Added "did you mean" output if your --name filter matches nothing. (tenderlove)
62
+
63
+ * 2 bug fixes:
64
+
65
+ * Big cleanup of test filtering. Much prettier / more functional.
66
+ * Fix situation where Assertion#location can't find the location. (pftg)
67
+
68
+ === 5.21.2 / 2024-01-17
69
+
70
+ * 1 bug fix:
71
+
72
+ * Fixed bug in Minitest::Compress#compress formatting w/ nested patterns. Now recurses properly.
73
+
74
+ === 5.21.1 / 2024-01-11
75
+
76
+ * 1 bug fix:
77
+
78
+ * Rails' default backtrace filter can't currently work with caller_locations, so reverting back to caller.
79
+
80
+ === 5.21.0 / 2024-01-11
81
+
82
+ * 10 minor enhancements:
83
+
84
+ * Add include_all kw arg to assert_respond_to and refute_respond_to.
85
+ * Added --quiet flag to skip ProgressReporter (prints the dots). Minor speedup.
86
+ * Added Minitest::Compress#compress and added it to UnexpectedError.
87
+ * Added ability to initialize BacktraceFilter w/ custom regexp.
88
+ * Filter failure backtraces using backtrace_filter before calculating location. (thomasmarshall)
89
+ * Make BacktraceFilter#filter compatible with locations (still compares strings).
90
+ * Optimized Assertion#location ~30%.
91
+ * Output relative paths for all failures/errors/backtraces.
92
+ * Refactored location information in assertions, now using locations.
93
+ * Removed thread and mutex_m dependencies. (hsbt, eregon)
94
+
95
+ * 2 bug fixes:
96
+
97
+ * Drop undocumented bt arg in #skip. Dunno why that ever happened, prolly for testing?
98
+ * Fix mock to work with ruby debugger enabled. (keithlayne)
99
+
1
100
  === 5.20.0 / 2023-09-06
2
101
 
3
102
  * 1 minor enhancement:
@@ -9,7 +108,7 @@
9
108
  * 2 minor enhancements:
10
109
 
11
110
  * Add metadata lazy accessor to Runnable / Result. (matteeyah)
12
- * Only load minitest/unit (aka ancient MiniTest compatibility layer) if ENV["MT_COMPAT"]
111
+ * Only load minitest/unit (aka ancient MiniTest compatibility layer) if \ENV[\"MT_COMPAT\"]
13
112
 
14
113
  * 1 bug fix:
15
114
 
@@ -20,7 +119,7 @@
20
119
  * 3 bug fixes:
21
120
 
22
121
  * Avoid extra string allocations when filtering tests. (tenderlove)
23
- * Only mention deprecated ENV['N'] if it is an integer string.
122
+ * Only mention deprecated \ENV[\'N\'] if it is an integer string.
24
123
  * Push up test_order to Minitest::Runnable to fix minitest/hell. (koic)
25
124
 
26
125
  === 5.18.0 / 2023-03-04
@@ -214,7 +313,7 @@
214
313
 
215
314
  * 3 bug fixes:
216
315
 
217
- * Check `option[:filter]` klass before match. Fixes 2.6 warning. (y-yagi)
316
+ * Check \option[:filter] klass before match. Fixes 2.6 warning. (y-yagi)
218
317
  * Fixed Assertions#diff from recalculating if set to nil
219
318
  * Fixed spec section of readme to not use deprecated global expectations. (CheezItMan)
220
319
 
data/Manifest.txt CHANGED
@@ -9,8 +9,11 @@ lib/minitest.rb
9
9
  lib/minitest/assertions.rb
10
10
  lib/minitest/autorun.rb
11
11
  lib/minitest/benchmark.rb
12
+ lib/minitest/compress.rb
13
+ lib/minitest/error_on_warning.rb
12
14
  lib/minitest/expectations.rb
13
15
  lib/minitest/hell.rb
16
+ lib/minitest/manual_plugins.rb
14
17
  lib/minitest/mock.rb
15
18
  lib/minitest/parallel.rb
16
19
  lib/minitest/pride.rb
data/README.rdoc CHANGED
@@ -3,6 +3,7 @@
3
3
  home :: https://github.com/minitest/minitest
4
4
  bugs :: https://github.com/minitest/minitest/issues
5
5
  rdoc :: https://docs.seattlerb.org/minitest
6
+ clog :: https://github.com/minitest/minitest/blob/master/History.rdoc
6
7
  vim :: https://github.com/sunaku/vim-ruby-minitest
7
8
  emacs:: https://github.com/arthurnn/minitest-emacs
8
9
 
@@ -405,22 +406,23 @@ Using our example above, here is how we might implement MyCI:
405
406
 
406
407
  === What versions are compatible with what? Or what versions are supported?
407
408
 
408
- 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
409
410
  overzealous backwards compatibility policy. As such, I'm stuck
410
411
  supporting versions of ruby that are long past EOL. Hopefully I'll be
411
412
  able to support only current versions of ruby sometime in the near
412
413
  future.
413
414
 
414
- (As of 2023-03-05)
415
+ (As of 2024-05-10)
415
416
 
416
417
  Current versions of rails: (https://endoflife.date/rails)
417
418
 
418
- | rails | min ruby | rec ruby | minitest | status | EOL Date |
419
- |-------+----------+----------+----------+----------+------------|
420
- | 7.0 | >= 2.7 | 3.1 | >= 5.1 | Current | 2025-06-01?|
421
- | 6.1 | >= 2.5 | 3.0 | >= 5.1 | Maint | 2024-06-01?|
422
- | 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security | 2023-06-01 |
423
- | 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 |
424
426
 
425
427
  If you want to look at the requirements for a specific version, run:
426
428
 
@@ -430,12 +432,13 @@ Current versions of ruby: (https://endoflife.date/ruby)
430
432
 
431
433
  | ruby | Status | EOL Date |
432
434
  |------+---------+------------|
433
- | 3.2 | Current | 2026-03-31 |
434
- | 3.1 | Maint | 2025-03-31 |
435
- | 3.0 | Maint | 2024-03-31 |
436
- | 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 |
437
440
  | 2.6 | EOL | 2022-03-31 |
438
- | 2.5 | EOL | 2021-03-31 |
441
+ | 2.5 | EOL | 2021-03-31 | DO YOU SEE WHAT I'M STUCK WITH???
439
442
 
440
443
  === How to test SimpleDelegates?
441
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
@@ -198,6 +198,11 @@ module Minitest
198
198
  assert obj.empty?, msg
199
199
  end
200
200
 
201
+ def _where # :nodoc:
202
+ where = Minitest.filter_backtrace(caller).first
203
+ where = where.split(/:in /, 2).first # clean up noise
204
+ end
205
+
201
206
  E = "" # :nodoc:
202
207
 
203
208
  ##
@@ -221,10 +226,7 @@ module Minitest
221
226
  if Minitest::VERSION =~ /^6/ then
222
227
  refute_nil exp, "Use assert_nil if expecting nil."
223
228
  else
224
- where = Minitest.filter_backtrace(caller).first
225
- where = where.split(/:in /, 2).first # clean up noise
226
-
227
- warn "DEPRECATED: Use assert_nil if expecting nil from #{where}. This will fail in Minitest 6."
229
+ warn "DEPRECATED: Use assert_nil if expecting nil from #{_where}. This will fail in Minitest 6."
228
230
  end
229
231
  end
230
232
 
@@ -449,12 +451,13 @@ module Minitest
449
451
 
450
452
  ##
451
453
  # Fails unless +obj+ responds to +meth+.
454
+ # include_all defaults to false to match Object#respond_to?
452
455
 
453
- def assert_respond_to obj, meth, msg = nil
456
+ def assert_respond_to obj, meth, msg = nil, include_all: false
454
457
  msg = message(msg) {
455
458
  "Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
456
459
  }
457
- assert obj.respond_to?(meth), msg
460
+ assert obj.respond_to?(meth, include_all), msg
458
461
  end
459
462
 
460
463
  ##
@@ -474,9 +477,7 @@ module Minitest
474
477
  # Fails unless the call returns a true value
475
478
 
476
479
  def assert_send send_ary, m = nil
477
- where = Minitest.filter_backtrace(caller).first
478
- where = where.split(/:in /, 2).first # clean up noise
479
- warn "DEPRECATED: assert_send. From #{where}"
480
+ warn "DEPRECATED: assert_send. From #{_where}"
480
481
 
481
482
  recv, msg, *args = send_ary
482
483
  m = message(m) {
@@ -807,11 +808,12 @@ module Minitest
807
808
 
808
809
  ##
809
810
  # Fails if +obj+ responds to the message +meth+.
811
+ # include_all defaults to false to match Object#respond_to?
810
812
 
811
- def refute_respond_to obj, meth, msg = nil
813
+ def refute_respond_to obj, meth, msg = nil, include_all: false
812
814
  msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
813
815
 
814
- refute obj.respond_to?(meth), msg
816
+ refute obj.respond_to?(meth, include_all), msg
815
817
  end
816
818
 
817
819
  ##
@@ -830,10 +832,10 @@ module Minitest
830
832
  # gets listed at the end of the run but doesn't cause a failure
831
833
  # exit code.
832
834
 
833
- def skip msg = nil, bt = caller
835
+ def skip msg = nil, _ignored = nil
834
836
  msg ||= "Skipped, no message given"
835
837
  @skip = true
836
- raise Minitest::Skip, msg, bt
838
+ raise Minitest::Skip, msg
837
839
  end
838
840
 
839
841
  ##
@@ -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"
@@ -0,0 +1,94 @@
1
+ module Minitest
2
+ ##
3
+ # Compresses backtraces.
4
+
5
+ module Compress
6
+
7
+ ##
8
+ # Takes a backtrace (array of strings) and compresses repeating
9
+ # cycles in it to make it more readable.
10
+
11
+ def compress orig
12
+ ary = orig
13
+
14
+ eswo = ->(ary, n, off) { # each_slice_with_offset
15
+ if off.zero? then
16
+ ary.each_slice n
17
+ else
18
+ # [ ...off... [...n...] [...n...] ... ]
19
+ front, back = ary.take(off), ary.drop(off)
20
+ [front].chain back.each_slice n
21
+ end
22
+ }
23
+
24
+ 3.times do # maybe don't use loop do here?
25
+ index = ary # [ a b c b c b c d ]
26
+ .size
27
+ .times # 0...size
28
+ .group_by { |i| ary[i] } # { a: [0] b: [1 3 5], c: [2 4 6], d: [7] }
29
+
30
+ order = index
31
+ .reject { |k, v| v.size == 1 } # { b: [1 3 5], c: [2 4 6] }
32
+ .sort_by { |k, ary| ### sort by max dist + min offset
33
+ d = ary.each_cons(2).sum { |a, b| b-a }
34
+ [-d, ary.first]
35
+ } # b: [1 3 5] c: [2 4 6]
36
+
37
+ ranges = order
38
+ .map { |k, ary| # [[1..2 3..4] [2..3 4..5]]
39
+ ary
40
+ .each_cons(2)
41
+ .map { |a, b| a..b-1 }
42
+ }
43
+
44
+ big_ranges = ranges
45
+ .flat_map { |a| # [1..2 3..4 2..3 4..5]
46
+ a.sort_by { |r| [-r.size, r.first] }.first 5
47
+ }
48
+ .first(100)
49
+
50
+ culprits = big_ranges
51
+ .map { |r|
52
+ eswo[ary, r.size, r.begin] # [o1 s1 s1 s2 s2]
53
+ .chunk_while { |a,b| a == b } # [[o1] [s1 s1] [s2 s2]]
54
+ .map { |a| [a.size, a.first] } # [[1 o1] [2 s1] [2 s2]]
55
+ }
56
+ .select { |chunks|
57
+ chunks.any? { |a| a.first > 1 } # compressed anything?
58
+ }
59
+
60
+ min = culprits
61
+ .min_by { |a| a.flatten.size } # most compressed
62
+
63
+ break unless min
64
+
65
+ ary = min.flat_map { |(n, lines)|
66
+ if n > 1 then
67
+ [[n, compress(lines)]] # [o1 [2 s1] [2 s2]]
68
+ else
69
+ lines
70
+ end
71
+ }
72
+ end
73
+
74
+ format = ->(lines) {
75
+ lines.flat_map { |line|
76
+ case line
77
+ when Array then
78
+ n, lines = line
79
+ lines = format[lines]
80
+ [
81
+ " +->> #{n} cycles of #{lines.size} lines:",
82
+ *lines.map { |s| " | #{s}" },
83
+ " +-<<",
84
+ ]
85
+ else
86
+ line
87
+ end
88
+ }
89
+ }
90
+
91
+ format[ary]
92
+ end
93
+ end
94
+ end
@@ -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
data/lib/minitest/mock.rb CHANGED
@@ -10,7 +10,7 @@ module Minitest # :nodoc:
10
10
  class Mock
11
11
  alias :__respond_to? :respond_to?
12
12
 
13
- overridden_methods = %w[
13
+ overridden_methods = %i[
14
14
  ===
15
15
  class
16
16
  inspect
@@ -23,8 +23,10 @@ module Minitest # :nodoc:
23
23
  to_s
24
24
  ]
25
25
 
26
+ overridden_methods << :singleton_method_added if defined?(::DEBUGGER__)
27
+
26
28
  instance_methods.each do |m|
27
- undef_method m unless overridden_methods.include?(m.to_s) || m =~ /^__/
29
+ undef_method m unless overridden_methods.include?(m) || m =~ /^__/
28
30
  end
29
31
 
30
32
  overridden_methods.map(&:to_sym).each do |method_id|
@@ -16,7 +16,7 @@ module Minitest
16
16
 
17
17
  def initialize size
18
18
  @size = size
19
- @queue = Queue.new
19
+ @queue = Thread::Queue.new
20
20
  @pool = nil
21
21
  end
22
22
 
@@ -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
@@ -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
 
@@ -114,7 +120,7 @@ module Minitest # :nodoc:
114
120
  self.test_globs = ["test/**/test_*.rb",
115
121
  "test/**/*_test.rb"]
116
122
  self.test_prelude = nil
117
- self.verbose = Rake.application.options.trace
123
+ self.verbose = Rake.application.options.trace || Rake.verbose == true
118
124
  self.warning = true
119
125
  end
120
126
 
@@ -288,7 +294,6 @@ end
288
294
 
289
295
  class Integer # :nodoc:
290
296
  def threads_do(jobs) # :nodoc:
291
- require "thread"
292
297
  q = Work.new jobs
293
298
 
294
299
  self.times.map {