2009-12-21 18:09:51 +00:00
|
|
|
# -*- mode: ruby; -*-
|
2008-12-29 23:40:59 +00:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/specification'
|
2008-12-04 21:38:04 +00:00
|
|
|
require 'fileutils'
|
2008-12-29 23:40:59 +00:00
|
|
|
require 'rake'
|
2008-11-22 01:00:51 +00:00
|
|
|
require 'rake/testtask'
|
2008-12-29 23:40:59 +00:00
|
|
|
require 'rake/gempackagetask'
|
2009-03-03 22:07:22 +00:00
|
|
|
begin
|
|
|
|
require 'rake/contrib/rubyforgepublisher'
|
|
|
|
rescue LoadError
|
|
|
|
end
|
2009-03-13 16:04:54 +00:00
|
|
|
require 'rbconfig'
|
|
|
|
include Config
|
2009-12-01 22:23:24 +00:00
|
|
|
ENV['TEST_MODE'] = 'TRUE'
|
2008-11-22 01:00:51 +00:00
|
|
|
|
2009-10-20 15:31:07 +00:00
|
|
|
desc "Test the MongoDB Ruby driver."
|
2009-10-22 18:10:12 +00:00
|
|
|
task :test do
|
2009-12-01 18:49:57 +00:00
|
|
|
puts "\nThis option has changed."
|
|
|
|
puts "\nTo test the driver with the c-extensions:\nrake test:c\n"
|
|
|
|
puts "To test the pure ruby driver: \nrake test:ruby"
|
2009-10-22 18:10:12 +00:00
|
|
|
end
|
|
|
|
|
2009-12-02 15:12:55 +00:00
|
|
|
namespace :test do
|
2009-12-01 18:49:57 +00:00
|
|
|
|
|
|
|
desc "Test the driver with the c extension enabled."
|
|
|
|
task :c do
|
|
|
|
ENV['C_EXT'] = 'TRUE'
|
|
|
|
Rake::Task['test:unit'].invoke
|
|
|
|
Rake::Task['test:functional'].invoke
|
|
|
|
Rake::Task['test:pooled_threading'].invoke
|
2010-01-21 19:50:08 +00:00
|
|
|
Rake::Task['test:drop_databases'].invoke
|
2009-12-01 18:49:57 +00:00
|
|
|
ENV['C_EXT'] = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Test the driver using pure ruby (no c extension)"
|
2009-12-02 15:12:55 +00:00
|
|
|
task :ruby do
|
2009-12-01 18:49:57 +00:00
|
|
|
ENV['C_EXT'] = nil
|
|
|
|
Rake::Task['test:unit'].invoke
|
|
|
|
Rake::Task['test:functional'].invoke
|
|
|
|
Rake::Task['test:pooled_threading'].invoke
|
2010-01-21 19:50:08 +00:00
|
|
|
Rake::Task['test:drop_databases'].invoke
|
2009-12-01 18:49:57 +00:00
|
|
|
end
|
|
|
|
|
2009-10-22 18:10:12 +00:00
|
|
|
Rake::TestTask.new(:unit) do |t|
|
|
|
|
t.test_files = FileList['test/unit/*_test.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
|
|
|
Rake::TestTask.new(:functional) do |t|
|
|
|
|
t.test_files = FileList['test/test*.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
2009-11-20 22:48:41 +00:00
|
|
|
|
2009-11-24 21:13:14 +00:00
|
|
|
Rake::TestTask.new(:pooled_threading) do |t|
|
|
|
|
t.test_files = FileList['test/threading/*.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
2009-11-23 18:13:14 +00:00
|
|
|
Rake::TestTask.new(:pair_count) do |t|
|
|
|
|
t.test_files = FileList['test/replica/count_test.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
2009-11-20 22:48:41 +00:00
|
|
|
Rake::TestTask.new(:pair_insert) do |t|
|
2009-11-23 18:13:14 +00:00
|
|
|
t.test_files = FileList['test/replica/insert_test.rb']
|
2009-11-20 22:48:41 +00:00
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
2009-11-24 20:20:51 +00:00
|
|
|
Rake::TestTask.new(:pooled_pair_insert) do |t|
|
|
|
|
t.test_files = FileList['test/replica/pooled_insert_test.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
2009-11-20 22:48:41 +00:00
|
|
|
Rake::TestTask.new(:pair_query) do |t|
|
|
|
|
t.test_files = FileList['test/replica/query_test.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
2010-01-21 19:50:08 +00:00
|
|
|
|
|
|
|
task :drop_databases do |t|
|
|
|
|
puts "Dropping test database..."
|
|
|
|
require File.join(File.dirname(__FILE__), 'lib', 'mongo')
|
|
|
|
include Mongo
|
|
|
|
con = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
|
|
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT)
|
|
|
|
con.drop_database('ruby-mongo-test')
|
|
|
|
end
|
2008-11-22 01:00:51 +00:00
|
|
|
end
|
2008-12-04 21:38:04 +00:00
|
|
|
|
2008-12-04 21:44:21 +00:00
|
|
|
desc "Generate documentation"
|
2008-12-04 21:38:04 +00:00
|
|
|
task :rdoc do
|
2009-04-14 20:53:42 +00:00
|
|
|
version = eval(File.read("mongo-ruby-driver.gemspec")).version
|
|
|
|
out = File.join('html', version.to_s)
|
2009-04-23 19:39:57 +00:00
|
|
|
FileUtils.rm_rf('html')
|
2009-04-14 20:53:42 +00:00
|
|
|
system "rdoc --main README.rdoc --op #{out} --inline-source --quiet README.rdoc `find lib -name '*.rb'`"
|
2009-01-08 16:42:52 +00:00
|
|
|
end
|
|
|
|
|
2010-01-07 23:35:18 +00:00
|
|
|
desc "Generate YARD documentation"
|
|
|
|
task :ydoc do
|
|
|
|
version = eval(File.read("mongo-ruby-driver.gemspec")).version
|
|
|
|
out = File.join('ydoc', version.to_s)
|
|
|
|
FileUtils.rm_rf('ydoc')
|
|
|
|
system "yardoc lib/**/*.rb lib/mongo/**/*.rb -o #{out} --title MongoRuby-#{version}"
|
|
|
|
end
|
|
|
|
|
2009-01-08 16:42:52 +00:00
|
|
|
desc "Publish documentation to mongo.rubyforge.org"
|
|
|
|
task :publish => [:rdoc] do
|
|
|
|
# Assumes docs are in ./html
|
|
|
|
Rake::RubyForgePublisher.new(GEM, RUBYFORGE_USER).upload
|
2008-12-04 21:38:04 +00:00
|
|
|
end
|
2008-12-29 23:40:59 +00:00
|
|
|
|
2009-03-02 16:49:56 +00:00
|
|
|
namespace :gem do
|
2008-12-29 23:40:59 +00:00
|
|
|
|
|
|
|
desc "Install the gem locally"
|
2009-01-16 20:01:31 +00:00
|
|
|
task :install do
|
2009-12-21 18:52:53 +00:00
|
|
|
sh "gem build mongo-ruby-driver.gemspec"
|
|
|
|
sh "gem install mongo-*.gem"
|
|
|
|
sh "rm mongo-*.gem"
|
2008-12-29 23:40:59 +00:00
|
|
|
end
|
|
|
|
|
2009-03-19 17:12:30 +00:00
|
|
|
desc "Install the optional c extensions"
|
|
|
|
task :install_extensions do
|
2009-12-21 18:52:53 +00:00
|
|
|
sh "gem build mongo-extensions.gemspec"
|
|
|
|
sh "gem install mongo_ext-*.gem"
|
|
|
|
sh "rm mongo_ext-*.gem"
|
2009-03-19 17:12:30 +00:00
|
|
|
end
|
|
|
|
|
2008-12-29 23:40:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
task :default => :list
|
|
|
|
|
|
|
|
task :list do
|
|
|
|
system 'rake -T'
|
|
|
|
end
|