2009-12-21 18:09:51 +00:00
|
|
|
# -*- mode: ruby; -*-
|
2011-12-12 20:33:14 +00:00
|
|
|
if RUBY_VERSION < '1.9.0'
|
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/specification'
|
|
|
|
end
|
2008-12-04 21:38:04 +00:00
|
|
|
require 'fileutils'
|
2008-11-22 01:00:51 +00:00
|
|
|
require 'rake/testtask'
|
2011-12-12 20:33:14 +00:00
|
|
|
require 'rake'
|
|
|
|
begin
|
|
|
|
require 'ci/reporter/rake/test_unit'
|
|
|
|
rescue LoadError
|
|
|
|
end
|
2012-02-10 16:17:33 +00:00
|
|
|
|
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')
|
2011-08-10 18:14:52 +00:00
|
|
|
mongo_jar = File.join(jar_dir, 'mongo-2.6.5.jar')
|
2010-09-30 13:43:17 +00:00
|
|
|
|
|
|
|
src_base = File.join(java_dir, 'src')
|
|
|
|
|
2011-08-10 18:14:52 +00:00
|
|
|
system("javac -Xlint:deprecation -Xlint:unchecked -classpath #{jruby_jar}:#{mongo_jar} #{File.join(src_base, 'org', 'jbson', '*.java')}")
|
2010-09-30 13:43:17 +00:00
|
|
|
system("cd #{src_base} && jar cf #{File.join(jar_dir, 'jbson.jar')} #{File.join('.', 'org', 'jbson', '*.class')}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|
2010-12-14 18:14:45 +00:00
|
|
|
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"
|
2009-10-22 18:10:12 +00:00
|
|
|
end
|
|
|
|
|
2012-02-07 01:51:44 +00:00
|
|
|
task :path do
|
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
|
|
|
end
|
|
|
|
|
2009-12-02 15:12:55 +00:00
|
|
|
namespace :test do
|
2012-02-07 01:51:44 +00:00
|
|
|
|
2010-12-02 17:36:44 +00:00
|
|
|
desc "Test the driver with the C extension enabled."
|
2012-02-07 01:51:44 +00:00
|
|
|
task :c => :path do
|
2009-12-01 18:49:57 +00:00
|
|
|
ENV['C_EXT'] = 'TRUE'
|
2010-12-14 18:14:45 +00:00
|
|
|
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
|
2009-12-01 18:49:57 +00:00
|
|
|
ENV['C_EXT'] = nil
|
|
|
|
end
|
|
|
|
|
2010-12-02 17:36:44 +00:00
|
|
|
desc "Test the driver using pure ruby (no C extension)"
|
2012-02-07 01:51:44 +00:00
|
|
|
task :ruby => :path do
|
2009-12-01 18:49:57 +00:00
|
|
|
ENV['C_EXT'] = nil
|
2010-12-14 18:14:45 +00:00
|
|
|
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
|
|
|
|
|
2010-12-15 17:18:57 +00:00
|
|
|
desc "Run the replica set test suite"
|
2010-12-14 18:14:45 +00:00
|
|
|
Rake::TestTask.new(:rs) do |t|
|
2010-12-14 22:38:52 +00:00
|
|
|
t.test_files = FileList['test/replica_sets/*_test.rb']
|
2010-12-14 18:14:45 +00:00
|
|
|
t.verbose = true
|
2011-02-19 22:17:21 +00:00
|
|
|
t.ruby_opts << '-w'
|
2009-12-01 18:49:57 +00:00
|
|
|
end
|
2010-10-12 19:39:28 +00:00
|
|
|
|
2012-02-13 21:43:14 +00:00
|
|
|
desc "Run the replica set test suite"
|
|
|
|
Rake::TestTask.new(:rs_no_threads) do |t|
|
|
|
|
t.test_files = FileList['test/replica_sets/*_test.rb'] - ["test/replica_sets/refresh_with_threads_test.rb"]
|
|
|
|
t.verbose = true
|
|
|
|
t.ruby_opts << '-w'
|
|
|
|
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
|
2011-02-20 14:57:13 +00:00
|
|
|
t.ruby_opts << '-w'
|
2009-10-22 18:10:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Rake::TestTask.new(:functional) do |t|
|
2010-02-19 23:00:03 +00:00
|
|
|
t.test_files = FileList['test/*_test.rb']
|
2009-10-22 18:10:12 +00:00
|
|
|
t.verbose = true
|
2011-02-20 15:24:31 +00:00
|
|
|
t.ruby_opts << '-w'
|
2009-10-22 18:10:12 +00:00
|
|
|
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
|
2011-02-19 23:33:57 +00:00
|
|
|
t.ruby_opts << '-w'
|
2009-11-24 21:13:14 +00:00
|
|
|
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
|
2011-02-19 23:35:27 +00:00
|
|
|
t.ruby_opts << '-w'
|
2010-02-04 23:07:45 +00:00
|
|
|
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
|
2011-02-19 23:42:03 +00:00
|
|
|
t.ruby_opts << '-w'
|
2010-02-25 19:58:32 +00:00
|
|
|
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
|
2011-02-19 23:43:32 +00:00
|
|
|
t.ruby_opts << '-w'
|
2010-03-19 18:05:31 +00:00
|
|
|
end
|
|
|
|
|
2010-03-17 19:55:19 +00:00
|
|
|
Rake::TestTask.new(:bson) do |t|
|
2010-10-12 19:39:28 +00:00
|
|
|
t.test_files = FileList['test/bson/*_test.rb']
|
2010-03-17 19:55:19 +00:00
|
|
|
t.verbose = true
|
2011-02-20 14:33:33 +00:00
|
|
|
t.ruby_opts << '-w'
|
2010-03-17 19:55:19 +00:00
|
|
|
end
|
|
|
|
|
2012-02-07 01:51:44 +00:00
|
|
|
task :drop_databases => :path do |t|
|
2010-12-02 17:36:44 +00:00
|
|
|
puts "Dropping test databases..."
|
2012-02-06 22:45:41 +00:00
|
|
|
require 'mongo'
|
2010-12-02 17:36:44 +00:00
|
|
|
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
|
|
|
|
2010-12-02 17:36:44 +00:00
|
|
|
desc "Generate RDOC documentation"
|
2008-12-04 21:38:04 +00:00
|
|
|
task :rdoc do
|
2010-06-08 05:10:01 +00:00
|
|
|
version = eval(File.read("mongo.gemspec")).version
|
2009-04-14 20:53:42 +00:00
|
|
|
out = File.join('html', version.to_s)
|
2009-04-23 19:39:57 +00:00
|
|
|
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'`"
|
2009-01-08 16:42:52 +00:00
|
|
|
end
|
|
|
|
|
2010-01-07 23:35:18 +00:00
|
|
|
desc "Generate YARD documentation"
|
|
|
|
task :ydoc do
|
2012-02-06 22:45:41 +00:00
|
|
|
require 'mongo'
|
2010-01-25 19:56:48 +00:00
|
|
|
out = File.join('ydoc', Mongo::VERSION)
|
2010-01-07 23:35:18 +00:00
|
|
|
FileUtils.rm_rf('ydoc')
|
2011-09-06 20:36:45 +00:00
|
|
|
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/READ_PREFERENCE.md,docs/HISTORY.md,docs/CREDITS.md,docs/RELEASES.md,docs/CREDITS.md,docs/TAILABLE_CURSORS.md"
|
2010-01-07 23:35:18 +00:00
|
|
|
end
|
|
|
|
|
2012-02-10 16:17:33 +00:00
|
|
|
namespace :jenkins do
|
2011-04-01 20:35:18 +00:00
|
|
|
task :ci_reporter do
|
|
|
|
begin
|
|
|
|
require 'ci/reporter/rake/test_unit'
|
|
|
|
rescue LoadError
|
|
|
|
warn "Warning: Unable to load ci_reporter gem."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-12-06 22:31:29 +00:00
|
|
|
namespace :test do
|
2011-12-12 20:33:14 +00:00
|
|
|
task :ruby do
|
2010-12-06 22:31:29 +00:00
|
|
|
Rake::Task['test:ruby'].invoke
|
2010-12-06 22:00:19 +00:00
|
|
|
end
|
|
|
|
|
2011-12-12 20:35:51 +00:00
|
|
|
task :c do
|
2010-12-06 22:31:29 +00:00
|
|
|
Rake::Task['gem:install_extensions'].invoke
|
|
|
|
Rake::Task['test:c'].invoke
|
2010-12-06 22:00:19 +00:00
|
|
|
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
|
2011-04-01 20:35:18 +00:00
|
|
|
`gem build bson.gemspec`
|
|
|
|
`gem install --no-rdoc --no-ri bson-*.gem`
|
2010-11-02 18:25:14 +00:00
|
|
|
|
2011-04-01 20:35:18 +00:00
|
|
|
`gem build mongo.gemspec`
|
|
|
|
`gem install --no-rdoc --no-ri mongo-*.gem`
|
2010-11-02 18:25:14 +00:00
|
|
|
|
2011-04-01 20:35:18 +00:00
|
|
|
`rm mongo-*.gem`
|
|
|
|
`rm bson-*.gem`
|
2008-12-29 23:40:59 +00:00
|
|
|
end
|
2012-02-10 16:17:33 +00:00
|
|
|
|
|
|
|
desc "Uninstall the optional c extensions"
|
|
|
|
task :uninstall_extensions do
|
|
|
|
`gem uninstall bson_ext`
|
|
|
|
end
|
2008-12-29 23:40:59 +00:00
|
|
|
|
2009-03-19 17:12:30 +00:00
|
|
|
desc "Install the optional c extensions"
|
|
|
|
task :install_extensions do
|
2011-04-01 20:35:18 +00:00
|
|
|
`gem build bson_ext.gemspec`
|
|
|
|
`gem install --no-rdoc --no-ri bson_ext-*.gem`
|
|
|
|
`rm bson_ext-*.gem`
|
2009-03-19 17:12:30 +00:00
|
|
|
end
|
|
|
|
|
2011-02-23 19:52:06 +00:00
|
|
|
desc "Build all gems"
|
|
|
|
task :build_all do
|
2011-04-01 20:35:18 +00:00
|
|
|
`gem build mongo.gemspec`
|
|
|
|
`gem build bson.gemspec`
|
|
|
|
`gem build bson.java.gemspec`
|
|
|
|
`gem build bson_ext.gemspec`
|
2011-02-23 19:52:06 +00:00
|
|
|
end
|
|
|
|
|
2008-12-29 23:40:59 +00:00
|
|
|
end
|
|
|
|
|
2010-11-02 18:25:14 +00:00
|
|
|
namespace :ci do
|
|
|
|
namespace :test do
|
2012-02-07 01:51:44 +00:00
|
|
|
task :c => :path do
|
2010-11-02 18:25:14 +00:00
|
|
|
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
|