# File lib/hoe/test.rb, line 69
  def define_test_tasks
    default_tasks = []

    if File.directory? "test" then
      desc 'Run the test suite. Use FILTER or TESTOPTS to add flags/args.'
      task :test do
        ruby make_test_cmd
      end

      desc 'Run the test suite using multiruby.'
      task :multi do
        ruby make_test_cmd(:multi)
      end

      desc 'Show which test files fail when run alone.'
      task :test_deps do
        tests = Dir["test/**/test_*.rb"]  +  Dir["test/**/*_test.rb"]

        paths = ['bin', 'lib', 'test'].join(File::PATH_SEPARATOR)
        null_dev = Hoe::WINDOZE ? '> NUL 2>&1' : '&> /dev/null'

        tests.each do |test|
          if not system "ruby -I#{paths} #{test} #{null_dev}" then
            puts "Dependency Issues: #{test}"
          end
        end
      end

      default_tasks << :test
    end

    if File.directory? "spec" then
      found = true
      begin
        require 'spec/rake/spectask'     # rspec 1

        desc "Run all specifications"
        Spec::Rake::SpecTask.new(:spec) do |t|
          t.libs = self.rspec_dirs
          t.spec_opts = self.rspec_options
        end
      rescue LoadError
        begin
          require 'rspec/core/rake_task' # rspec 2

          desc "Run all specifications"
          RSpec::Core::RakeTask.new(:spec) do |t|
            t.rspec_opts = self.rspec_options
            t.rspec_opts << "-I#{self.rspec_dirs.join(":")}" unless
              rspec_dirs.empty?
          end
        rescue LoadError
          found = false
        end
      end

      if found then
        default_tasks << :spec
      else
        warn "Found spec dir, but couldn't load rspec (1 or 2) task. skipping."
      end
    end

    desc 'Run the default task(s).'
    task :default => default_tasks

    unless default_tasks.empty? then
      ##
      # This is for Erik Hollensbe's rubygems-test project. Hoe is
      # test-happy, so by using this plugin you're already testable. For
      # more information, see: <https://github.com/erikh/rubygems-test>
      # and/or <http://www.gem-testers.org/>

      self.spec.files += [".gemtest"]

      pkg  = pkg_path
      turd = "#{pkg}/.gemtest"

      task pkg do
        touch turd
      end
    end

    desc 'Run ZenTest against the package.'
    task :audit do
      libs = %w(lib test ext).join(File::PATH_SEPARATOR)
      sh "zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(' ')}"
    end
  end