2007-01-08 11:05:02 -05:00
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
# the default task is to run both the unit and functional tests
|
|
|
|
# functional tests require that a solr test server is running
|
|
|
|
# but this Rakefil should take care of starting and stopping it
|
|
|
|
# for you
|
|
|
|
#
|
|
|
|
# if you just want to run unit tests:
|
|
|
|
#
|
|
|
|
# rake test_units
|
|
|
|
#
|
|
|
|
# and if you just want to run functional tests
|
|
|
|
#
|
|
|
|
# rake test_functionals
|
|
|
|
#
|
|
|
|
# if you would like to see solr startup messages on STDERR
|
|
|
|
# when starting solr test server during functional tests use:
|
|
|
|
#
|
|
|
|
# rake SOLR_CONSOLE=true
|
|
|
|
|
2009-10-12 14:31:18 -04:00
|
|
|
SOLR_RUBY_VERSION = '0.0.8'
|
2007-01-02 23:57:00 -05:00
|
|
|
|
|
|
|
require 'rubygems'
|
|
|
|
require 'rake'
|
|
|
|
require 'rake/testtask'
|
|
|
|
require 'rake/rdoctask'
|
|
|
|
require 'rake/packagetask'
|
|
|
|
require 'rake/gempackagetask'
|
2007-01-08 11:28:19 -05:00
|
|
|
require 'test/functional/test_solr_server'
|
2007-01-02 23:57:00 -05:00
|
|
|
|
2007-01-21 14:11:34 -05:00
|
|
|
task :default => [:test_units]
|
2007-01-02 23:57:00 -05:00
|
|
|
|
2007-02-19 12:33:11 -05:00
|
|
|
SOLR_PARAMS = {
|
|
|
|
:quiet => ENV['SOLR_CONSOLE'] ? false : true,
|
|
|
|
:jetty_home => ENV['SOLR_JETTY_HOME'] || File.expand_path('../../../example'),
|
|
|
|
:jetty_port => ENV['SOLR_JETTY_PORT'] || 8888,
|
|
|
|
:solr_home => ENV['SOLR_HOME'] || File.expand_path('test')
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-02 23:57:00 -05:00
|
|
|
spec = Gem::Specification.new do |s|
|
2007-02-18 21:20:25 -05:00
|
|
|
s.name = 'solr-ruby'
|
|
|
|
s.version = SOLR_RUBY_VERSION
|
2007-01-02 23:57:00 -05:00
|
|
|
s.author = 'Apache Solr'
|
2007-02-18 21:20:25 -05:00
|
|
|
s.email = 'ruby-dev@lucene.apache.org'
|
|
|
|
s.homepage = 'http://wiki.apache.org/solr/solr-ruby'
|
2007-01-02 23:57:00 -05:00
|
|
|
s.platform = Gem::Platform::RUBY
|
2007-01-14 20:44:37 -05:00
|
|
|
s.summary = 'Ruby library for working with Apache Solr'
|
2007-01-21 16:04:39 -05:00
|
|
|
|
|
|
|
# Omit functional tests from gem for now, as that requires a Solr instance
|
|
|
|
s.files = Dir.glob("lib/**/*").concat(Dir.glob("test/unit/**/*"))
|
2007-01-02 23:57:00 -05:00
|
|
|
s.require_path = 'lib'
|
|
|
|
s.autorequire = 'solr'
|
|
|
|
s.has_rdoc = true
|
|
|
|
end
|
|
|
|
|
2007-02-09 16:01:18 -05:00
|
|
|
namespace :gem do
|
|
|
|
Rake::GemPackageTask.new(spec) do |pkg|
|
|
|
|
pkg.need_zip = true
|
|
|
|
pkg.need_tar = true
|
|
|
|
pkg.package_dir = "pkg/gem"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :rails do
|
|
|
|
desc "Creates rails plugin structure and distributable packages. init.rb is created and removed on the fly."
|
|
|
|
task :package => "init.rb" do
|
|
|
|
File.rm_f("init.rb")
|
|
|
|
end
|
2007-02-18 21:20:25 -05:00
|
|
|
Rake::PackageTask.new("solr-ruby-rails", SOLR_RUBY_VERSION) do |pkg|
|
2007-02-09 16:01:18 -05:00
|
|
|
pkg.need_zip = true
|
|
|
|
pkg.need_tar = true
|
|
|
|
pkg.package_dir = "pkg/rails"
|
|
|
|
pkg.package_files.include("lib/**/*.rb", "test/unit/**/*.rb", "init.rb", "LICENSE.txt", "README")
|
|
|
|
end
|
|
|
|
|
|
|
|
file "init.rb" do
|
|
|
|
open("init.rb", "w") do |file|
|
|
|
|
file.puts LICENSE
|
|
|
|
file.puts "require 'solr.rb'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-02-12 06:33:42 -05:00
|
|
|
desc "Install the Rails plugin version into the vendor/plugins dir. Need to set PLUGINS_DIR environment variable."
|
2007-02-18 21:20:25 -05:00
|
|
|
task :install_solr_ruby => :package do
|
2007-02-12 06:33:42 -05:00
|
|
|
plugins_dir = ENV["PLUGINS_DIR"] or raise "You must set PLUGINS_DIR"
|
2007-03-22 05:40:04 -04:00
|
|
|
mkdir File.join(plugins_dir, "solr-ruby-rails-#{SOLR_RUBY_VERSION}/") rescue nil
|
|
|
|
File.cp_r(File.join("pkg","rails", "solr-ruby-rails-#{SOLR_RUBY_VERSION}/"), plugins_dir)
|
2007-02-12 06:33:42 -05:00
|
|
|
end
|
2007-01-02 23:57:00 -05:00
|
|
|
end
|
|
|
|
|
2007-02-09 16:01:18 -05:00
|
|
|
task :package => ["rails:package", "gem:package"]
|
|
|
|
task :repackage => [:clobber_package, :package]
|
|
|
|
task :clobber_package => ["rails:clobber_package", "gem:clobber_package"] do rm_r "pkg" rescue nil end
|
|
|
|
task :clobber => [:clobber_package]
|
|
|
|
|
2007-01-30 01:05:21 -05:00
|
|
|
desc "Generate rdoc documentation"
|
2007-01-02 23:57:00 -05:00
|
|
|
Rake::RDocTask.new('doc') do |rd|
|
|
|
|
rd.rdoc_files.include("lib/**/*.rb")
|
2007-10-05 08:56:30 -04:00
|
|
|
rd.rdoc_files.include('README', 'CHANGES.yml', 'LICENSE.txt')
|
2007-01-24 11:16:01 -05:00
|
|
|
rd.main = 'README'
|
2007-01-02 23:57:00 -05:00
|
|
|
rd.rdoc_dir = 'doc'
|
|
|
|
end
|
2007-01-03 20:00:30 -05:00
|
|
|
|
2007-01-30 01:05:21 -05:00
|
|
|
desc "Run unit tests"
|
2007-01-08 11:05:02 -05:00
|
|
|
Rake::TestTask.new(:test_units) do |t|
|
|
|
|
t.pattern = 'test/unit/*_test.rb'
|
|
|
|
t.verbose = true
|
|
|
|
t.ruby_opts = ['-r solr', '-r test/unit', '-Itest/unit']
|
2007-01-03 20:00:30 -05:00
|
|
|
end
|
|
|
|
|
2007-01-21 14:11:34 -05:00
|
|
|
# NOTE: test_functionals does not work standalone currently. It needs the TestSolrServer wrapper in the :test task
|
2007-01-08 11:05:02 -05:00
|
|
|
Rake::TestTask.new(:test_functionals) do |t|
|
|
|
|
t.pattern = 'test/functional/*_test.rb'
|
2007-01-03 20:00:30 -05:00
|
|
|
t.verbose = true
|
2007-01-08 11:05:02 -05:00
|
|
|
t.ruby_opts = ['-r solr', '-r test/unit', '-Itest/functional']
|
2007-01-03 20:00:30 -05:00
|
|
|
end
|
|
|
|
|
2007-01-30 01:05:21 -05:00
|
|
|
desc "Run unit and functional tests"
|
|
|
|
task :test => [:test_units] do
|
2007-01-21 14:11:34 -05:00
|
|
|
rm_rf "test/data" # remove functional test temp data directory
|
|
|
|
|
2007-01-08 15:23:28 -05:00
|
|
|
# wrap functional tests with a test-specific Solr server
|
2007-02-19 12:33:11 -05:00
|
|
|
got_error = TestSolrServer.wrap(SOLR_PARAMS) do
|
2007-01-08 11:05:02 -05:00
|
|
|
Rake::Task[:test_functionals].invoke
|
|
|
|
end
|
|
|
|
|
|
|
|
raise "test failures" if got_error
|
2007-01-03 20:00:30 -05:00
|
|
|
end
|
2007-01-08 11:05:02 -05:00
|
|
|
|
2007-01-30 01:05:21 -05:00
|
|
|
# TODO: consider replacing system() to rcov with the included
|
|
|
|
# Rake task: http://eigenclass.org/hiki.rb?cmd=view&p=rcov+FAQ&key=rake
|
2007-01-08 11:05:02 -05:00
|
|
|
namespace :test do
|
|
|
|
desc 'Measures test coverage'
|
2007-01-08 11:57:36 -05:00
|
|
|
# borrowed from here: http://clarkware.com/cgi/blosxom/2007/01/05#RcovRakeTask
|
2007-01-08 11:05:02 -05:00
|
|
|
task :coverage do
|
2007-01-21 14:11:34 -05:00
|
|
|
rm_rf "coverage"
|
|
|
|
rm_rf "coverage.data"
|
2007-02-19 12:33:11 -05:00
|
|
|
TestSolrServer.wrap(SOLR_PARAMS) do
|
2007-01-08 15:23:28 -05:00
|
|
|
system("rcov --aggregate coverage.data --text-summary -Ilib:test/functional test/functional/*_test.rb")
|
|
|
|
end
|
2007-01-12 21:53:39 -05:00
|
|
|
system("rcov --aggregate coverage.data --text-summary -Ilib:test/unit test/unit/*_test.rb")
|
2007-01-08 11:05:02 -05:00
|
|
|
system("open coverage/index.html") if PLATFORM['darwin']
|
|
|
|
end
|
2007-01-30 01:05:21 -05:00
|
|
|
end
|
|
|
|
|
2007-01-08 11:05:02 -05:00
|
|
|
|
2007-01-30 01:05:21 -05:00
|
|
|
def egrep(pattern)
|
|
|
|
Dir['**/*.rb'].each do |fn|
|
|
|
|
count = 0
|
|
|
|
open(fn) do |f|
|
|
|
|
while line = f.gets
|
2007-03-22 05:40:04 -04:00
|
|
|
count += 1
|
|
|
|
if line =~ pattern
|
|
|
|
puts "#{fn}:#{count}:#{line}"
|
|
|
|
end
|
2007-01-30 01:05:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2007-01-08 11:57:36 -05:00
|
|
|
end
|
2007-01-30 01:05:21 -05:00
|
|
|
|
|
|
|
desc "Report TODO/FIXME/TBD tags in the code"
|
|
|
|
task :todo do
|
|
|
|
egrep /#.*(FIXME|TODO|TBD)/
|
|
|
|
end
|
|
|
|
|
2007-02-09 16:01:18 -05:00
|
|
|
LICENSE = <<STR
|
2007-02-09 16:03:33 -05:00
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
2007-02-09 16:01:18 -05:00
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2007-02-09 16:03:33 -05:00
|
|
|
STR
|