minitest 5.24.1 → 5.25.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +28 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +64 -69
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +10 -10
- data/lib/minitest/error_on_warning.rb +3 -3
- data/lib/minitest/mock.rb +13 -13
- data/lib/minitest/parallel.rb +4 -4
- data/lib/minitest/pride_plugin.rb +10 -14
- data/lib/minitest/spec.rb +5 -5
- data/lib/minitest/test.rb +10 -22
- data/lib/minitest/test_task.rb +9 -9
- data/lib/minitest.rb +58 -51
- data/test/minitest/metametameta.rb +6 -9
- data/test/minitest/test_minitest_assertions.rb +113 -113
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +67 -64
- data/test/minitest/test_minitest_reporter.rb +11 -15
- data/test/minitest/test_minitest_spec.rb +35 -38
- data/test/minitest/test_minitest_test.rb +80 -99
- data/test/minitest/test_minitest_test_task.rb +11 -8
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
    
        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 | 
             
                  ===
         | 
| @@ -93,7 +93,7 @@ module Minitest # :nodoc: | |
| 93 93 | 
             
                def expect name, retval, args = [], **kwargs, &blk
         | 
| 94 94 | 
             
                  name = name.to_sym
         | 
| 95 95 |  | 
| 96 | 
            -
                  if  | 
| 96 | 
            +
                  if blk then
         | 
| 97 97 | 
             
                    raise ArgumentError, "args ignored when block given" unless args.empty?
         | 
| 98 98 | 
             
                    raise ArgumentError, "kwargs ignored when block given" unless kwargs.empty?
         | 
| 99 99 | 
             
                    @expected_calls[name] << { :retval => retval, :block => blk }
         | 
| @@ -106,7 +106,7 @@ module Minitest # :nodoc: | |
| 106 106 | 
             
                        kwargs = args.pop
         | 
| 107 107 | 
             
                      else
         | 
| 108 108 | 
             
                        unless @@KW_WARNED then
         | 
| 109 | 
            -
                          from = caller.first
         | 
| 109 | 
            +
                          from = caller(1..1).first
         | 
| 110 110 | 
             
                          warn "Using MT_KWARGS_HAC\K yet passing kwargs. From #{from}"
         | 
| 111 111 | 
             
                          @@KW_WARNED = true
         | 
| 112 112 | 
             
                        end
         | 
| @@ -141,7 +141,7 @@ module Minitest # :nodoc: | |
| 141 141 |  | 
| 142 142 | 
             
                def verify
         | 
| 143 143 | 
             
                  @expected_calls.each do |name, expected|
         | 
| 144 | 
            -
                    actual = @actual_calls.fetch | 
| 144 | 
            +
                    actual = @actual_calls.fetch name, nil # defaults to []
         | 
| 145 145 | 
             
                    raise MockExpectationError, "expected #{__call name, expected[0]}" unless actual
         | 
| 146 146 | 
             
                    raise MockExpectationError, "expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
         | 
| 147 147 | 
             
                      actual.size < expected.size
         | 
| @@ -150,7 +150,7 @@ module Minitest # :nodoc: | |
| 150 150 | 
             
                end
         | 
| 151 151 |  | 
| 152 152 | 
             
                def method_missing sym, *args, **kwargs, &block # :nodoc:
         | 
| 153 | 
            -
                  unless @expected_calls.key? | 
| 153 | 
            +
                  unless @expected_calls.key? sym then
         | 
| 154 154 | 
             
                    if @delegator && @delegator.respond_to?(sym)
         | 
| 155 155 | 
             
                      if kwargs.empty? then # FIX: drop this after 2.7 dead
         | 
| 156 156 | 
             
                        return @delegator.public_send(sym, *args, &block)
         | 
| @@ -172,9 +172,9 @@ module Minitest # :nodoc: | |
| 172 172 | 
             
                  end
         | 
| 173 173 |  | 
| 174 174 | 
             
                  expected_args, expected_kwargs, retval, val_block =
         | 
| 175 | 
            -
                    expected_call.values_at | 
| 175 | 
            +
                    expected_call.values_at :args, :kwargs, :retval, :block
         | 
| 176 176 |  | 
| 177 | 
            -
                  expected_kwargs = kwargs. | 
| 177 | 
            +
                  expected_kwargs = kwargs.to_h { |ak, av| [ak, Object] } if
         | 
| 178 178 | 
             
                    Hash == expected_kwargs
         | 
