mongo-ruby-driver/Rakefile

198 lines
5.2 KiB
Ruby
Raw Normal View History

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
require 'rbconfig'
include Config
2009-12-01 22:23:24 +00:00
ENV['TEST_MODE'] = 'TRUE'
2008-11-22 01:00:51 +00:00
2010-09-30 13:43:17 +00:00
task :java do
Rake::Task['build:java'].invoke
Rake::Task['test:ruby'].invoke
end
namespace :build do
desc "Build the java extensions."
task :java do
puts "Building Java extensions..."
java_dir = File.join(File.dirname(__FILE__), 'ext', 'java')
jar_dir = File.join(java_dir, 'jar')
jruby_jar = File.join(jar_dir, 'jruby.jar')
mongo_jar = File.join(jar_dir, 'mongo-2.4.jar')
2010-10-12 19:39:28 +00:00
bson_jar = File.join(jar_dir, 'bson-2.2.jar')
2010-09-30 13:43:17 +00:00
src_base = File.join(java_dir, 'src')
system("javac -Xlint:unchecked -classpath #{jruby_jar}:#{mongo_jar}:#{bson_jar} #{File.join(src_base, 'org', 'jbson', '*.java')}")
system("cd #{src_base} && jar cf #{File.join(jar_dir, 'jbson.jar')} #{File.join('.', 'org', 'jbson', '*.class')}")
end
end
desc "Test the MongoDB Ruby driver."
task :test do
puts "\nTo test the driver with the C-extensions:\nrake test:c\n\n"
puts "To test the pure ruby driver: \nrake test:ruby\n\n"
end
namespace :test do
desc "Test the driver with the C extension enabled."
task :c do
ENV['C_EXT'] = 'TRUE'
if ENV['TEST']
Rake::Task['test:functional'].invoke
else
Rake::Task['test:unit'].invoke
Rake::Task['test:functional'].invoke
Rake::Task['test:bson'].invoke
Rake::Task['test:pooled_threading'].invoke
Rake::Task['test:drop_databases'].invoke
end
ENV['C_EXT'] = nil
end
desc "Test the driver using pure ruby (no C extension)"
task :ruby do
ENV['C_EXT'] = nil
if ENV['TEST']
Rake::Task['test:functional'].invoke
else
Rake::Task['test:unit'].invoke
Rake::Task['test:functional'].invoke
Rake::Task['test:bson'].invoke
Rake::Task['test:pooled_threading'].invoke
Rake::Task['test:drop_databases'].invoke
end
end
desc "Run the replica set test suite"
Rake::TestTask.new(:rs) do |t|
2010-12-14 22:38:52 +00:00
t.test_files = FileList['test/replica_sets/*_test.rb']
t.verbose = true
2011-02-19 22:17:21 +00:00
t.ruby_opts << '-w'
end
2010-10-12 19:39:28 +00:00
Rake::TestTask.new(:unit) do |t|
t.test_files = FileList['test/unit/*_test.rb']
t.verbose = true
2011-02-20 14:57:13 +00:00
t.ruby_opts << '-w'
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|
2010-12-15 17:16:10 +00:00
t.test_files = FileList['test/threading/*_test.rb']
2009-11-24 21:13:14 +00:00
t.verbose = true
end
2010-02-04 23:07:45 +00:00
Rake::TestTask.new(:auto_reconnect) do |t|
t.test_files = FileList['test/auxillary/autoreconnect_test.rb']
t.verbose = true
end
2010-02-25 19:58:32 +00:00
Rake::TestTask.new(:authentication) do |t|
t.test_files = FileList['test/auxillary/authentication_test.rb']
t.verbose = true
end
2010-03-19 18:05:31 +00:00
Rake::TestTask.new(:new_features) do |t|
t.test_files = FileList['test/auxillary/1.4_features.rb']
t.verbose = true
end
Rake::TestTask.new(:bson) do |t|
2010-10-12 19:39:28 +00:00
t.test_files = FileList['test/bson/*_test.rb']
t.verbose = true
2011-02-20 14:33:33 +00:00
t.ruby_opts << '-w'
end
2010-01-21 19:50:08 +00:00
task :drop_databases do |t|
puts "Dropping test databases..."
require './lib/mongo'
con = Mongo::Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Connection::DEFAULT_PORT)
con.database_names.each do |name|
con.drop_database(name) if name =~ /^ruby-test/
end
2010-01-21 19:50:08 +00:00
end
2008-11-22 01:00:51 +00:00
end
2008-12-04 21:38:04 +00:00
desc "Generate RDOC documentation"
2008-12-04 21:38:04 +00:00
task :rdoc do
version = eval(File.read("mongo.gemspec")).version
out = File.join('html', version.to_s)
FileUtils.rm_rf('html')
2010-11-29 22:04:39 +00:00
system "rdoc --main README.md --op #{out} --inline-source --quiet README.md `find lib -name '*.rb'`"
end
desc "Generate YARD documentation"
task :ydoc do
2010-01-25 19:56:48 +00:00
require File.join(File.dirname(__FILE__), 'lib', 'mongo')
out = File.join('ydoc', Mongo::VERSION)
FileUtils.rm_rf('ydoc')
system "yardoc lib/**/*.rb lib/mongo/**/*.rb lib/bson/**/*.rb -e yard/yard_ext.rb -p yard/templates -o #{out} --title MongoRuby-#{Mongo::VERSION} --files docs/TUTORIAL.md,docs/GridFS.md,docs/FAQ.md,docs/REPLICA_SETS.md,docs/WRITE_CONCERN.md,docs/HISTORY.md,docs/CREDITS.md,docs/1.0_UPGRADE.md"
end
namespace :bamboo do
2010-12-06 22:31:29 +00:00
namespace :test do
task :ruby do
Rake::Task['test:ruby'].invoke
end
2010-12-06 22:31:29 +00:00
task :c do
Rake::Task['gem:install_extensions'].invoke
Rake::Task['test:c'].invoke
end
end
end
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
2010-06-02 19:50:52 +00:00
sh "gem build bson.gemspec"
sh "gem install --no-rdoc --no-ri bson-*.gem"
sh "gem build mongo.gemspec"
sh "gem install --no-rdoc --no-ri mongo-*.gem"
2009-12-21 18:52:53 +00:00
sh "rm mongo-*.gem"
2010-06-02 19:50:52 +00:00
sh "rm bson-*.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
sh "gem build bson_ext.gemspec"
sh "gem install --no-rdoc --no-ri bson_ext-*.gem"
sh "rm bson_ext-*.gem"
2009-03-19 17:12:30 +00:00
end
2008-12-29 23:40:59 +00:00
end
namespace :ci do
namespace :test do
task :c do
Rake::Task['gem:install'].invoke
Rake::Task['gem:install_extensions'].invoke
Rake::Task['test:c'].invoke
end
end
end
2008-12-29 23:40:59 +00:00
task :default => :list
task :list do
system 'rake -T'
end