class Autotest

def run

def run
  hook :initialize
  hook :post_initialize
  require "minitest/server"
  Minitest::Server.run self
  reset
  add_sigint_handler
  self.last_mtime = Time.now if options[:no_full_after_start]
  self.debug if options[:debug]
  loop do
    begin # ^c handler
      get_to_green
      if tainted? and not options[:no_full_after_failed] then
        rerun_all_tests
      else
        hook :all_good
      end
      wait_for_changes
    rescue Interrupt
      break if wants_to_quit
      reset
    end
  end
  hook :quit
  puts
rescue Exception => err
  hook(:died, err) or (
    warn "Unhandled exception: #{err}"
    warn err.backtrace.join("\n  ")
    warn "Quitting"
  )
ensure
  Minitest::Server.stop
end