| 179 179 |  | 
| 180 180 | 
             
                  if val_block then
         | 
| @@ -197,7 +197,7 @@ module Minitest # :nodoc: | |
| 197 197 | 
             
                      [sym, expected_kwargs.size, kwargs]
         | 
| 198 198 | 
             
                  end
         | 
| 199 199 |  | 
| 200 | 
            -
                  zipped_args = expected_args.zip | 
| 200 | 
            +
                  zipped_args = expected_args.zip args
         | 
| 201 201 | 
             
                  fully_matched = zipped_args.all? { |mod, a|
         | 
| 202 202 | 
             
                    mod === a or mod == a
         | 
| 203 203 | 
             
                  }
         | 
| @@ -212,10 +212,10 @@ module Minitest # :nodoc: | |
| 212 212 | 
             
                    raise MockExpectationError, fmt % [sym, expected_kwargs.keys, kwargs.keys]
         | 
| 213 213 | 
             
                  end
         | 
| 214 214 |  | 
| 215 | 
            -
                  zipped_kwargs = expected_kwargs. | 
| 215 | 
            +
                  zipped_kwargs = expected_kwargs.to_h { |ek, ev|
         | 
| 216 216 | 
             
                    av = kwargs[ek]
         | 
| 217 217 | 
             
                    [ek, [ev, av]]
         | 
| 218 | 
            -
                  } | 
| 218 | 
            +
                  }
         | 
