minitest 5.18.0 → 5.22.3

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: 27d1d24e16ba576cc5a425d6e09e3de81465d10104a647c21ad9a5df36be1551
4
- data.tar.gz: c3ca5dd490b7d08ee3254c7c8a680af0675f72e5356ad97b55dd1ec67e27251d
3
+ metadata.gz: 549d1470d48f7424db415007d45cfd317ad88104e1e5004e97c46afa4d760a1a
4
+ data.tar.gz: f6f2e952c63cb9074d2fccf45148ab5c5045aec5bdbeadfadcbbf8338107ec2d
5
5
  SHA512:
6
- metadata.gz: f545c292aabb802ae8e03cea73bf2334a8ac6dea7da411b8e6ad48e036b00eabac550e5405c11aea175b30a9d65aced4e3601258081e845299ff6e1dbffd353d
7
- data.tar.gz: ae62ac5c0f4218b66fe0206eb0205828c872531d6b68a4b0537fbe4b0a8753ccf604b4d11a11322dc329b275a1428683125c061e6e255f90ff5a076e4afb02ad
6
+ metadata.gz: da1e40c0087e97affdab34c247b98d5d4482ba47d3a0b677dcef4ebf0839827e304fba101a02fcebd38008a8d9ba9eaa163e98545d13927b276dcb461dac7237
7
+ data.tar.gz: c4074d137040f0362af40a5cd9c637492ba983a0a8ab5341c2acb8d531725b10192c40b6002570695aca6da1c0c1bdb389a6eac94cefcda8a6b60d48b49c960d
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,85 @@
1
+ === 5.22.2 / 2024-02-07
2
+
3
+ * 1 bug fix:
4
+
5
+ * Third time's a charm? Remember: 'ensure' is almost always the
6
+ wrong way to go (for results... it's great for cleaning up).
7
+
8
+ === 5.22.1 / 2024-02-06
9
+
10
+ * 1 bug fix:
11
+
12
+ * Don't exit non-zero if no tests ran and no filter (aka, the test file is empty).
13
+ (I'm starting to think the exit 1 thing for @tenderlove was a mistake...)
14
+
15
+ === 5.22.0 / 2024-02-05
16
+
17
+ * 1 minor enhancement:
18
+
19
+ * Added "did you mean" output if your --name filter matches nothing. (tenderlove)
20
+
21
+ * 2 bug fixes:
22
+
23
+ * Big cleanup of test filtering. Much prettier / more functional.
24
+ * Fix situation where Assertion#location can't find the location. (pftg)
25
+
26
+ === 5.21.2 / 2024-01-17
27
+
28
+ * 1 bug fix:
29
+
30
+ * Fixed bug in Minitest::Compress#compress formatting w/ nested patterns. Now recurses properly.
31
+
32
+ === 5.21.1 / 2024-01-11
33
+
34
+ * 1 bug fix:
35
+
36
+ * Rails' default backtrace filter can't currently work with caller_locations, so reverting back to caller.
37
+
38
+ === 5.21.0 / 2024-01-11
39
+
40
+ * 10 minor enhancements:
41
+
42
+ * Add include_all kw arg to assert_respond_to and refute_respond_to.
43
+ * Added --quiet flag to skip ProgressReporter (prints the dots). Minor speedup.
44
+ * Added Minitest::Compress#compress and added it to UnexpectedError.
45
+ * Added ability to initialize BacktraceFilter w/ custom regexp.
46
+ * Filter failure backtraces using backtrace_filter before calculating location. (thomasmarshall)
47
+ * Make BacktraceFilter#filter compatible with locations (still compares strings).
48
+ * Optimized Assertion#location ~30%.
49
+ * Output relative paths for all failures/errors/backtraces.
50
+ * Refactored location information in assertions, now using locations.
51
+ * Removed thread and mutex_m dependencies. (hsbt, eregon)
52
+
53
+ * 2 bug fixes:
54
+
55
+ * Drop undocumented bt arg in #skip. Dunno why that ever happened, prolly for testing?
56
+ * Fix mock to work with ruby debugger enabled. (keithlayne)
57
+
58
+ === 5.20.0 / 2023-09-06
59
+
60
+ * 1 minor enhancement:
61
+
62
+ * Optionally allow autorun exit hook to remain active in forked child. (casperisfine)
63
+
64
+ === 5.19.0 / 2023-07-26
65
+
66
+ * 2 minor enhancements:
67
+
68
+ * Add metadata lazy accessor to Runnable / Result. (matteeyah)
69
+ * Only load minitest/unit (aka ancient MiniTest compatibility layer) if \ENV[\"MT_COMPAT\"]
70
+
71
+ * 1 bug fix:
72
+
73
+ * Minitest::TestTask enthusiastically added itself to default. (ParadoxV5)
74
+
75
+ === 5.18.1 / 2023-06-16
76
+
77
+ * 3 bug fixes:
78
+
79
+ * Avoid extra string allocations when filtering tests. (tenderlove)
80
+ * Only mention deprecated \ENV[\'N\'] if it is an integer string.
81
+ * Push up test_order to Minitest::Runnable to fix minitest/hell. (koic)
82
+
1
83
  === 5.18.0 / 2023-03-04
2
84
 
3
85
  * 2 major enhancements:
@@ -189,7 +271,7 @@
189
271
 
190
272
  * 3 bug fixes:
191
273
 
192
- * Check `option[:filter]` klass before match. Fixes 2.6 warning. (y-yagi)
274
+ * Check \option[:filter] klass before match. Fixes 2.6 warning. (y-yagi)
193
275
  * Fixed Assertions#diff from recalculating if set to nil
194
276
  * Fixed spec section of readme to not use deprecated global expectations. (CheezItMan)
195
277
 
data/Manifest.txt CHANGED
@@ -9,6 +9,7 @@ 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
12
13
  lib/minitest/expectations.rb
13
14
  lib/minitest/hell.rb
14
15
  lib/minitest/mock.rb
data/README.rdoc CHANGED
@@ -1,8 +1,9 @@
1
1
  = minitest/{test,spec,mock,benchmark}
2
2
 
3
- home :: https://github.com/seattlerb/minitest
4
- bugs :: https://github.com/seattlerb/minitest/issues
3
+ home :: https://github.com/minitest/minitest
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
 
@@ -411,7 +412,7 @@ 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 2022-11-29)
415
+ (As of 2023-03-05)
415
416
 
416
417
  Current versions of rails: (https://endoflife.date/rails)
417
418
 
@@ -422,20 +423,21 @@ Current versions of rails: (https://endoflife.date/rails)
422
423
  | 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security | 2023-06-01 |
423
424
  | 5.2 | >= 2.2.2 | 2.5 | ~> 5.1 | EOL | 2022-06-01 |
424
425
 
426
+ If you want to look at the requirements for a specific version, run:
427
+
428
+ gem spec -r --ruby rails -v 7.0.0
429
+
425
430
  Current versions of ruby: (https://endoflife.date/ruby)
426
431
 
427
432
  | ruby | Status | EOL Date |
428
433
  |------+---------+------------|
429
- | 3.1 | Current | 2025-12-25 |
434
+ | 3.2 | Current | 2026-03-31 |
435
+ | 3.1 | Maint | 2025-03-31 |
430
436
  | 3.0 | Maint | 2024-03-31 |
431
- | 2.7 | Maint* | 2023-03-31 |
437
+ | 2.7 | Security| 2023-03-31 |
432
438
  | 2.6 | EOL | 2022-03-31 |
433
439
  | 2.5 | EOL | 2021-03-31 |
434
440
 
435
- See also:
436
-
437
- * https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
438
-
439
441
  === How to test SimpleDelegates?
440
442
 
441
443
  The following implementation and test:
@@ -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
  ##
@@ -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
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|
@@ -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
@@ -80,14 +81,6 @@ module Minitest
80
81
  end
81
82
  end
82
83
 
83
- ##
84
- # Defines the order to run tests (:random by default). Override
85
- # this or use a convenience method to change it for your tests.
86
-
87
- def self.test_order
88
- :random
89
- end
90
-
91
84
  ##
92
85
  # Runs a single test with setup/teardown hooks.
93
86
 
@@ -149,7 +142,7 @@ module Minitest
149
142
  # end
150
143
  # end
151
144
  #
152
- # class MiniTest::Test
145
+ # class Minitest::Test
153
146
  # include MyMinitestPlugin
154
147
  # end
155
148
 
@@ -253,4 +246,4 @@ module Minitest
253
246
  end # Test
254
247
  end
255
248
 
256
- require "minitest/unit" unless defined?(MiniTest) # compatibility layer only
249
+ require "minitest/unit" if ENV["MT_COMPAT"] # compatibility layer only
@@ -29,6 +29,10 @@ module Minitest # :nodoc:
29
29
  # end
30
30
  #
31
31
  # Customize the name and only run unit tests.
32
+ #
33
+ # NOTE: To hook this task up to the default, make it a dependency:
34
+ #
35
+ # task default: :unit
32
36
 
33
37
  class TestTask < Rake::TaskLib
34
38
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # :nodoc:
@@ -157,8 +161,6 @@ module Minitest # :nodoc:
157
161
  end
158
162
 
159
163
  def define # :nodoc:
160
- default_tasks = []
161
-
162
164
  desc "Run the test suite. Use N, X, A, and TESTOPTS to add flags/args."
163
165
  task name do
164
166
  ruby make_test_cmd, verbose:verbose
@@ -243,11 +245,6 @@ module Minitest # :nodoc:
243
245
  "sort -n -k2 -t=",
244
246
  "tail -25"].join " | "
245
247
  end
246
-
247
- default_tasks << name
248
-
249
- desc "Run the default task(s)."
250
- task :default => default_tasks
251
248
  end
252
249
 
253
250
  ##
@@ -291,7 +288,6 @@ end
291
288
 
292
289
  class Integer # :nodoc:
293
290
  def threads_do(jobs) # :nodoc:
294
- require "thread"
295
291
  q = Work.new jobs
296
292
 
297
293
  self.times.map {