module Rake

def application

Current Rake Application
def application
  @application ||= Rake::Application.new
end

def application=(app)

Set the current Rake application object.
def application=(app)
  @application = app
end

def each_dir_parent(dir) # :nodoc:

:nodoc:
Yield each file or directory component.
def each_dir_parent(dir)    # :nodoc:
  old_length = nil
  while dir != '.' && dir.length != old_length
    yield(dir)
    old_length = dir.length
    dir = File.dirname(dir)
  end
end

def load_rakefile(path)

Load a rakefile.
def load_rakefile(path)
  load(path)
end

def original_dir

Return the original directory where the Rake application was started.
def original_dir
  application.original_dir
end

def run_tests(pattern='test/test*.rb', log_enabled=false)

def run_tests(pattern='test/test*.rb', log_enabled=false)
  Dir["#{pattern}"].each { |fn|
    $stderr.puts fn if log_enabled
    begin
      require fn
    rescue Exception => ex
      $stderr.puts "Error in #{fn}: #{ex.message}"
      $stderr.puts ex.backtrace
      assert false
    end
  }
end