minitest 5.22.3 → 5.25.4
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 +4 -4
- checksums.yaml.gz.sig +2 -2
- data/History.rdoc +95 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +15 -13
- data/Rakefile +6 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +64 -69
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +10 -10
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +35 -17
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +10 -14
- data/lib/minitest/spec.rb +13 -12
- data/lib/minitest/test.rb +10 -22
- data/lib/minitest/test_task.rb +17 -11
- data/lib/minitest.rb +206 -136
- data/test/minitest/metametameta.rb +18 -10
- data/test/minitest/test_minitest_assertions.rb +133 -134
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +150 -78
- data/test/minitest/test_minitest_reporter.rb +18 -22
- data/test/minitest/test_minitest_spec.rb +73 -56
- data/test/minitest/test_minitest_test.rb +84 -103
- data/test/minitest/test_minitest_test_task.rb +18 -9
- data.tar.gz.sig +0 -0
- metadata +5 -3
- metadata.gz.sig +0 -0
    
        data/lib/minitest/benchmark.rb
    CHANGED
    
    | @@ -47,8 +47,6 @@ module Minitest | |
| 47 47 |  | 
| 48 48 | 
             
                def self.bench_linear min, max, step = 10
         | 
| 49 49 | 
             
                  (min..max).step(step).to_a
         | 
| 50 | 
            -
                rescue LocalJumpError # 1.8.6
         | 
| 51 | 
            -
                  r = []; (min..max).step(step) { |n| r << n }; r
         | 
| 52 50 | 
             
                end
         | 
| 53 51 |  | 
| 54 52 | 
             
                ##
         | 
| @@ -83,7 +81,7 @@ module Minitest | |
| 83 81 | 
             
                def assert_performance validation, &work
         | 
| 84 82 | 
             
                  range = self.class.bench_range
         | 
| 85 83 |  | 
| 86 | 
            -
                  io.print  | 
| 84 | 
            +
                  io.print self.name
         | 
| 87 85 |  | 
| 88 86 | 
             
                  times = []
         | 
| 89 87 |  | 
| @@ -236,7 +234,7 @@ module Minitest | |
| 236 234 |  | 
| 237 235 | 
             
                def fit_exponential xs, ys
         | 
| 238 236 | 
             
                  n     = xs.size
         | 
| 239 | 
            -
                  xys   = xs.zip | 
| 237 | 
            +
                  xys   = xs.zip ys
         | 
| 240 238 | 
             
                  sxlny = sigma(xys) { |x, y| x * Math.log(y) }
         | 
| 241 239 | 
             
                  slny  = sigma(xys) { |_, y| Math.log(y)     }
         | 
| 242 240 | 
             
                  sx2   = sigma(xys) { |x, _| x * x           }
         | 
| @@ -258,7 +256,7 @@ module Minitest | |
| 258 256 |  | 
| 259 257 | 
             
                def fit_logarithmic xs, ys
         | 
| 260 258 | 
             
                  n     = xs.size
         | 
| 261 | 
            -
                  xys   = xs.zip | 
| 259 | 
            +
                  xys   = xs.zip ys
         | 
| 262 260 | 
             
                  slnx2 = sigma(xys) { |x, _| Math.log(x) ** 2 }
         | 
| 263 261 | 
             
                  slnx  = sigma(xys) { |x, _| Math.log(x)      }
         | 
| 264 262 | 
             
                  sylnx = sigma(xys) { |x, y| y * Math.log(x)  }
         | 
| @@ -280,7 +278,7 @@ module Minitest | |
| 280 278 |  | 
| 281 279 | 
             
                def fit_linear xs, ys
         | 
| 282 280 | 
             
                  n   = xs.size
         | 
| 283 | 
            -
                  xys = xs.zip | 
| 281 | 
            +
                  xys = xs.zip ys
         | 
| 284 282 | 
             
                  sx  = sigma xs
         | 
| 285 283 | 
             
                  sy  = sigma ys
         | 
| 286 284 | 
             
                  sx2 = sigma(xs)  { |x|   x ** 2 }
         | 
| @@ -302,7 +300,7 @@ module Minitest | |
| 302 300 |  | 
| 303 301 | 
             
                def fit_power xs, ys
         | 
| 304 302 | 
             
                  n       = xs.size
         | 
| 305 | 
            -
                  xys     = xs.zip | 
