mirror of https://github.com/apache/lucene.git
Added TestSolrServer.wrap. Adjusted Rakefile to use .wrap method in test target, and added functional tests to code coverage run.
Test coverage now at 100%! git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@494186 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c1311749ac
commit
6d0d02f41b
|
@ -82,21 +82,9 @@ task :test do
|
|||
# unit tests don't require a solr server
|
||||
Rake::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) do
|
||||
Rake::Task[:test_functionals].invoke
|
||||
rescue
|
||||
got_error = true
|
||||
ensure
|
||||
puts "stopping solr server"
|
||||
solr_server.stop
|
||||
end
|
||||
|
||||
raise "test failures" if got_error
|
||||
|
@ -107,7 +95,11 @@ namespace :test do
|
|||
# borrowed from here: http://clarkware.com/cgi/blosxom/2007/01/05#RcovRakeTask
|
||||
task :coverage do
|
||||
rm_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")
|
||||
end
|
||||
system("open coverage/index.html") if PLATFORM['darwin']
|
||||
end
|
||||
|
||||
|
|
|
@ -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_response
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,4 +45,24 @@ class TestSolrServer
|
|||
Process.kill('TERM', @pid)
|
||||
Process.wait
|
||||
end
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue