Apache Solr open-source search software
Added TestSolrServer.wrap. Adjusted Rakefile to use .wrap method in test target, and added functional tests to code coverage run.
Erik Hatcher6d0d02f41b01
diff --git a/client/ruby/solrb/Rakefile b/client/ruby/solrb/Rakefileindex 5fe8175c88d..285b5c7b1b4 100644--- a/client/ruby/solrb/Rakefile+++ b/client/ruby/solrb/Rakefile@@ -82,21 +82,9 @@ task :test do# unit tests don't require a solr serverRake::Task[:test_units].invoke rescue got_error = true- # functional tests do- solr_server = TestSolrServer.instance- solr_server.quiet = false if ENV['SOLR_CONSOLE']-- begin- puts- puts "starting solr server for functional tests"- solr_server.start- sleep 10+ # wrap functional tests with a test-specific Solr server+ got_error = TestSolrServer.wrap(:quiet => ENV['SOLR_CONSOLE'] ? false : true) doRake::Task[:test_functionals].invoke- rescue- got_error = true- ensure- puts "stopping solr server"- solr_server.stopendraise "test failures" if got_error@@ -107,7 +95,11 @@ namespace :test do# borrowed from here: http://clarkware.com/cgi/blosxom/2007/01/05#RcovRakeTasktask :coverage dorm_f "coverage"- system("rcov --text-summary -Ilib:test/unit test/unit/*_test.rb")+ rm_f "coverage.data"+ system("rcov --aggregate coverage.data --text-summary -Ilib:test/unit test/unit/*_test.rb")+ TestSolrServer.wrap do+ system("rcov --aggregate coverage.data --text-summary -Ilib:test/functional test/functional/*_test.rb")+ endsystem("open coverage/index.html") if PLATFORM['darwin']enddiff --git a/client/ruby/solrb/test/functional/server_test.rb b/client/ruby/solrb/test/functional/server_test.rbindex e387d5ae892..6983c83f8eb 100644--- a/client/ruby/solrb/test/functional/server_test.rb+++ b/client/ruby/solrb/test/functional/server_test.rb@@ -10,8 +10,15 @@# See the License for the specific language governing permissions and# limitations under the License.+require 'test/unit'+require 'solr'+class TestServer < Test::Unit::TestCase- def test_ok- assert_equal true, true+ include Solr++ def test_commit+ connection = Connection.new("http://localhost:8888")+ response = connection.send(UpdateRequest.new("<commit/>"))+ assert_equal "<result status=\"0\"></result>", response.raw_responseendenddiff --git a/client/ruby/solrb/test/functional/test_solr_server.rb b/client/ruby/solrb/test/functional/test_solr_server.rbindex 81256fd85cb..b5f4b80f578 100644--- a/client/ruby/solrb/test/functional/test_solr_server.rb+++ b/client/ruby/solrb/test/functional/test_solr_server.rb@@ -45,4 +45,24 @@ class TestSolrServerProcess.kill('TERM', @pid)Process.waitend- end++ def self.wrap(params = {})+ error = false+ solr_server = self.instance+ solr_server.quiet = params[:quiet]+ begin+ puts "starting solr server"+ solr_server.start+ sleep 10+ yield+ rescue+ error = true+ ensure+ puts "stopping solr server"+ solr_server.stop+ end++ return error+ end++end