# File lib/rubygems/commands/test_command.rb, line 102
  def find_rake
    rake_path = nil;

    begin
      rake_path = Gem.bin_path('rake', 'rake')
    rescue
      if RUBY_VERSION > '1.9' and File.exist?(File.join(RbConfig::CONFIG["bindir"], Gem::Installer.exec_format % 'rake'))
        rake_path = File.join(RbConfig::CONFIG["bindir"], Gem::Installer.exec_format % 'rake')
      else
        alert_error "Couldn't find rake; rubygems-test will not work without it. Aborting."
        raise Gem::RakeNotFoundError, "Couldn't find rake; rubygems-test will not work without it."
      end
    end

    if RUBY_VERSION > '1.9' and !rake_path
      if RUBY_PLATFORM =~ /mswin/
        #
        # XXX GarbageCollect breaks ruby -S with rake.
        #
        return File.join(RbConfig::CONFIG["bindir"], 'rake.bat')
      else
        return rake_path || 'rake'
      end
    else
      return rake_path
    end
  end