| 219 219 |  | 
| 220 220 | 
             
                  fully_matched = zipped_kwargs.all? { |ek, (ev, av)|
         | 
| 221 221 | 
             
                    ev === av or ev == av
         | 
| @@ -228,8 +228,8 @@ module Minitest # :nodoc: | |
| 228 228 |  | 
| 229 229 | 
             
                  @actual_calls[sym] << {
         | 
| 230 230 | 
             
                    :retval => retval,
         | 
| 231 | 
            -
                    :args | 
| 232 | 
            -
                    :kwargs => zipped_kwargs. | 
| 231 | 
            +
                    :args   => zipped_args.map { |e, a| e === a ? e : a },
         | 
| 232 | 
            +
                    :kwargs => zipped_kwargs.to_h { |k, (e, a)| [k, e === a ? e : a] },
         | 
| 233 233 | 
             
                  }
         | 
| 234 234 |  | 
| 235 235 | 
             
                  retval
         | 
| @@ -238,7 +238,7 @@ module Minitest # :nodoc: | |
| 238 238 | 
             
                def respond_to? sym, include_private = false # :nodoc:
         | 
| 239 239 | 
             
                  return true if @expected_calls.key? sym.to_sym
         | 
| 240 240 | 
             
                  return true if @delegator && @delegator.respond_to?(sym, include_private)
         | 
| 241 | 
            -
                  __respond_to? | 
| 241 | 
            +
                  __respond_to? sym, include_private
         | 
| 242 242 | 
             
                end
         | 
| 243 243 | 
             
              end
         | 
| 244 244 | 
             
            end
         | 
    
        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.
         | 
| @@ -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$/ ? 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
         | 
| @@ -249,7 +249,7 @@ class Minitest::Spec < Minitest::Test | |
| 249 249 | 
             
                  pre, post = "let '#{name}' cannot ", ". Please use another name."
         | 
| 250 250 | 
             
                  methods = Minitest::Spec.instance_methods.map(&:to_s) - %w[subject]
         | 
| 251 251 | 
             
                  raise ArgumentError, "#{pre}begin with 'test'#{post}" if
         | 
| 252 | 
            -
                    name  | 
| 252 | 
            +
                    name.start_with? "test"
         | 
| 253 253 | 
             
                  raise ArgumentError, "#{pre}override a method in Minitest::Spec#{post}" if
         | 
| 254 254 | 
             
                    methods.include? name
         | 
| 255 255 |  | 
| @@ -268,7 +268,7 @@ class Minitest::Spec < Minitest::Test | |
| 268 268 | 
             
                end
         | 
| 269 269 |  | 
| 270 270 | 
             
                def create name, desc # :nodoc:
         | 
| 271 | 
            -
                  cls = Class.new | 
| 271 | 
            +
                  cls = Class.new self do
         | 
| 272 272 | 
             
                    @name = name
         | 
| 273 273 | 
             
                    @desc = desc
         | 
| 274 274 |  | 
| @@ -289,7 +289,7 @@ class Minitest::Spec < Minitest::Test | |
| 289 289 | 
             
                end
         | 
| 290 290 |  | 
| 291 291 | 
             
                attr_reader :desc # :nodoc:
         | 
| 292 | 
            -
                alias  | 
| 292 | 
            +
                alias specify it
         | 
| 293 293 |  | 
| 294 294 | 
             
                ##
         | 
| 295 295 | 
             
                # 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
    
    | @@ -150,7 +150,7 @@ module Minitest # :nodoc: | |
| 150 150 | 
             
                    ENV["N"] && ENV["N"].to_i > 0
         | 
| 151 151 |  | 
| 152 152 | 
             
                  lib_extras = (ENV["MT_LIB_EXTRAS"] || "").split File::PATH_SEPARATOR
         | 
| 153 | 
            -
                  self.libs[0,0] = lib_extras
         | 
| 153 | 
            +
                  self.libs[0, 0] = lib_extras
         | 
| 154 154 |  | 
| 155 155 | 
             
                  extra_args << "-n" << ENV["N"]                      if ENV["N"]
         | 
| 156 156 | 
             
                  extra_args << "-e" << ENV["X"]                      if ENV["X"]
         | 
| @@ -169,7 +169,7 @@ module Minitest # :nodoc: | |
| 169 169 | 
             
                def define # :nodoc:
         | 
| 170 170 | 
             
                  desc "Run the test suite. Use N, X, A, and TESTOPTS to add flags/args."
         | 
| 171 171 | 
             
                  task name do
         | 
| 172 | 
            -
                    ruby make_test_cmd, verbose:verbose
         | 
| 172 | 
            +
                    ruby make_test_cmd, verbose: verbose
         | 
| 173 173 | 
             
                  end
         | 
| 174 174 |  | 
| 175 175 | 
             
                  desc "Print out the test command. Good for profiling and other tools."
         | 
| @@ -183,7 +183,7 @@ module Minitest # :nodoc: | |
| 183 183 |  | 
| 184 184 | 
             
                    # 3 seems to be the magic number... (tho not by that much)
         | 
| 185 185 | 
             
                    bad, good, n = {}, [], (ENV.delete("K") || 3).to_i
         | 
| 186 | 
            -
                    file = ENV.delete | 
| 186 | 
            +
                    file = ENV.delete "F"
         | 
| 187 187 | 
             
                    times = {}
         | 
| 188 188 |  | 
| 189 189 | 
             
                    tt0 = Time.now
         | 
| @@ -244,7 +244,7 @@ module Minitest # :nodoc: | |
| 244 244 |  | 
| 245 245 | 
             
                  task "#{name}:deps" => "#{name}:isolated" # now just an alias
         | 
| 246 246 |  | 
| 247 | 
            -
                  desc " | 
| 247 | 
            +
                  desc "Run the test suite and report the slowest 25 tests."
         | 
| 248 248 | 
             
                  task "#{name}:slow" do
         | 
| 249 249 | 
             
                    sh ["rake #{name} A=-v",
         | 
| 250 250 | 
             
                        "egrep '#test_.* s = .'",
         | 
| @@ -268,11 +268,11 @@ module Minitest # :nodoc: | |
| 268 268 | 
             
                  runner = runner.join "; "
         | 
| 269 269 |  | 
| 270 270 | 
             
                  args  = []
         | 
| 271 | 
            -
                  args << "-I#{libs.join | 
| 271 | 
            +
                  args << "-I#{libs.join File::PATH_SEPARATOR}" unless libs.empty?
         | 
| 272 272 | 
             
                  args << "-w" if warning
         | 
| 273 | 
            -
                  args <<  | 
| 273 | 
            +
                  args << "-e"
         | 
| 274 274 | 
             
                  args << "'#{runner}'"
         | 
| 275 | 
            -
                  args <<  | 
| 275 | 
            +
                  args << "--"
         | 
| 276 276 | 
             
                  args << extra_args.map(&:shellescape)
         | 
| 277 277 |  | 
| 278 278 | 
             
                  args.join " "
         | 
| @@ -293,10 +293,10 @@ class Work < Queue # :nodoc: | |
| 293 293 | 
             
            end
         | 
| 294 294 |  | 
| 295 295 | 
             
            class Integer # :nodoc:
         | 
| 296 | 
            -
              def threads_do | 
| 296 | 
            +
              def threads_do jobs # :nodoc:
         | 
| 297 297 | 
             
                q = Work.new jobs
         | 
| 298 298 |  | 
| 299 | 
            -
                self | 
| 299 | 
            +
                Array.new(self) {
         | 
| 300 300 | 
             
                  Thread.new do
         | 
| 301 301 | 
             
                    while job = q.pop # go until quit value
         | 
| 302 302 | 
             
                      yield job
         | 
    
        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. | 
| 12 | 
            +
              VERSION = "5.25.1" # :nodoc:
         | 
| 13 13 |  | 
| 14 14 | 
             
              @@installed_at_exit ||= false
         | 
| 15 15 | 
             
              @@after_run = []
         | 
| @@ -67,9 +67,8 @@ module Minitest | |
| 67 67 | 
             
              # Registers Minitest to run at process exit
         | 
| 68 68 |  | 
| 69 69 | 
             
              def self.autorun
         | 
| 70 | 
            -
                 | 
| 71 | 
            -
                  Warning[ | 
| 72 | 
            -
                end
         | 
| 70 | 
            +
                Warning[:deprecated] = true if
         | 
| 71 | 
            +
                  Object.const_defined?(:Warning) && Warning.respond_to?(:[]=)
         | 
| 73 72 |  | 
| 74 73 | 
             
                at_exit {
         | 
| 75 74 | 
             
                  next if $! and not ($!.kind_of? SystemExit and $!.success?)
         | 
| @@ -142,7 +141,7 @@ module Minitest | |
| 142 141 |  | 
| 143 142 | 
             
              def self.process_args args = [] # :nodoc:
         | 
| 144 143 | 
             
                options = {
         | 
| 145 | 
            -
             | 
| 144 | 
            +
                            :io => $stdout,
         | 
| 146 145 | 
             
                          }
         | 
| 147 146 | 
             
                orig_args = args.dup
         | 
| 148 147 |  | 
| @@ -186,7 +185,7 @@ module Minitest | |
| 186 185 | 
             
                    options[:skip] = s.chars.to_a
         | 
| 187 186 | 
             
                  end
         | 
| 188 187 |  | 
| 189 | 
            -
                  ruby27plus = ::Warning.respond_to? | 
| 188 | 
            +
                  ruby27plus = ::Warning.respond_to? :[]=
         | 
| 190 189 |  | 
| 191 190 | 
             
                  opts.on "-W[error]", String, "Turn Ruby warnings into errors" do |s|
         | 
| 192 191 | 
             
                    options[:Werror] = true
         | 
| @@ -202,14 +201,14 @@ module Minitest | |
| 202 201 |  | 
| 203 202 | 
             
                  unless extensions.empty?
         | 
| 204 203 | 
             
                    opts.separator ""
         | 
| 205 | 
            -
                    opts.separator "Known extensions: #{extensions.join | 
| 204 | 
            +
                    opts.separator "Known extensions: #{extensions.join ", "}"
         | 
| 206 205 |  | 
| 207 206 | 
             
                    extensions.each do |mod_or_meth|
         | 
| 208 207 | 
             
                      case mod_or_meth
         | 
| 209 208 | 
             
                      when Symbol, String then
         | 
| 210 209 | 
             
                        meth = mod_or_meth
         | 
| 211 210 | 
             
                        msg = "plugin_#{meth}_options"
         | 
| 212 | 
            -
                        send msg, opts, options if respond_to? | 
| 211 | 
            +
                        send msg, opts, options if respond_to? msg
         | 
| 213 212 | 
             
                      when Module
         | 
| 214 213 | 
             
                        recv = mod_or_meth
         | 
| 215 214 | 
             
                        next unless recv.respond_to? :minitest_plugin_options
         | 
| @@ -240,7 +239,7 @@ module Minitest | |
| 240 239 | 
             
                end
         | 
| 241 240 |  | 
| 242 241 | 
             
                options[:args] = orig_args.map { |s|
         | 
| 243 | 
            -
                  s | 
| 242 | 
            +
                  s.match?(/[\s|&<>$()]/) ? s.inspect : s
         | 
| 244 243 | 
             
                }.join " "
         | 
| 245 244 |  | 
| 246 245 | 
             
                options
         | 
| @@ -282,7 +281,7 @@ module Minitest | |
| 282 281 | 
             
                self.init_plugins options
         | 
| 283 282 | 
             
                self.reporter = nil # runnables shouldn't depend on the reporter, ever
         | 
| 284 283 |  | 
| 285 | 
            -
                self.parallel_executor.start if parallel_executor.respond_to? | 
| 284 | 
            +
                self.parallel_executor.start if parallel_executor.respond_to? :start
         | 
| 286 285 | 
             
                reporter.start
         | 
| 287 286 | 
             
                begin
         | 
| 288 287 | 
             
                  __run reporter, options
         | 
| @@ -406,8 +405,8 @@ module Minitest | |
| 406 405 | 
             
                  pos = options[:filter]
         | 
| 407 406 | 
             
                  neg = options[:exclude]
         | 
| 408 407 |  | 
| 409 | 
            -
                  pos = Regexp.new $1 if pos. | 
| 410 | 
            -
                  neg = Regexp.new $1 if neg. | 
| 408 | 
            +
                  pos = Regexp.new $1 if pos.kind_of?(String) && pos =~ %r%/(.*)/%
         | 
| 409 | 
            +
                  neg = Regexp.new $1 if neg.kind_of?(String) && neg =~ %r%/(.*)/%
         | 
| 411 410 |  | 
| 412 411 | 
             
                  filtered_methods = self.runnable_methods
         | 
| 413 412 | 
             
                    .select { |m| !pos ||  pos === m || pos === "#{self}##{m}"  }
         | 
| @@ -415,8 +414,22 @@ module Minitest | |
| 415 414 |  | 
| 416 415 | 
             
                  return if filtered_methods.empty?
         | 
| 417 416 |  | 
| 417 | 
            +
                  t0 = name = nil
         | 
| 418 | 
            +
             | 
| 419 | 
            +
                  @_info_handler = lambda do
         | 
| 420 | 
            +
                    unless reporter.passed? then
         | 
| 421 | 
            +
                      warn "Current results:"
         | 
| 422 | 
            +
                      warn reporter.reporters.grep(SummaryReporter).first
         | 
| 423 | 
            +
                    end
         | 
| 424 | 
            +
             | 
| 425 | 
            +
                    warn "Current: %s#%s %.2fs" % [self, name, Minitest.clock_time - t0]
         | 
| 426 | 
            +
                  end
         | 
| 427 | 
            +
             | 
| 418 428 | 
             
                  with_info_handler reporter do
         | 
| 419 429 | 
             
                    filtered_methods.each do |method_name|
         | 
| 430 | 
            +
                      name = method_name
         | 
| 431 | 
            +
                      t0 = Minitest.clock_time
         | 
| 432 | 
            +
             | 
| 420 433 | 
             
                      run_one_method self, method_name, reporter
         | 
| 421 434 | 
             
                    end
         | 
| 422 435 | 
             
                  end
         | 
| @@ -442,16 +455,7 @@ module Minitest | |
| 442 455 | 
             
                end
         | 
| 443 456 |  | 
| 444 457 | 
             
                def self.with_info_handler reporter, &block # :nodoc:
         | 
| 445 | 
            -
                   | 
| 446 | 
            -
                    unless reporter.passed? then
         | 
| 447 | 
            -
                      warn "Current results:"
         | 
| 448 | 
            -
                      warn ""
         | 
| 449 | 
            -
                      warn reporter.reporters.first
         | 
| 450 | 
            -
                      warn ""
         | 
| 451 | 
            -
                    end
         | 
| 452 | 
            -
                  end
         | 
| 453 | 
            -
             | 
| 454 | 
            -
                  on_signal ::Minitest.info_signal, handler, &block
         | 
| 458 | 
            +
                  on_signal ::Minitest.info_signal, @_info_handler, &block
         | 
| 455 459 | 
             
                end
         | 
| 456 460 |  | 
| 457 461 | 
             
                SIGNALS = Signal.list # :nodoc:
         | 
| @@ -489,7 +493,7 @@ module Minitest | |
| 489 493 | 
             
                def marshal_dump # :nodoc:
         | 
| 490 494 | 
             
                  unless @@marshal_dump_warned then
         | 
| 491 495 | 
             
                    warn ["Minitest::Runnable#marshal_dump is deprecated.",
         | 
| 492 | 
            -
                          "You might be violating internals. From", caller.first].join " "
         | 
| 496 | 
            +
                          "You might be violating internals. From", caller(1..1).first].join " "
         | 
| 493 497 | 
             
                    @@marshal_dump_warned = true
         | 
| 494 498 | 
             
                  end
         | 
| 495 499 |  | 
| @@ -617,7 +621,7 @@ module Minitest | |
| 617 621 | 
             
                # Did this run error?
         | 
| 618 622 |  | 
| 619 623 | 
             
                def error?
         | 
| 620 | 
            -
                  self.failures.any?  | 
| 624 | 
            +
                  self.failures.any? UnexpectedError
         | 
| 621 625 | 
             
                end
         | 
| 622 626 | 
             
              end
         | 
| 623 627 |  | 
| @@ -720,7 +724,7 @@ module Minitest | |
| 720 724 | 
             
                  true
         | 
| 721 725 | 
             
                end
         | 
| 722 726 |  | 
| 723 | 
            -
                def synchronize | 
| 727 | 
            +
                def synchronize &block # :nodoc:
         | 
| 724 728 | 
             
                  @mutex.synchronize(&block)
         | 
| 725 729 | 
             
                end
         | 
| 726 730 | 
             
              end
         | 
| @@ -752,11 +756,11 @@ module Minitest | |
| 752 756 | 
             
              # own.
         | 
| 753 757 |  | 
| 754 758 | 
             
              class ProgressReporter < Reporter
         | 
| 755 | 
            -
                def prerecord klass, name  | 
| 756 | 
            -
                   | 
| 757 | 
            -
             | 
| 758 | 
            -
             | 
| 759 | 
            -
                   | 
| 759 | 
            +
                def prerecord klass, name # :nodoc:
         | 
| 760 | 
            +
                  return unless options[:verbose]
         | 
| 761 | 
            +
             | 
| 762 | 
            +
                  io.print "%s#%s = " % [klass.name, name]
         | 
| 763 | 
            +
                  io.flush
         | 
| 760 764 | 
             
                end
         | 
| 761 765 |  | 
| 762 766 | 
             
                def record result # :nodoc:
         | 
| @@ -890,10 +894,8 @@ module Minitest | |
| 890 894 | 
             
              # own.
         | 
| 891 895 |  | 
| 892 896 | 
             
              class SummaryReporter < StatisticsReporter
         | 
| 893 | 
            -
                # : | 
| 894 | 
            -
                attr_accessor : | 
| 895 | 
            -
                attr_accessor :old_sync
         | 
| 896 | 
            -
                # :startdoc:
         | 
| 897 | 
            +
                attr_accessor :sync     # :nodoc:
         | 
| 898 | 
            +
                attr_accessor :old_sync # :nodoc:
         | 
| 897 899 |  | 
| 898 900 | 
             
                def start # :nodoc:
         | 
| 899 901 | 
             
                  super
         | 
| @@ -941,20 +943,22 @@ module Minitest | |
| 941 943 | 
             
                end
         | 
| 942 944 |  | 
| 943 945 | 
             
                def to_s # :nodoc:
         | 
| 944 | 
            -
                  aggregated_results(StringIO.new( | 
| 946 | 
            +
                  aggregated_results(StringIO.new("".b)).string
         | 
| 945 947 | 
             
                end
         | 
| 946 948 |  | 
| 947 949 | 
             
                def summary # :nodoc:
         | 
| 948 | 
            -
                  extra =  | 
| 950 | 
            +
                  extra = []
         | 
| 949 951 |  | 
| 950 | 
            -
                  extra  | 
| 951 | 
            -
                    results.any?(&:skipped?) unless
         | 
| 952 | 
            -
                    options[:verbose] or options[:show_skips] or ENV["MT_NO_SKIP_MSG"]
         | 
| 952 | 
            +
                  extra << ", %d warnings" % [warnings] if options[:Werror]
         | 
| 953 953 |  | 
| 954 | 
            -
                  extra | 
| 954 | 
            +
                  extra << "\n\nYou have skipped tests. Run with --verbose for details." if
         | 
| 955 | 
            +
                    results.any?(&:skipped?) unless
         | 
| 956 | 
            +
                    options[:verbose]        or
         | 
| 957 | 
            +
                    options[:show_skips]     or
         | 
| 958 | 
            +
                    ENV["MT_NO_SKIP_MSG"]
         | 
| 955 959 |  | 
| 956 960 | 
             
                  "%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
         | 
| 957 | 
            -
                    [count, assertions, failures, errors, skips, extra]
         | 
| 961 | 
            +
                    [count, assertions, failures, errors, skips, extra.join]
         | 
| 958 962 | 
             
                end
         | 
| 959 963 | 
             
              end
         | 
| 960 964 |  | 
| @@ -1125,7 +1129,7 @@ module Minitest | |
| 1125 1129 |  | 
| 1126 1130 | 
             
                def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
         | 
| 1127 1131 | 
             
                  where = Minitest.filter_backtrace(caller).first
         | 
| 1128 | 
            -
                  where = where.split( | 
| 1132 | 
            +
                  where = where.split(":in ", 2).first # clean up noise
         | 
| 1129 1133 | 
             
                  warn "DEPRECATED: `maglev?` called from #{where}. This will fail in Minitest 6."
         | 
| 1130 1134 | 
             
                  "maglev" == platform
         | 
| 1131 1135 | 
             
                end
         | 
| @@ -1134,14 +1138,14 @@ module Minitest | |
| 1134 1138 | 
             
                # Is this running on mri?
         | 
| 1135 1139 |  | 
| 1136 1140 | 
             
                def mri? platform = RUBY_DESCRIPTION
         | 
| 1137 | 
            -
                   | 
| 1141 | 
            +
                  platform.start_with? "ruby"
         | 
| 1138 1142 | 
             
                end
         | 
| 1139 1143 |  | 
| 1140 1144 | 
             
                ##
         | 
| 1141 1145 | 
             
                # Is this running on macOS?
         | 
| 1142 1146 |  | 
| 1143 1147 | 
             
                def osx? platform = RUBY_PLATFORM
         | 
| 1144 | 
            -
                   | 
| 1148 | 
            +
                  platform.include? "darwin"
         | 
| 1145 1149 | 
             
                end
         | 
| 1146 1150 |  | 
| 1147 1151 | 
             
                ##
         | 
| @@ -1149,7 +1153,7 @@ module Minitest | |
| 1149 1153 |  | 
| 1150 1154 | 
             
                def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
         | 
| 1151 1155 | 
             
                  where = Minitest.filter_backtrace(caller).first
         | 
| 1152 | 
            -
                  where = where.split( | 
| 1156 | 
            +
                  where = where.split(":in ", 2).first # clean up noise
         | 
| 1153 1157 | 
             
                  warn "DEPRECATED: `rubinius?` called from #{where}. This will fail in Minitest 6."
         | 
| 1154 1158 | 
             
                  "rbx" == platform
         | 
| 1155 1159 | 
             
                end
         | 
| @@ -1158,7 +1162,7 @@ module Minitest | |
| 1158 1162 | 
             
                # Is this running on windows?
         | 
| 1159 1163 |  | 
| 1160 1164 | 
             
                def windows? platform = RUBY_PLATFORM
         | 
| 1161 | 
            -
                  /mswin|mingw | 
| 1165 | 
            +
                  /mswin|mingw/.match? platform
         | 
| 1162 1166 | 
             
                end
         | 
| 1163 1167 | 
             
              end
         | 
| 1164 1168 |  | 
| @@ -1169,11 +1173,14 @@ module Minitest | |
| 1169 1173 |  | 
| 1170 1174 | 
             
              class BacktraceFilter
         | 
| 1171 1175 |  | 
| 1172 | 
            -
                MT_RE = %r%lib/minitest|internal:warning%  | 
| 1176 | 
            +
                MT_RE = %r%lib/minitest|internal:warning% # :nodoc:
         | 
| 1177 | 
            +
             | 
| 1178 | 
            +
                ##
         | 
| 1179 | 
            +
                # The regular expression to use to filter backtraces. Defaults to +MT_RE+.
         | 
| 1173 1180 |  | 
| 1174 1181 | 
             
                attr_accessor :regexp
         | 
| 1175 1182 |  | 
| 1176 | 
            -
                def initialize regexp = MT_RE
         | 
| 1183 | 
            +
                def initialize regexp = MT_RE # :nodoc:
         | 
| 1177 1184 | 
             
                  self.regexp = regexp
         | 
| 1178 1185 | 
             
                end
         | 
| 1179 1186 |  | 
| @@ -1186,9 +1193,9 @@ module Minitest | |
| 1186 1193 |  | 
| 1187 1194 | 
             
                  return bt.dup if $DEBUG || ENV["MT_DEBUG"]
         | 
| 1188 1195 |  | 
| 1189 | 
            -
                  new_bt = bt.take_while { |line| line.to_s  | 
| 1190 | 
            -
                  new_bt = bt.select     { |line| line.to_s  | 
| 1191 | 
            -
                  new_bt = bt.dup | 
| 1196 | 
            +
                  new_bt = bt.take_while { |line| !regexp.match? line.to_s }
         | 
| 1197 | 
            +
                  new_bt = bt.select     { |line| !regexp.match? line.to_s } if new_bt.empty?
         | 
| 1198 | 
            +
                  new_bt = bt.dup                                            if new_bt.empty?
         | 
| 1192 1199 |  | 
| 1193 1200 | 
             
                  new_bt
         | 
| 1194 1201 | 
             
                end
         | 
| @@ -3,10 +3,6 @@ require "stringio" | |
| 3 3 | 
             
            require "minitest/autorun"
         | 
| 4 4 |  | 
| 5 5 | 
             
            class Minitest::Test
         | 
| 6 | 
            -
              def clean s
         | 
| 7 | 
            -
                s.gsub(/^ {6}/, "")
         | 
| 8 | 
            -
              end
         | 
| 9 | 
            -
             | 
| 10 6 | 
             
              def with_empty_backtrace_filter
         | 
| 11 7 | 
             
                with_backtrace_filter Minitest::BacktraceFilter.new %r%.% do
         | 
| 12 8 | 
             
                  yield
         | 
| @@ -31,6 +27,7 @@ class Minitest::Test | |
| 31 27 | 
             
              end
         | 
| 32 28 |  | 
| 33 29 | 
             
              def assert_deprecation re = /DEPRECATED/
         | 
| 30 | 
            +
                re = // if $-w.nil? # "skip" if running `rake testW0`
         | 
| 34 31 | 
             
                assert_output "", re do
         | 
| 35 32 | 
             
                  yield
         | 
| 36 33 | 
             
                end
         | 
| @@ -67,7 +64,7 @@ class MetaMetaMetaTestCase < Minitest::Test | |
| 67 64 | 
             
              def run_tu_with_fresh_reporter flags = %w[--seed 42]
         | 
| 68 65 | 
             
                options = Minitest.process_args flags
         | 
| 69 66 |  | 
| 70 | 
            -
                @output = StringIO.new("" | 
| 67 | 
            +
                @output = StringIO.new(+"")
         | 
| 71 68 |  | 
| 72 69 | 
             
                self.reporter = Minitest::CompositeReporter.new
         | 
| 73 70 | 
             
                reporter << Minitest::SummaryReporter.new(@output, options)
         | 
| @@ -76,7 +73,7 @@ class MetaMetaMetaTestCase < Minitest::Test | |
| 76 73 | 
             
                with_stderr @output do
         | 
| 77 74 | 
             
                  reporter.start
         | 
| 78 75 |  | 
| 79 | 
            -
                  yield | 
| 76 | 
            +
                  yield reporter if block_given?
         | 
| 80 77 |  | 
| 81 78 | 
             
                  @tus ||= [@tu]
         | 
| 82 79 | 
             
                  @tus.each do |tu|
         | 
| @@ -94,8 +91,8 @@ class MetaMetaMetaTestCase < Minitest::Test | |
| 94 91 | 
             
              end
         | 
| 95 92 |  | 
| 96 93 | 
             
              def assert_report expected, flags = %w[--seed 42], &block
         | 
| 97 | 
            -
                header =  | 
| 98 | 
            -
                  Run options: #{flags.map { |s| s  | 
| 94 | 
            +
                header = <<~EOM
         | 
| 95 | 
            +
                  Run options: #{flags.map { |s| s.include?("|") ? s.inspect : s }.join " "}
         | 
| 99 96 |  | 
| 100 97 | 
             
                  # Running:
         | 
| 101 98 |  | 
| @@ -130,7 +127,7 @@ class MetaMetaMetaTestCase < Minitest::Test | |
| 130 127 | 
             
                output.gsub!(/in [`']block in (?:([^']+)[#.])?/, "in 'block in")
         | 
| 131 128 | 
             
                output.gsub!(/in [`'](?:([^']+)[#.])?/, "in '")
         | 
| 132 129 |  | 
| 133 | 
            -
                output.gsub!(/( at )[^:] | 
| 130 | 
            +
                output.gsub!(/( at )([^:]+):\d+/) { "#{$1}[#{file[$2]}:LINE]" } # eval?
         | 
| 134 131 |  | 
| 135 132 | 
             
                output
         | 
| 136 133 | 
             
              end
         |