module Oktest

Constants

FAIL_EXCEPTION

FAIL_EXCEPTION = (defined?(MiniTest) ? MiniTest::Assertion :

defined?(Test::Unit) ? Test::Unit::AssertionFailedError : AssertionFailed)
FILTER_CLASS
REPORTER_CLASS
REPORTER_CLASSES
RUNNER_CLASS
SKIP_EXCEPTION
STATUSES
THE_FIXTURE_MANAGER
THE_GLOBAL_SCOPE
TODO_EXCEPTION
VERSION

Public Class Methods

filter(filter_obj) click to toggle source
# File lib/oktest.rb, line 2336
def self.filter(filter_obj)
  filter_obj.filter_children!(THE_GLOBAL_SCOPE)
end
global_scope(&block) click to toggle source
# File lib/oktest.rb, line 1130
def self.global_scope(&block)
  #; [!flnpc] run block in the THE_GLOBAL_SCOPE object.
  #; [!pe0g2] raises error when nested called.
  self.__scope(THE_GLOBAL_SCOPE, &block)
  #; [!fcmt2] not create new scope object.
  return THE_GLOBAL_SCOPE
end
main(argv=nil) click to toggle source
# File lib/oktest.rb, line 2703
def self.main(argv=nil)
  status = MainApp.main(argv)
  exit(status)
end
run(reporter: nil, style: nil) click to toggle source
# File lib/oktest.rb, line 2053
def self.run(reporter: nil, style: nil)
  #; [!kfi8b] do nothing when 'Oktest.scope()' not called.
  return unless THE_GLOBAL_SCOPE.has_child?
  #; [!6xn3t] creates reporter object according to 'style:' keyword arg.
  klass = (style ? REPORTER_CLASSES[style] : REPORTER_CLASS)  or
    raise ArgumentError, "#{style.inspect}: unknown style."
  reporter ||= klass.new
  #; [!mn451] run test cases.
  runner = RUNNER_CLASS.new(reporter)
  runner.start()
  ! THE_GLOBAL_SCOPE.has_child?  or "** internal error"
  #; [!p52se] returns total number of failures and errors.
  counts = reporter.counts
  return counts[:FAIL] + counts[:ERROR]
end
scope(tag: nil, &block) click to toggle source
# File lib/oktest.rb, line 1138
def self.scope(tag: nil, &block)
  #; [!kem4y] detects test script filename.
  location = caller(1).first  # caller() makes performance slower, but necessary.
  filename = location =~ /:\d+/ ? $` : nil
  #; [!6ullm] changes test script filename from absolute path to relative path.
  if filename
    pwd = Dir.pwd()
    if filename.start_with?(pwd)
      filename = filename[pwd.length..-1].sub(/\A\//, '')
    elsif filename.start_with?('./')
      filename = filename[2..-1]
    end
  end
  #; [!vxoy1] creates new scope object.
  #; [!rsimc] adds scope object as child of THE_GLOBAL_SCOPE.
  scope = ScopeNode.new(THE_GLOBAL_SCOPE, filename, tag: tag)
  #; [!jmc4q] raises error when nested called.
  self.__scope(scope, &block)
  return scope
end