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
|
|
|
|
|
2007-01-02 23:57:00 -05:00
|
|
|
SOLRB_VERSION = '0.0.1'
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
task :default => [:test]
|
|
|
|
|
|
|
|
spec = Gem::Specification.new do |s|
|
2007-01-12 22:02:26 -05:00
|
|
|
s.name = 'solrb'
|
2007-01-02 23:57:00 -05:00
|
|
|
s.version = SOLRB_VERSION
|
|
|
|
s.author = 'Apache Solr'
|
|
|
|
s.email = 'solr-user@lucene.apache.org'
|
|
|
|
s.homepage = 'http://wiki.apache.org/solr/Flare'
|
|
|
|
s.platform = Gem::Platform::RUBY
|
|
|
|
s.summary = 'A ruby library for working with Apache Solr'
|
|
|
|
s.files = Dir.glob("{lib,test}/**/*")
|
|
|
|
s.require_path = 'lib'
|
|
|
|
s.autorequire = 'solr'
|
|
|
|
s.has_rdoc = true
|
|
|
|
end
|
|
|
|
|
|
|
|
Rake::GemPackageTask.new(spec) do |pkg|
|
|
|
|
pkg.need_zip = true
|
|
|
|
pkg.need_tar = true
|
|
|
|
end
|
|
|
|
|
|
|
|
Rake::RDocTask.new('doc') do |rd|
|
|
|
|
rd.rdoc_files.include("lib/**/*.rb")
|
|
|
|
rd.main = 'Solr::Connection'
|
|
|
|
rd.rdoc_dir = 'doc'
|
|
|
|
end
|
2007-01-03 20:00:30 -05:00
|
|
|
|
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-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
|
|
|
|
|
|
|
|
task :test do
|
2007-01-08 11:05:02 -05:00
|
|
|
# unit tests don't require a solr server
|
2007-01-12 23:34:29 -05:00
|
|
|
Rake::Task[:test_units].invoke
|
2007-01-08 11:05:02 -05:00
|
|
|
|
2007-01-08 15:23:28 -05:00
|
|
|
# wrap functional tests with a test-specific Solr server
|
|
|
|
got_error = TestSolrServer.wrap(:quiet => ENV['SOLR_CONSOLE'] ? false : true) 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
|
|
|
|
|
|
|
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
|
|
|
|
rm_f "coverage"
|
2007-01-08 15:23:28 -05:00
|
|
|
rm_f "coverage.data"
|
|
|
|
TestSolrServer.wrap do
|
|
|
|
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-08 11:57:36 -05:00
|
|
|
end
|