Apache Solr open-source search software
SOLR-160: work on functional tests functioning on Windows. This commit is a slight tweak to the code contributed by Mel Riffe
Erik Hatcher5f4e9eed8827
diff --git a/client/ruby/solrb/test/functional/test_solr_server.rb b/client/ruby/solrb/test/functional/test_solr_server.rbindex 43dcc8295c0..0e58bd76673 100644--- a/client/ruby/solrb/test/functional/test_solr_server.rb+++ b/client/ruby/solrb/test/functional/test_solr_server.rb@@ -10,48 +10,27 @@# See the License for the specific language governing permissions and# limitations under the License.-# A singleton class for starting/stopping a Solr server for testing purposes-# The behavior of TestSolrServer can be modified prior to start() by changing-# port, solr_home, and quiet properties.-class TestSolrServerrequire 'singleton'include Singletonattr_accessor :port, :solr_home, :quiet-+# configure the singleton with some defaultsdef initialize@port = 8888@quiet = trueroot_dir = File.expand_path(File.dirname(__FILE__) + '/../..')@solr_dir = "#{root_dir}/solr"- @solr_home = "#{root_dir}/test"+ @solr_home = "#{root_dir}/test"@pid = nilend- # start the solr server- def start- Dir.chdir(@solr_dir) do- @pid = fork do- STDERR.close if @quiet- exec "java -Djetty.port=#{@port} -Dsolr.solr.home=#{@solr_home} " +- "-jar start.jar"- end- end- end-- # stop a running solr server- def stop- Process.kill('TERM', @pid)- Process.wait- end-def self.wrap(params = {})error = falsesolr_server = self.instancesolr_server.quiet = params[:quiet]begin- puts "starting solr server"+ puts "starting solr server on #{RUBY_PLATFORM}"solr_server.startsleep params[:startup_wait] || 5yield@@ -61,8 +40,48 @@ class TestSolrServerputs "stopping solr server"solr_server.stopend-+return errorend++ if RUBY_PLATFORM =~ /mswin32/+ require 'win32/process'++ # start the solr server+ def start+ Dir.chdir(@solr_dir) do+ @pid = Process.create(+ :app_name => "java -Djetty.port=#{@port} -Dsolr.solr.home=#{@solr_home} -jar start.jar",+ :creation_flags => Process::DETACHED_PROCESS,+ :process_inherit => false,+ :thread_inherit => true,+ :cwd => "#{@solr_dir}"+ ).process_id+ end+ end++ # stop a running solr server+ def stop+ Process.kill(1, @pid)+ Process.wait+ end+ else # Not Windows+ # start the solr server+ def start+ Dir.chdir(@solr_dir) do+ @pid = fork do+ STDERR.close if @quiet+ exec "java -Djetty.port=#{@port} -Dsolr.solr.home=#{@solr_home} " ++ "-jar start.jar"+ end+ end+ end++ # stop a running solr server+ def stop+ Process.kill('TERM', @pid)+ Process.wait+ end+ endend