[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Status report for Ruby bindings on Windows

From: Kouhei Sutou <kou_at_cozmixng.org>
Date: 2007-01-30 16:59:39 CET

Hi Joe,

In <ae6cb1100701292301o55581b5ay5826525a743d7e20@mail.gmail.com>
  "Re: Status report for Ruby bindings on Windows" on Mon, 29 Jan 2007 23:01:59 -0800,
  "Joe Swatosh" <joe.swatosh@gmail.com> wrote:

> * I didn't try your run-test.rb patch for windows. I've been toying
> with going a different way with that and I will include a patch to
> show what I'm thinking.

Thanks! Could you try my new attached patch? The patch is
based on yours.

> * Normalizing the line breaks. Upon reflection, I've decided that I
> started us down the wrong path when I modified the tests for the line
> ending issues. As I've thought about it more, I now believe that the
> bindings should do the conversions. My thinking is since Ruby treats
> line endings as "'\n" instead of "\r\n" the bindings should provide
> any multiline values Ruby expects. (This is where the 'b' comes from
> when calling File::open. Without the 'b' on windows there is a \r\n
> to \n conversion. With the 'b', no conversion. Maybe we should check
> out what the Perl and Python bindings do about this issue on
> windows?). (I've made zero effort to figure out what this will take).

OK. We'll try the problem after we solve test environment
problem on Windows.

> * (Saving the best for last) I updated against trunk last night and
> re-ran the tests and the test_client is no longer causing errors.

Thanks for confirming.

Regards,

--
kou

Index: subversion/bindings/swig/ruby/test/util.rb
===================================================================
--- subversion/bindings/swig/ruby/test/util.rb (revision 23287)
+++ subversion/bindings/swig/ruby/test/util.rb (working copy)
@@ -8,8 +8,15 @@
   end
 end
 
-module SvnTestUtil
+module SvnTestUtilSetupEnvironment
+ def setup_test_environment(top_dir, base_dir, ext_dir)
+ svnserve_dir = File.join(top_dir, 'subversion', 'svnserve')
+ ENV["PATH"] = "#{svnserve_dir}:#{ENV['PATH']}"
+ FileUtils.ln_sf(File.join(base_dir, ".libs"), ext_dir)
+ end
+end
 
+module SvnTestUtil
   def setup_basic(need_svnserve=false)
     @need_svnserve = need_svnserve
     @author = ENV["USER"] || "sample-user"
@@ -247,4 +254,10 @@
   def windows?
     /cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM)
   end
+
+ extend SvnTestUtilSetupEnvironment
+ if windows?
+ require 'windows_util'
+ include SvnTestWindowsUtil
+ end
 end
Index: subversion/bindings/swig/ruby/test/run-test.rb
===================================================================
--- subversion/bindings/swig/ruby/test/run-test.rb (revision 23287)
+++ subversion/bindings/swig/ruby/test/run-test.rb (working copy)
@@ -5,24 +5,18 @@
 
 test_dir = File.expand_path(File.join(File.dirname(__FILE__)))
 base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
-top_dir = File.expand_path(File.join(base_dir, "..", "..", ".."))
+top_dir = File.expand_path(File.join(base_dir, "..", "..", "..", ".."))
 
 ext_dir = File.join(base_dir, ".ext")
 ext_svn_dir = File.join(ext_dir, "svn")
+ext_svn_ext_dir = File.join(ext_svn_dir, "ext")
 FileUtils.mkdir_p(ext_svn_dir)
 at_exit {FileUtils.rm_rf(ext_dir)}
 
 $LOAD_PATH.unshift(test_dir)
 require 'util'
 
-if SvnTestUtil.windows?
- ext_svn_ext_dir = File.join(ext_svn_dir, "ext")
- FileUtils.mkdir_p(ext_svn_ext_dir)
- FileUtils.cp(Dir.glob(File.join(base_dir, "*.dll"), ext_svn_ext_dir))
-else
- ENV["PATH"] = "#{File.join(top_dir, 'subversion', 'svnserve')}:#{ENV['PATH']}"
- FileUtils.ln_sf(File.join(base_dir, ".libs"), File.join(ext_svn_dir, "ext"))
-end
+SvnTestUtil.setup_test_environment(top_dir, base_dir, ext_svn_ext_dir)
 
 $LOAD_PATH.unshift(ext_dir)
 $LOAD_PATH.unshift(base_dir)
Index: subversion/bindings/swig/ruby/test/windows_util.rb
===================================================================
--- subversion/bindings/swig/ruby/test/windows_util.rb (revision 0)
+++ subversion/bindings/swig/ruby/test/windows_util.rb (revision 0)
@@ -0,0 +1,123 @@
+require 'fileutils'
+
+module SvnTestWindowsUtil
+ def self.included(mod)
+ mod.extend(ClassMethods)
+ end
+
+ begin
+ require 'win32/service'
+
+ SERVICE_NAME = 'test-svn-server'
+
+ def setup_svnserve
+ @svnserve_port = @svnserve_ports.first
+ @repos_svnserve_uri = "svn://#{@svnserve_host}:#{@svnserve_port}"
+
+ unless Win32::Service.exists?(SERVICE_NAME)
+ # Here we assume that svnserve is going available on the path when the
+ # service starts. So use "svnserve" unqualified. This isn't normally
+ # how I'd recommend installing a windows service, but for running these
+ # tests it is a significantly simplifying assumption. We can't even
+ # test for svnserve being on the path here because when the service
+ # starts, it'll be running as LocalSystem and the new process may
+ # actually have a different path than we have here.
+
+ Win32::Service.new.create_service do |s|
+ s.service_name = SERVICE_NAME
+ s.binary_path_name = "svnserve"
+ s.binary_path_name << " --service"
+ s.binary_path_name << " --root \"#{@full_repos_path}\"".tr('/','\\')
+ s.binary_path_name << " --listen-host #{@svnserve_host}"
+ s.binary_path_name << " --listen-port #{@svnserve_port}"
+ end.close
+ at_exit{Win32::Service.delete(SERVICE_NAME)}
+ end
+
+ Win32::Service.start(SERVICE_NAME)
+ end
+
+ def teardown_svnserve
+ Win32::Service.stop(SERVICE_NAME) rescue Win32::ServiceError
+ end
+ rescue LoadError
+ puts "Testing with file:// instead of svn://."
+ puts "Install win32-service to enable testing with svnserve."
+
+ def setup_svnserve
+ @repos_svnserve_uri = @repos_uri
+ end
+
+ def teardown_svnserve
+ end
+ end
+
+ def add_pre_revprop_change_hook
+ File.open("#{@repos.pre_revprop_change_hook}.cmd", "w") do |hook|
+ hook.print <<-HOOK
+set REPOS=%1
+set REV=%2
+set USER=%3
+set PROPNAME=%4
+if "%PROPNAME%" == "#{Svn::Core::PROP_REVISION_LOG}" if "%USER%" == "#{@author}" exit 0
+exit 1
+ HOOK
+ end
+ end
+
+ module ClassMethods
+ def setup_test_environment(top_dir, base_dir, ext_dir)
+ build_type = "Release"
+
+ FileUtils.mkdir_p(ext_dir)
+
+ svn_version_h = File.join(top_dir, "subversion", "include",
+ "svn_version.h")
+ version = nil
+ File.open(svn_version_h) do |f|
+ f.each do |line|
+ if /^\s*#\s*define\s+SVN_VER_MAJOR\s+(\d+)/ =~ line
+ version = $1
+ break
+ end
+ end
+ end
+
+ # First we copy the ruby swig implementation library into the ext
+ # directory. So we can make it available to the bindings themselves.
+ # We assume that the libraries that libsvn_swig_ruby depends on will
+ # be available on the path.
+ relative_base_dir =
+ base_dir.sub(/^#{Regexp.escape(top_dir + File::SEPARATOR)}/, '')
+ build_base_dir = File.join(top_dir, build_type, relative_base_dir)
+ libsvn_swig_ruby_name = 'libsvn_swig_ruby'
+ dll = File.join(build_base_dir, libsvn_swig_ruby_name,
+ "#{libsvn_swig_ruby_name}-#{version}.dll")
+ FileUtils.cp(dll, ext_dir)
+
+ # Now we copy the actual swig dlls into the ext directory. Since they
+ # depend on libsvn_swig_ruby we have to provide a way for them to find
+ # libsvn_swig_ruby. Since a require will try to load a .rb before a .dll
+ # or .so, we generate an .rb that adds the ext directory to the path,
+ # before requiring the .dll (including the extension).
+ build_conf = File.join(top_dir, "build.conf")
+ File.open(build_conf) do |f|
+ f.each do |line|
+ if /^\[swig_(.+)\]\s*$/ =~ line
+ lib_name = $1
+ FileUtils.cp(File.join(build_base_dir, "#{lib_name}.dll"), ext_dir)
+ File.open(File.join(ext_dir, "#{lib_name}.rb" ), 'w') do |rb|
+ rb.puts(<<-'EOC')
+ext_dir = File.expand_path(File.dirname(__FILE__)).tr('/','\\')
+unless ENV["PATH"].split(';').include?(ext_dir)
+ ENV["PATH"] = "#{ext_dir};#{ENV['PATH']}"
+end
+require File.join(ext_dir, File.basename(__FILE__, '.rb')) + '.dll'
+EOC
+ end
+ end
+ end
+ end
+ end
+ end
+end

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Jan 30 17:00:00 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.