| 303 | 
            +
                  xys     = xs.zip ys
         | 
| 306 304 | 
             
                  slnxlny = sigma(xys) { |x, y| Math.log(x) * Math.log(y) }
         | 
| 307 305 | 
             
                  slnx    = sigma(xs)  { |x   | Math.log(x)               }
         | 
| 308 306 | 
             
                  slny    = sigma(ys)  { |   y| Math.log(y)               }
         | 
| @@ -323,7 +321,7 @@ module Minitest | |
| 323 321 |  | 
| 324 322 | 
             
                def sigma enum, &block
         | 
| 325 323 | 
             
                  enum = enum.map(&block) if block
         | 
| 326 | 
            -
                  enum. | 
| 324 | 
            +
                  enum.sum
         | 
| 327 325 | 
             
                end
         | 
| 328 326 |  | 
| 329 327 | 
             
                ##
         | 
| @@ -419,7 +417,6 @@ module Minitest | |
| 419 417 | 
             
                  end
         | 
| 420 418 | 
             
                end
         | 
| 421 419 |  | 
| 422 | 
            -
             | 
| 423 420 | 
             
                ##
         | 
| 424 421 | 
             
                # Create a benchmark that verifies that the performance is logarithmic.
         | 
| 425 422 | 
             
                #
         | 
    
        data/lib/minitest/compress.rb
    CHANGED
    
    | @@ -11,12 +11,12 @@ module Minitest | |
| 11 11 | 
             
                def compress orig
         | 
| 12 12 | 
             
                  ary = orig
         | 
| 13 13 |  | 
| 14 | 
            -
                  eswo = ->( | 
| 14 | 
            +
                  eswo = ->(a, n, off) { # each_slice_with_offset
         | 
| 15 15 | 
             
                    if off.zero? then
         | 
| 16 | 
            -
                       | 
| 16 | 
            +
                      a.each_slice n
         | 
| 17 17 | 
             
                    else
         | 
| 18 18 | 
             
                      # [ ...off... [...n...] [...n...] ... ]
         | 
| 19 | 
            -
                      front, back =  | 
| 19 | 
            +
                      front, back = a.take(off), a.drop(off)
         | 
| 20 20 | 
             
                      [front].chain back.each_slice n
         | 
| 21 21 | 
             
                    end
         | 
| 22 22 | 
             
                  }
         | 
| @@ -29,16 +29,16 @@ module Minitest | |
| 29 29 |  | 
| 30 30 | 
             
                    order = index
         | 
| 31 31 | 
             
                      .reject { |k, v| v.size == 1 }          # { b: [1 3 5], c: [2 4 6] }
         | 
| 32 | 
            -
                      .sort_by { |k,  | 
| 33 | 
            -
                        d =  | 
| 34 | 
            -
                        [-d,  | 
| 32 | 
            +
                      .sort_by { |k, a1|                      ### sort by max dist + min offset
         | 
| 33 | 
            +
                        d = a1.each_cons(2).sum { |a2, b| b-a2 }
         | 
| 34 | 
            +
                        [-d, a1.first]
         | 
| 35 35 | 
             
                      }                                       # b: [1 3 5] c: [2 4 6]
         | 
| 36 36 |  | 
| 37 37 | 
             
                    ranges = order
         | 
| 38 | 
            -
                      .map { |k,  | 
| 39 | 
            -
                         | 
| 38 | 
            +
                      .map { |k, a1|                          # [[1..2 3..4] [2..3 4..5]]
         | 
| 39 | 
            +
                        a1
         | 
| 40 40 | 
             
                          .each_cons(2)
         | 
| 41 | 
            -
                          .map { | | 
| 41 | 
            +
                          .map { |a2, b| a2..b-1 }
         | 
| 42 42 | 
             
                      }
         | 
| 43 43 |  | 
| 44 44 | 
             
                    big_ranges = ranges
         | 
| @@ -50,7 +50,7 @@ module Minitest | |
| 50 50 | 
             
                    culprits = big_ranges
         | 
| 51 51 | 
             
                      .map { |r|
         | 
| 52 52 | 
             
                        eswo[ary, r.size, r.begin]            # [o1 s1 s1 s2 s2]
         | 
| 53 | 
            -
                          .chunk_while { |a,b| a == b } | 
| 53 | 
            +
                          .chunk_while { |a, b| a == b }      # [[o1] [s1 s1] [s2 s2]]
         | 
| 54 54 | 
             
                          .map { |a| [a.size, a.first] }      # [[1 o1] [2 s1] [2 s2]]
         | 
| 55 55 | 
             
                      }
         | 
| 56 56 | 
             
                      .select { |chunks|
         | 
    
        data/lib/minitest/mock.rb
    CHANGED
    
    | @@ -8,7 +8,7 @@ module Minitest # :nodoc: | |
| 8 8 | 
             
              # All mock objects are an instance of Mock
         | 
| 9 9 |  | 
| 10 10 | 
             
              class Mock
         | 
| 11 | 
            -
                alias  | 
| 11 | 
            +
                alias __respond_to? respond_to?
         | 
| 12 12 |  | 
| 13 13 | 
             
                overridden_methods = %i[
         | 
| 14 14 | 
             
                  ===
         | 
| @@ -30,6 +30,7 @@ module Minitest # :nodoc: | |
| 30 30 | 
             
                end
         | 
| 31 31 |  | 
| 32 32 | 
             
                overridden_methods.map(&:to_sym).each do |method_id|
         | 
| 33 | 
            +
                  old_w, $-w = $-w, nil
         | 
| 33 34 | 
             
                  define_method method_id do |*args, **kwargs, &b|
         | 
| 34 35 | 
             
                    if @expected_calls.key? method_id then
         | 
| 35 36 | 
             
                      if kwargs.empty? then # FIX: drop this after 2.7 dead
         | 
| @@ -45,6 +46,8 @@ module Minitest # :nodoc: | |
| 45 46 | 
             
                      end
         | 
| 46 47 | 
             
                    end
         | 
| 47 48 | 
             
                  end
         | 
| 49 | 
            +
                ensure
         | 
| 50 | 
            +
                  $-w = old_w
         | 
| 48 51 | 
             
                end
         | 
| 49 52 |  | 
| 50 53 | 
             
                def initialize delegator = nil # :nodoc:
         | 
| @@ -93,7 +96,7 @@ module Minitest # :nodoc: | |
| 93 96 | 
             
                def expect name, retval, args = [], **kwargs, &blk
         | 
| 94 97 | 
             
                  name = name.to_sym
         | 
| 95 98 |  | 
| 96 | 
            -
                  if  | 
| 99 | 
            +
                  if blk then
         | 
| 97 100 | 
             
                    raise ArgumentError, "args ignored when block given" unless args.empty?
         | 
| 98 101 | 
             
                    raise ArgumentError, "kwargs ignored when block given" unless kwargs.empty?
         | 
| 99 102 | 
             
                    @expected_calls[name] << { :retval => retval, :block => blk }
         | 
| @@ -106,7 +109,7 @@ module Minitest # :nodoc: | |
| 106 109 | 
             
                        kwargs = args.pop
         | 
| 107 110 | 
             
                      else
         | 
| 108 111 | 
             
                        unless @@KW_WARNED then
         | 
| 109 | 
            -
                          from = caller.first
         | 
| 112 | 
            +
                          from = caller(1..1).first
         | 
| 110 113 | 
             
                          warn "Using MT_KWARGS_HAC\K yet passing kwargs. From #{from}"
         | 
| 111 114 | 
             
                          @@KW_WARNED = true
         | 
| 112 115 | 
             
                        end
         | 
| @@ -141,16 +144,16 @@ module Minitest # :nodoc: | |
| 141 144 |  | 
| 142 145 | 
             
                def verify
         | 
| 143 146 | 
             
                  @expected_calls.each do |name, expected|
         | 
| 144 | 
            -
                    actual = @actual_calls.fetch | 
| 145 | 
            -
                    raise MockExpectationError, " | 
| 146 | 
            -
                    raise MockExpectationError, " | 
| 147 | 
            +
                    actual = @actual_calls.fetch name, nil # defaults to []
         | 
| 148 | 
            +
                    raise MockExpectationError, "Expected #{__call name, expected[0]}" unless actual
         | 
| 149 | 
            +
                    raise MockExpectationError, "Expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
         | 
| 147 150 | 
             
                      actual.size < expected.size
         | 
| 148 151 | 
             
                  end
         | 
| 149 152 | 
             
                  true
         | 
| 150 153 | 
             
                end
         | 
| 151 154 |  | 
| 152 155 | 
             
                def method_missing sym, *args, **kwargs, &block # :nodoc:
         | 
| 153 | 
            -
                  unless @expected_calls.key? | 
| 156 | 
            +
                  unless @expected_calls.key? sym then
         | 
| 154 157 | 
             
                    if @delegator && @delegator.respond_to?(sym)
         | 
| 155 158 | 
             
                      if kwargs.empty? then # FIX: drop this after 2.7 dead
         | 
| 156 159 | 
             
                        return @delegator.public_send(sym, *args, &block)
         | 
| @@ -172,9 +175,9 @@ module Minitest # :nodoc: | |
| 172 175 | 
             
                  end
         | 
| 173 176 |  | 
| 174 177 | 
             
                  expected_args, expected_kwargs, retval, val_block =
         | 
| 175 | 
            -
                    expected_call.values_at | 
| 178 | 
            +
                    expected_call.values_at :args, :kwargs, :retval, :block
         | 
| 176 179 |  | 
| 177 | 
            -
                  expected_kwargs = kwargs. | 
| 180 | 
            +
                  expected_kwargs = kwargs.to_h { |ak, av| [ak, Object] } if
         | 
| 178 181 | 
             
                    Hash == expected_kwargs
         | 
| 179 182 |  | 
| 180 183 | 
             
                  if val_block then
         | 
| @@ -197,7 +200,7 @@ module Minitest # :nodoc: | |
| 197 200 | 
             
                      [sym, expected_kwargs.size, kwargs]
         | 
| 198 201 | 
             
                  end
         | 
| 199 202 |  | 
| 200 | 
            -
                  zipped_args = expected_args.zip | 
| 203 | 
            +
                  zipped_args = expected_args.zip args
         | 
| 201 204 | 
             
                  fully_matched = zipped_args.all? { |mod, a|
         | 
| 202 205 | 
             
                    mod === a or mod == a
         | 
| 203 206 | 
             
                  }
         | 
| @@ -212,10 +215,10 @@ module Minitest # :nodoc: | |
| 212 215 | 
             
                    raise MockExpectationError, fmt % [sym, expected_kwargs.keys, kwargs.keys]
         | 
| 213 216 | 
             
                  end
         | 
| 214 217 |  | 
| 215 | 
            -
                  zipped_kwargs = expected_kwargs. | 
| 218 | 
            +
                  zipped_kwargs = expected_kwargs.to_h { |ek, ev|
         | 
| 216 219 | 
             
                    av = kwargs[ek]
         | 
| 217 220 | 
             
                    [ek, [ev, av]]
         | 
| 218 | 
            -
                  } | 
| 221 | 
            +
                  }
         | 
| 219 222 |  | 
| 220 223 | 
             
                  fully_matched = zipped_kwargs.all? { |ek, (ev, av)|
         | 
| 221 224 | 
             
                    ev === av or ev == av
         | 
| @@ -228,8 +231,8 @@ module Minitest # :nodoc: | |
| 228 231 |  | 
| 229 232 | 
             
                  @actual_calls[sym] << {
         | 
| 230 233 | 
             
                    :retval => retval,
         | 
| 231 | 
            -
                    :args | 
| 232 | 
            -
                    :kwargs => zipped_kwargs. | 
| 234 | 
            +
                    :args   => zipped_args.map { |e, a| e === a ? e : a },
         | 
| 235 | 
            +
                    :kwargs => zipped_kwargs.to_h { |k, (e, a)| [k, e === a ? e : a] },
         | 
| 233 236 | 
             
                  }
         | 
| 234 237 |  | 
| 235 238 | 
             
                  retval
         | 
| @@ -238,20 +241,35 @@ module Minitest # :nodoc: | |
| 238 241 | 
             
                def respond_to? sym, include_private = false # :nodoc:
         | 
| 239 242 | 
             
                  return true if @expected_calls.key? sym.to_sym
         | 
| 240 243 | 
             
                  return true if @delegator && @delegator.respond_to?(sym, include_private)
         | 
| 241 | 
            -
                  __respond_to? | 
| 244 | 
            +
                  __respond_to? sym, include_private
         | 
| 242 245 | 
             
                end
         | 
| 243 246 | 
             
              end
         | 
| 244 247 | 
             
            end
         | 
| 245 248 |  | 
| 246 249 | 
             
            module Minitest::Assertions
         | 
| 247 250 | 
             
              ##
         | 
| 248 | 
            -
              # Assert that the mock verifies correctly.
         | 
| 251 | 
            +
              # Assert that the mock verifies correctly and fail if not.
         | 
| 249 252 |  | 
| 250 | 
            -
              def assert_mock mock
         | 
| 253 | 
            +
              def assert_mock mock, msg = nil
         | 
| 251 254 | 
             
                assert mock.verify
         | 
| 255 | 
            +
              rescue MockExpectationError => e
         | 
| 256 | 
            +
                msg = message(msg) { e.message }
         | 
| 257 | 
            +
                flunk msg
         | 
| 252 258 | 
             
              end
         | 
| 253 259 | 
             
            end
         | 
| 254 260 |  | 
| 261 | 
            +
            module Minitest::Expectations
         | 
| 262 | 
            +
              ##
         | 
| 263 | 
            +
              # See Minitest::Assertions#assert_mock.
         | 
| 264 | 
            +
              #
         | 
| 265 | 
            +
              #    _(collection).must_verify
         | 
| 266 | 
            +
              #
         | 
| 267 | 
            +
              # :method: must_verify
         | 
| 268 | 
            +
             | 
| 269 | 
            +
              infect_an_assertion :assert_mock, :must_verify, :unary if
         | 
| 270 | 
            +
                defined?(infect_an_assertion)
         | 
| 271 | 
            +
            end
         | 
| 272 | 
            +
             | 
| 255 273 | 
             
            ##
         | 
| 256 274 | 
             
            # Object extensions for Minitest::Mock.
         | 
| 257 275 |  | 
    
        data/lib/minitest/parallel.rb
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            module Minitest
         | 
| 2 | 
            -
              module Parallel  | 
| 2 | 
            +
              module Parallel # :nodoc:
         | 
| 3 3 |  | 
| 4 4 | 
             
                ##
         | 
| 5 5 | 
             
                # The engine used to run multiple tests in parallel.
         | 
| @@ -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 |  | 
| @@ -24,10 +24,10 @@ module Minitest | |
| 24 24 | 
             
                  # Start the executor
         | 
| 25 25 |  | 
| 26 26 | 
             
                  def start
         | 
| 27 | 
            -
                    @pool  = size | 
| 28 | 
            -
                      Thread.new | 
| 27 | 
            +
                    @pool  = Array.new(size) {
         | 
| 28 | 
            +
                      Thread.new @queue do |queue|
         | 
| 29 29 | 
             
                        Thread.current.abort_on_exception = true
         | 
| 30 | 
            -
                        while  | 
| 30 | 
            +
                        while job = queue.pop do
         | 
| 31 31 | 
             
                          klass, method, reporter = job
         | 
| 32 32 | 
             
                          reporter.synchronize { reporter.prerecord klass, method }
         | 
| 33 33 | 
             
                          result = Minitest.run_one_method klass, method
         | 
| @@ -8,13 +8,13 @@ module Minitest | |
| 8 8 | 
             
              end
         | 
| 9 9 |  | 
| 10 10 | 
             
              def self.plugin_pride_init options # :nodoc:
         | 
| 11 | 
            -
                 | 
| 12 | 
            -
                  klass = ENV["TERM"] =~ /^xterm|-256color$/ ? PrideLOL : PrideIO
         | 
| 13 | 
            -
                  io    = klass.new options[:io]
         | 
| 11 | 
            +
                return unless PrideIO.pride?
         | 
| 14 12 |  | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 13 | 
            +
                klass = ENV["TERM"] =~ /^xterm|-(?:256color|direct)$/ ? PrideLOL : PrideIO
         | 
| 14 | 
            +
                io    = klass.new options[:io]
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                self.reporter.reporters.grep(Minitest::Reporter).each do |rep|
         | 
| 17 | 
            +
                  rep.io = io if rep.io.tty?
         | 
| 18 18 | 
             
                end
         | 
| 19 19 | 
             
              end
         | 
| 20 20 |  | 
| @@ -59,12 +59,10 @@ module Minitest | |
| 59 59 |  | 
| 60 60 | 
             
                def print o
         | 
| 61 61 | 
             
                  case o
         | 
| 62 | 
            -
                  when "." then
         | 
| 62 | 
            +
                  when ".", "S" then
         | 
| 63 63 | 
             
                    io.print pride o
         | 
| 64 64 | 
             
                  when "E", "F" then
         | 
| 65 65 | 
             
                    io.print "#{ESC}41m#{ESC}37m#{o}#{NND}"
         | 
| 66 | 
            -
                  when "S" then
         | 
| 67 | 
            -
                    io.print pride o
         | 
| 68 66 | 
             
                  else
         | 
| 69 67 | 
             
                    io.print o
         | 
| 70 68 | 
             
                  end
         | 
| @@ -72,11 +70,9 @@ module Minitest | |
| 72 70 |  | 
| 73 71 | 
             
                def puts *o # :nodoc:
         | 
| 74 72 | 
             
                  o.map! { |s|
         | 
| 75 | 
            -
                    s.to_s.sub( | 
| 73 | 
            +
                    s.to_s.sub("Finished") {
         | 
| 76 74 | 
             
                      @index = 0
         | 
| 77 | 
            -
                      "Fabulous run". | 
| 78 | 
            -
                        pride(c)
         | 
| 79 | 
            -
                      }.join
         | 
| 75 | 
            +
                      "Fabulous run".chars.map { |c| pride(c) }.join
         | 
| 80 76 | 
             
                    }
         | 
| 81 77 | 
             
                  }
         | 
| 82 78 |  | 
| @@ -113,7 +109,7 @@ module Minitest | |
| 113 109 | 
             
                  #
         | 
| 114 110 | 
             
                  #   plot (3*sin(x)+3), (3*sin(x+2*pi/3)+3), (3*sin(x+4*pi/3)+3)
         | 
| 115 111 |  | 
| 116 | 
            -
                  @colors = (6 * 7) | 
| 112 | 
            +
                  @colors = Array.new(6 * 7) { |n|
         | 
| 117 113 | 
             
                    n *= 1.0 / 3
         | 
| 118 114 | 
             
                    r  = (3 * Math.sin(n           ) + 3).to_i
         | 
| 119 115 | 
             
                    g  = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
         | 
    
        data/lib/minitest/spec.rb
    CHANGED
    
    | @@ -4,11 +4,11 @@ class Module # :nodoc: | |
| 4 4 | 
             
              def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
         | 
| 5 5 | 
             
                block = dont_flip == :block
         | 
| 6 6 | 
             
                dont_flip = false if block
         | 
| 7 | 
            -
                target_obj = block ?  | 
| 7 | 
            +
                target_obj = block ? "_{obj.method}" : "_(obj)"
         | 
| 8 8 |  | 
| 9 9 | 
             
                # https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html
         | 
| 10 10 | 
             
                # Drop this when we can drop ruby 2.6 (aka after rails 6.1 EOL, ~2024-06)
         | 
| 11 | 
            -
                kw_extra = "ruby2_keywords %p" % [new_name] if respond_to? | 
| 11 | 
            +
                kw_extra = "ruby2_keywords %p" % [new_name] if respond_to? :ruby2_keywords, true
         | 
| 12 12 |  | 
| 13 13 | 
             
                # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
         | 
| 14 14 | 
             
                self.class_eval <<-EOM, __FILE__, __LINE__ + 1
         | 
| @@ -81,14 +81,15 @@ module Kernel | |
| 81 81 |  | 
| 82 82 | 
             
              def describe desc, *additional_desc, &block # :doc:
         | 
| 83 83 | 
             
                stack = Minitest::Spec.describe_stack
         | 
| 84 | 
            -
                 | 
| 85 | 
            -
                 | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 84 | 
            +
                is_spec_class = Class === self && kind_of?(Minitest::Spec::DSL)
         | 
| 85 | 
            +
                name  = [stack.last, desc, *additional_desc]
         | 
| 86 | 
            +
                name.prepend self if stack.empty? && is_spec_class
         | 
| 87 | 
            +
                sclas =
         | 
| 88 | 
            +
                  stack.last                 \
         | 
| 89 | 
            +
                  || (is_spec_class && self) \
         | 
| 90 | 
            +
                  || Minitest::Spec.spec_type(desc, *additional_desc)
         | 
| 90 91 |  | 
| 91 | 
            -
                cls = sclas.create name, desc
         | 
| 92 | 
            +
                cls = sclas.create name.compact.join("::"), desc
         | 
| 92 93 |  | 
| 93 94 | 
             
                stack.push cls
         | 
| 94 95 | 
             
                cls.class_eval(&block)
         | 
| @@ -249,7 +250,7 @@ class Minitest::Spec < Minitest::Test | |
| 249 250 | 
             
                  pre, post = "let '#{name}' cannot ", ". Please use another name."
         | 
| 250 251 | 
             
                  methods = Minitest::Spec.instance_methods.map(&:to_s) - %w[subject]
         | 
| 251 252 | 
             
                  raise ArgumentError, "#{pre}begin with 'test'#{post}" if
         | 
| 252 | 
            -
                    name  | 
| 253 | 
            +
                    name.start_with? "test"
         | 
| 253 254 | 
             
                  raise ArgumentError, "#{pre}override a method in Minitest::Spec#{post}" if
         | 
| 254 255 | 
             
                    methods.include? name
         | 
| 255 256 |  | 
| @@ -268,7 +269,7 @@ class Minitest::Spec < Minitest::Test | |
| 268 269 | 
             
                end
         | 
| 269 270 |  | 
| 270 271 | 
             
                def create name, desc # :nodoc:
         | 
| 271 | 
            -
                  cls = Class.new | 
| 272 | 
            +
                  cls = Class.new self do
         | 
| 272 273 | 
             
                    @name = name
         | 
| 273 274 | 
             
                    @desc = desc
         | 
| 274 275 |  | 
| @@ -289,7 +290,7 @@ class Minitest::Spec < Minitest::Test | |
| 289 290 | 
             
                end
         | 
| 290 291 |  | 
| 291 292 | 
             
                attr_reader :desc # :nodoc:
         | 
| 292 | 
            -
                alias  | 
| 293 | 
            +
                alias specify it
         | 
| 293 294 |  | 
| 294 295 | 
             
                ##
         | 
| 295 296 | 
             
                # Rdoc... why are you so dumb?
         | 
    
        data/lib/minitest/test.rb
    CHANGED
    
    | @@ -85,20 +85,18 @@ module Minitest | |
| 85 85 | 
             
                # Runs a single test with setup/teardown hooks.
         | 
| 86 86 |  | 
| 87 87 | 
             
                def run
         | 
| 88 | 
            -
                   | 
| 89 | 
            -
                     | 
| 90 | 
            -
                       | 
| 91 | 
            -
                         | 
| 92 | 
            -
                          self.send hook
         | 
| 93 | 
            -
                        end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                        self.send self.name
         | 
| 88 | 
            +
                  time_it do
         | 
| 89 | 
            +
                    capture_exceptions do
         | 
| 90 | 
            +
                      SETUP_METHODS.each do |hook|
         | 
| 91 | 
            +
                        self.send hook
         | 
| 96 92 | 
             
                      end
         | 
| 97 93 |  | 
| 98 | 
            -
                       | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 94 | 
            +
                      self.send self.name
         | 
| 95 | 
            +
                    end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                    TEARDOWN_METHODS.each do |hook|
         | 
| 98 | 
            +
                      capture_exceptions do
         | 
| 99 | 
            +
                        self.send hook
         | 
| 102 100 | 
             
                      end
         | 
| 103 101 | 
             
                    end
         | 
| 104 102 | 
             
                  end
         | 
| @@ -230,16 +228,6 @@ module Minitest | |
| 230 228 | 
             
                  ne
         | 
| 231 229 | 
             
                end
         | 
| 232 230 |  | 
| 233 | 
            -
                def with_info_handler &block # :nodoc:
         | 
| 234 | 
            -
                  t0 = Minitest.clock_time
         | 
| 235 | 
            -
             | 
| 236 | 
            -
                  handler = lambda do
         | 
| 237 | 
            -
                    warn "\nCurrent: %s#%s %.2fs" % [self.class, self.name, Minitest.clock_time - t0]
         | 
| 238 | 
            -
                  end
         | 
| 239 | 
            -
             | 
| 240 | 
            -
                  self.class.on_signal ::Minitest.info_signal, handler, &block
         | 
| 241 | 
            -
                end
         | 
| 242 | 
            -
             | 
| 243 231 | 
             
                include LifecycleHooks
         | 
| 244 232 | 
             
                include Guard
         | 
| 245 233 | 
             
                extend Guard
         | 
    
        data/lib/minitest/test_task.rb
    CHANGED
    
    | @@ -1,6 +1,12 @@ | |
| 1 1 | 
             
            require "shellwords"
         | 
| 2 2 | 
             
            require "rbconfig"
         | 
| 3 | 
            -
             | 
| 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 |  | 
| @@ -144,7 +150,7 @@ module Minitest # :nodoc: | |
| 144 150 | 
             
                    ENV["N"] && ENV["N"].to_i > 0
         | 
| 145 151 |  | 
| 146 152 | 
             
                  lib_extras = (ENV["MT_LIB_EXTRAS"] || "").split File::PATH_SEPARATOR
         | 
| 147 | 
            -
                  self.libs[0,0] = lib_extras
         | 
| 153 | 
            +
                  self.libs[0, 0] = lib_extras
         | 
| 148 154 |  | 
| 149 155 | 
             
                  extra_args << "-n" << ENV["N"]                      if ENV["N"]
         | 
| 150 156 | 
             
                  extra_args << "-e" << ENV["X"]                      if ENV["X"]
         | 
| @@ -163,7 +169,7 @@ module Minitest # :nodoc: | |
| 163 169 | 
             
                def define # :nodoc:
         | 
| 164 170 | 
             
                  desc "Run the test suite. Use N, X, A, and TESTOPTS to add flags/args."
         | 
| 165 171 | 
             
                  task name do
         | 
| 166 | 
            -
                    ruby make_test_cmd, verbose:verbose
         | 
| 172 | 
            +
                    ruby make_test_cmd, verbose: verbose
         | 
| 167 173 | 
             
                  end
         | 
| 168 174 |  | 
| 169 175 | 
             
                  desc "Print out the test command. Good for profiling and other tools."
         | 
| @@ -177,7 +183,7 @@ module Minitest # :nodoc: | |
| 177 183 |  | 
| 178 184 | 
             
                    # 3 seems to be the magic number... (tho not by that much)
         | 
| 179 185 | 
             
                    bad, good, n = {}, [], (ENV.delete("K") || 3).to_i
         | 
| 180 | 
            -
                    file = ENV.delete | 
| 186 | 
            +
                    file = ENV.delete "F"
         | 
| 181 187 | 
             
                    times = {}
         | 
| 182 188 |  | 
| 183 189 | 
             
                    tt0 = Time.now
         | 
| @@ -238,7 +244,7 @@ module Minitest # :nodoc: | |
| 238 244 |  | 
| 239 245 | 
             
                  task "#{name}:deps" => "#{name}:isolated" # now just an alias
         | 
| 240 246 |  | 
| 241 | 
            -
                  desc " | 
| 247 | 
            +
                  desc "Run the test suite and report the slowest 25 tests."
         | 
| 242 248 | 
             
                  task "#{name}:slow" do
         | 
| 243 249 | 
             
                    sh ["rake #{name} A=-v",
         | 
| 244 250 | 
             
                        "egrep '#test_.* s = .'",
         | 
| @@ -262,11 +268,11 @@ module Minitest # :nodoc: | |
| 262 268 | 
             
                  runner = runner.join "; "
         | 
| 263 269 |  | 
| 264 270 | 
             
                  args  = []
         | 
| 265 | 
            -
                  args << "-I#{libs.join | 
| 271 | 
            +
                  args << "-I#{libs.join File::PATH_SEPARATOR}" unless libs.empty?
         | 
| 266 272 | 
             
                  args << "-w" if warning
         | 
| 267 | 
            -
                  args <<  | 
| 273 | 
            +
                  args << "-e"
         | 
| 268 274 | 
             
                  args << "'#{runner}'"
         | 
| 269 | 
            -
                  args <<  | 
| 275 | 
            +
                  args << "--"
         | 
| 270 276 | 
             
                  args << extra_args.map(&:shellescape)
         | 
| 271 277 |  | 
| 272 278 | 
             
                  args.join " "
         | 
| @@ -287,10 +293,10 @@ class Work < Queue # :nodoc: | |
| 287 293 | 
             
            end
         | 
| 288 294 |  | 
| 289 295 | 
             
            class Integer # :nodoc:
         | 
| 290 | 
            -
              def threads_do | 
| 296 | 
            +
              def threads_do jobs # :nodoc:
         | 
| 291 297 | 
             
                q = Work.new jobs
         | 
| 292 298 |  | 
| 293 | 
            -
                self | 
| 299 | 
            +
                Array.new(self) {
         | 
| 294 300 | 
             
                  Thread.new do
         | 
| 295 301 | 
             
                    while job = q.pop # go until quit value
         | 
| 296 302 | 
             
                      yield job
         |