class Minitest::Test

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/minitest/hell.rbs

class Minitest::Test
  def self.runnable_methods: () -> untyped
  def run: (Minitest::CompositeReporter reporter, ?Hash options) -> nil
end

def self.i_suck_and_my_tests_are_order_dependent!

def self.i_suck_and_my_tests_are_order_dependent!
  class << self
    undef_method :test_order if method_defined? :test_order
    define_method :test_order do :alpha end
  end
end

def self.make_my_diffs_pretty!

def self.make_my_diffs_pretty!
  require "pp"
  define_method :mu_pp, &:pretty_inspect
end

def self.parallelize_me!

def self.parallelize_me!
  include Minitest::Parallel::Test
  extend Minitest::Parallel::Test::ClassMethods
end

def self.runnable_methods

Experimental RBS support (using type sampling data from the type_fusion project).

def self.runnable_methods: () -> untyped

This signature was generated using 7 samples from 1 application.

def self.runnable_methods
  methods = methods_matching(/^test_/)
  case self.test_order
  when :random, :parallel then
    srand Minitest.seed
    methods.sort.shuffle
  when :alpha, :sorted then
    methods.sort
  else
    raise "Unknown test_order: #{self.test_order.inspect}"
  end
end

def capture_exceptions # :nodoc:

:nodoc:
def capture_exceptions # :nodoc:
  yield
rescue *PASSTHROUGH_EXCEPTIONS
  raise
rescue Assertion => e
  self.failures << e
rescue Exception => e
  self.failures << UnexpectedError.new(sanitize_exception e)
end

def class_name # :nodoc:

:nodoc:
def class_name # :nodoc:
  self.class.name # for Minitest::Reportable
end

def neuter_exception e # :nodoc:

:nodoc:
def neuter_exception e # :nodoc:
  bt = e.backtrace
  msg = e.message.dup
  new_exception e.class, msg, bt            # e.class can be a problem...
rescue
  msg.prepend "Neutered Exception #{e.class}: "
  new_exception RuntimeError, msg, bt, true # but if this raises, we die
end

def new_exception klass, msg, bt, kill = false # :nodoc:

:nodoc:
def new_exception klass, msg, bt, kill = false # :nodoc:
  ne = klass.new msg
  ne.set_backtrace bt
  if kill then
    ne.instance_variables.each do |v|
      ne.remove_instance_variable v
    end
  end
  Marshal.dump ne                           # can raise TypeError
  ne
end

def run

Experimental RBS support (using type sampling data from the type_fusion project).

def run: (Minitest::CompositeReporter reporter, ?io | IO | color | TrueClass | output_inline | TrueClass | seed | Integer | args | String options) -> nil

This signature was generated using 1 sample from 1 application.

def run
  with_info_handler do
    time_it do
      capture_exceptions do
        SETUP_METHODS.each do |hook|
          self.send hook
        end
        self.send self.name
      end
      TEARDOWN_METHODS.each do |hook|
        capture_exceptions do
          self.send hook
        end
      end
    end
  end
  Result.from self # per contract
end

def sanitize_exception e # :nodoc:

:nodoc:
def sanitize_exception e # :nodoc:
  Marshal.dump e
  e                                         # good: use as-is
rescue
  neuter_exception e
end

def with_info_handler &block # :nodoc:

:nodoc:
def with_info_handler &block # :nodoc:
  t0 = Minitest.clock_time
  handler = lambda do
    warn "\nCurrent: %s#%s %.2fs" % [self.class, self.name, Minitest.clock_time - t0]
  end
  self.class.on_signal ::Minitest.info_signal, handler, &block
end